Skip to content

Commit 4a84283

Browse files
prattmicshentubot
authored andcommitted
Return EPERM for mknod
This more directly matches what Linux does with unsupported nodes. PiperOrigin-RevId: 248780425 Change-Id: I17f3dd0b244f6dc4eb00e2e42344851b8367fbec
1 parent 0410578 commit 4a84283

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pkg/sentry/fs/gofer/path.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ func (i *inodeOperations) Bind(ctx context.Context, dir *fs.Inode, name string,
281281
}
282282

283283
// CreateFifo implements fs.InodeOperations.CreateFifo. Gofer nodes do not support the
284-
// creation of fifos and always returns EOPNOTSUPP.
284+
// creation of fifos and always returns EPERM.
285285
func (*inodeOperations) CreateFifo(context.Context, *fs.Inode, string, fs.FilePermissions) error {
286-
return syscall.EOPNOTSUPP
286+
return syscall.EPERM
287287
}
288288

289289
// Remove implements InodeOperations.Remove.

pkg/sentry/fs/host/inode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (*inodeOperations) CreateHardLink(context.Context, *fs.Inode, *fs.Inode, st
287287

288288
// CreateFifo implements fs.InodeOperations.CreateFifo.
289289
func (*inodeOperations) CreateFifo(context.Context, *fs.Inode, string, fs.FilePermissions) error {
290-
return syserror.EOPNOTSUPP
290+
return syserror.EPERM
291291
}
292292

293293
// Remove implements fs.InodeOperations.Remove.

runsc/fsgofer/fsgofer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,10 @@ func (l *localFile) Link(target p9.File, newName string) error {
860860
//
861861
// Not implemented.
862862
func (*localFile) Mknod(_ string, _ p9.FileMode, _ uint32, _ uint32, _ p9.UID, _ p9.GID) (p9.QID, error) {
863-
return p9.QID{}, syscall.ENOSYS
863+
// From mknod(2) man page:
864+
// "EPERM: [...] if the filesystem containing pathname does not support
865+
// the type of node requested."
866+
return p9.QID{}, syscall.EPERM
864867
}
865868

866869
// UnlinkAt implements p9.File.

0 commit comments

Comments
 (0)