commit 7e515ad7cc20e51a137378d22abae7164d23e286
parent 2bbf1a97d3e0f23e87da85cbbdc809e603371461
Author: Matsuda Kenji <info@mtkn.jp>
Date: Tue, 19 Dec 2023 11:49:44 +0900
not open file when chgro
Diffstat:
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/diskfs/stat_unix.go b/diskfs/stat_unix.go
@@ -23,7 +23,7 @@ func fiStat(pool *QidPool, id fileID, info fs.FileInfo) (*lib9p.Stat, error) {
var err error
qid, err = pool.addID(id, info)
if err != nil {
- panic(fmt.Errorf("allocID: %v", err))
+ return nil, fmt.Errorf("allocID: %v", err)
}
}
@@ -138,17 +138,10 @@ func (f *File) wstat(s *lib9p.Stat) error {
if err != nil {
return fmt.Errorf("convert gid: %v", err)
}
- if file == nil {
- file, err = os.OpenFile(path.Join(f.fs.rootPath, f.path), os.O_RDWR, 0)
- if err != nil {
- return err
- }
- defer file.Close()
- }
- if err := file.Chown(u, g); err != nil {
+ if err := os.Chown(filepath.Join(f.fs.rootPath, f.path), u, g); err != nil {
return fmt.Errorf("chown: %v", err)
}
- st, err := file.Stat()
+ st, err := fs.Stat(lib9p.ExportFS{f.fs}, filepath.Join(f.fs.rootPath, f.path))
if err != nil {
return fmt.Errorf("stat: %v", err)
}
@@ -157,7 +150,7 @@ func (f *File) wstat(s *lib9p.Stat) error {
gidCache[fileid] = s.Gid
}
if s.Name != oldStat.Name {
- // TODO: check neither Names contains "/"
+ // TODO: check neither Name contains "/"
oldpath := path.Join(f.fs.rootPath, path.Dir(f.path), oldStat.Name)
newpath := path.Join(f.fs.rootPath, path.Dir(f.path), s.Name)
if err := os.Rename(oldpath, newpath); err != nil {