plumb through Fd in setattr (#67)
this allows us to distinguish between truncate vs ftruncategeesefs-0-30-9
parent
e7bcad2083
commit
4898d79241
|
@ -93,6 +93,11 @@ func convertInMessage(
|
||||||
to.Mtime = &t
|
to.Mtime = &t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if valid.Handle() {
|
||||||
|
t := fuseops.HandleID(in.Fh)
|
||||||
|
to.Handle = &t
|
||||||
|
}
|
||||||
|
|
||||||
case fusekernel.OpForget:
|
case fusekernel.OpForget:
|
||||||
type input fusekernel.ForgetIn
|
type input fusekernel.ForgetIn
|
||||||
in := (*input)(inMsg.Consume(unsafe.Sizeof(input{})))
|
in := (*input)(inMsg.Consume(unsafe.Sizeof(input{})))
|
||||||
|
|
|
@ -145,6 +145,9 @@ type SetInodeAttributesOp struct {
|
||||||
// The inode of interest.
|
// The inode of interest.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
|
||||||
|
// If set, this is ftruncate(2), otherwise it's truncate(2)
|
||||||
|
Handle *HandleID
|
||||||
|
|
||||||
// The attributes to modify, or nil for attributes that don't need a change.
|
// The attributes to modify, or nil for attributes that don't need a change.
|
||||||
Size *uint64
|
Size *uint64
|
||||||
Mode *os.FileMode
|
Mode *os.FileMode
|
||||||
|
|
|
@ -247,6 +247,12 @@ func (fs *memFS) SetInodeAttributes(
|
||||||
fs.mu.Lock()
|
fs.mu.Lock()
|
||||||
defer fs.mu.Unlock()
|
defer fs.mu.Unlock()
|
||||||
|
|
||||||
|
if op.Size != nil && op.Handle == nil && *op.Size != 0 {
|
||||||
|
// require that truncate to non-zero has to be ftruncate()
|
||||||
|
// but allow open(O_TRUNC)
|
||||||
|
err = syscall.EBADF
|
||||||
|
}
|
||||||
|
|
||||||
// Grab the inode.
|
// Grab the inode.
|
||||||
inode := fs.getInodeOrDie(op.Inode)
|
inode := fs.getInodeOrDie(op.Inode)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue