@@ -31,10 +31,6 @@ import (
3131type memFS struct {
3232 fuseutil.NotImplementedFileSystem
3333
34- // The UID and GID that every inode receives.
35- uid uint32
36- gid uint32
37-
3834 /////////////////////////
3935 // Mutable state
4036 /////////////////////////
@@ -73,8 +69,6 @@ func NewMemFS(
7369 // Set up the basic struct.
7470 fs := & memFS {
7571 inodes : make ([]* inode , fuseops .RootInodeID + 1 ),
76- uid : uid ,
77- gid : gid ,
7872 }
7973
8074 // Set up the root inode.
@@ -250,7 +244,7 @@ func (fs *memFS) SetInodeAttributes(
250244 inode := fs .getInodeOrDie (op .Inode )
251245
252246 // Handle the request.
253- inode .SetAttributes (op .Size , op .Mode , op .Mtime )
247+ inode .SetAttributes (op .Size , op .Mode , op .Mtime , op . Uid , op . Gid )
254248
255249 // Fill in the response.
256250 op .Attributes = inode .attrs
@@ -283,8 +277,8 @@ func (fs *memFS) MkDir(
283277 childAttrs := fuseops.InodeAttributes {
284278 Nlink : 1 ,
285279 Mode : op .Mode ,
286- Uid : fs . uid ,
287- Gid : fs . gid ,
280+ Uid : op . Uid ,
281+ Gid : op . Gid ,
288282 }
289283
290284 // Allocate a child.
@@ -311,15 +305,17 @@ func (fs *memFS) MkNode(
311305 fs .mu .Lock ()
312306 defer fs .mu .Unlock ()
313307
314- op .Entry , err = fs .createFile (op .Parent , op .Name , op .Mode )
308+ op .Entry , err = fs .createFile (op .Parent , op .Name , op .Mode , op . Uid , op . Gid )
315309 return
316310}
317311
318312// LOCKS_REQUIRED(fs.mu)
319313func (fs * memFS ) createFile (
320314 parentID fuseops.InodeID ,
321315 name string ,
322- mode os.FileMode ) (entry fuseops.ChildInodeEntry , err error ) {
316+ mode os.FileMode ,
317+ uid uint32 ,
318+ gid uint32 ) (entry fuseops.ChildInodeEntry , err error ) {
323319 // Grab the parent, which we will update shortly.
324320 parent := fs .getInodeOrDie (parentID )
325321
@@ -340,8 +336,8 @@ func (fs *memFS) createFile(
340336 Mtime : now ,
341337 Ctime : now ,
342338 Crtime : now ,
343- Uid : fs . uid ,
344- Gid : fs . gid ,
339+ Uid : uid ,
340+ Gid : gid ,
345341 }
346342
347343 // Allocate a child.
@@ -368,7 +364,7 @@ func (fs *memFS) CreateFile(
368364 fs .mu .Lock ()
369365 defer fs .mu .Unlock ()
370366
371- op .Entry , err = fs .createFile (op .Parent , op .Name , op .Mode )
367+ op .Entry , err = fs .createFile (op .Parent , op .Name , op .Mode , op . Uid , op . Gid )
372368 return
373369}
374370
@@ -398,8 +394,8 @@ func (fs *memFS) CreateSymlink(
398394 Mtime : now ,
399395 Ctime : now ,
400396 Crtime : now ,
401- Uid : fs . uid ,
402- Gid : fs . gid ,
397+ Uid : op . Uid ,
398+ Gid : op . Gid ,
403399 }
404400
405401 // Allocate a child.
0 commit comments