Skip to content

Commit

Permalink
fuse: don't set flagname keyed by syscall.O_LARGEFILE
Browse files Browse the repository at this point in the history
On amd64, syscall.O_LARGEFILE is 0x0, making it be ignored as a
key. However, the kernel always passes 0x8000 to the FUSE server for
the OPEN call.

The previous behavior causes crashes on 386, because the flagname is
added twice.

Change-Id: Ibabcdfef4d90e4fa4d02963d45a4d4cf2cba1ea2
  • Loading branch information
hanwen committed Feb 9, 2024
1 parent cbb13ba commit e9e7c22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 12 additions & 10 deletions fuse/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ var (
RELEASE_FLUSH: "FLUSH",
})
openFlagNames = newFlagNames(map[int64]string{
int64(os.O_WRONLY): "WRONLY",
int64(os.O_RDWR): "RDWR",
int64(os.O_APPEND): "APPEND",
int64(syscall.O_ASYNC): "ASYNC",
int64(os.O_CREATE): "CREAT",
int64(os.O_EXCL): "EXCL",
int64(syscall.O_NOCTTY): "NOCTTY",
int64(syscall.O_NONBLOCK): "NONBLOCK",
int64(os.O_SYNC): "SYNC",
int64(os.O_TRUNC): "TRUNC",
int64(os.O_WRONLY): "WRONLY",
int64(os.O_RDWR): "RDWR",
int64(os.O_APPEND): "APPEND",
int64(syscall.O_ASYNC): "ASYNC",
int64(os.O_CREATE): "CREAT",
int64(os.O_EXCL): "EXCL",
int64(syscall.O_NOCTTY): "NOCTTY",
int64(syscall.O_NONBLOCK): "NONBLOCK",
int64(os.O_SYNC): "SYNC",
int64(os.O_TRUNC): "TRUNC",
// syscall.O_LARGEFILE is 0x0 on x86_64, but the
// kernel supplies 0x8000 anyway.
0x8000: "LARGEFILE",
int64(syscall.O_CLOEXEC): "CLOEXEC",
int64(syscall.O_DIRECTORY): "DIRECTORY",
Expand Down
1 change: 0 additions & 1 deletion fuse/print_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

func init() {
openFlagNames.set(syscall.O_DIRECT, "DIRECT")
openFlagNames.set(syscall.O_LARGEFILE, "LARGEFILE")
openFlagNames.set(syscall_O_NOATIME, "NOATIME")
initFlagNames.set(CAP_NO_OPENDIR_SUPPORT, "NO_OPENDIR_SUPPORT")
initFlagNames.set(CAP_EXPLICIT_INVAL_DATA, "EXPLICIT_INVAL_DATA")
Expand Down

0 comments on commit e9e7c22

Please sign in to comment.