diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-15 03:22:20 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-15 03:22:20 +0900 |
| commit | f955b15b84354c2f83ab542512f198404c1ec52f (patch) | |
| tree | 5e85d5d7766377bf096cae01a98a01e612db5b70 /internal/system/tmpfiles.go | |
| parent | 0340c679955acedf5db92004420634a565b1c303 (diff) | |
system: remove write mode tmpfiles
This interface is ugly and bug-prone. This change removes its write mode which has been obsoleted by CopyBind.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/system/tmpfiles.go')
| -rw-r--r-- | internal/system/tmpfiles.go | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/internal/system/tmpfiles.go b/internal/system/tmpfiles.go index e51eaaef..6dd97903 100644 --- a/internal/system/tmpfiles.go +++ b/internal/system/tmpfiles.go @@ -42,26 +42,9 @@ func (sys *I) LinkFileType(et Enablement, oldname, newname string) *I { return sys } -// Write registers an Op that writes dst with the contents of src. -func (sys *I) Write(dst, src string) *I { - return sys.WriteType(Process, dst, src) -} - -// WriteType registers a file writing Op labelled with type et. -func (sys *I) WriteType(et Enablement, dst, src string) *I { - sys.lock.Lock() - sys.ops = append(sys.ops, &Tmpfile{et, tmpfileWrite, dst, src}) - sys.lock.Unlock() - - sys.UpdatePermType(et, dst, acl.Read) - - return sys -} - const ( tmpfileCopy uint8 = iota tmpfileLink - tmpfileWrite ) type Tmpfile struct { @@ -84,10 +67,6 @@ func (t *Tmpfile) apply(_ *I) error { fmsg.VPrintln("linking tmpfile", t) return fmsg.WrapErrorSuffix(os.Link(t.src, t.dst), fmt.Sprintf("cannot link tmpfile %q:", t.dst)) - case tmpfileWrite: - fmsg.VPrintln("writing", t) - return fmsg.WrapErrorSuffix(os.WriteFile(t.dst, []byte(t.src), 0600), - fmt.Sprintf("cannot write tmpfile %q:", t.dst)) default: panic("invalid tmpfile method " + strconv.Itoa(int(t.method))) } @@ -109,12 +88,7 @@ func (t *Tmpfile) Is(o Op) bool { return ok && t0 != nil && *t == *t0 } -func (t *Tmpfile) Path() string { - if t.method == tmpfileWrite { - return fmt.Sprintf("(%d bytes of data)", len(t.src)) - } - return t.src -} +func (t *Tmpfile) Path() string { return t.src } func (t *Tmpfile) String() string { switch t.method { @@ -122,8 +96,6 @@ func (t *Tmpfile) String() string { return fmt.Sprintf("%q from %q", t.dst, t.src) case tmpfileLink: return fmt.Sprintf("%q from %q", t.dst, t.src) - case tmpfileWrite: - return fmt.Sprintf("%d bytes of data to %q", len(t.src), t.dst) default: panic("invalid tmpfile method " + strconv.Itoa(int(t.method))) } |
