func (fs *unionFS) putDeletion(name string) (code fuse.Status) { code = fs.createDeletionStore() if !code.Ok() { return code } marker := fs.deletionPath(name) fs.deletionCache.AddEntry(path.Base(marker)) // Is there a WriteStringToFileOrDie ? writable := fs.fileSystems[0] fi, code := writable.GetAttr(marker, nil) if code.Ok() && fi.Size == uint64(len(name)) { return fuse.OK } var f nodefs.File if code == fuse.ENOENT { f, code = writable.Create(marker, uint32(os.O_TRUNC|os.O_WRONLY), 0644, nil) } else { writable.Chmod(marker, 0644, nil) f, code = writable.Open(marker, uint32(os.O_TRUNC|os.O_WRONLY), nil) } if !code.Ok() { log.Printf("could not create deletion file %v: %v", marker, code) return fuse.EPERM } defer f.Release() defer f.Flush() n, code := f.Write([]byte(name), 0) if int(n) != len(name) || !code.Ok() { panic(fmt.Sprintf("Error for writing %v: %v, %v (exp %v) %v", name, marker, n, len(name), code)) } return fuse.OK }
func (n *pathInode) Write(file nodefs.File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { if file != nil { return file.Write(data, off) } return 0, fuse.ENOSYS }