Commit cb99d1d8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: init flag names using flagNameEntry

This will allow duplicate keys in the initialization.

Change-Id: I16969bddd1aad0232477379229a0afbe8faf1933
parent fc0fdbf6
...@@ -12,75 +12,75 @@ import ( ...@@ -12,75 +12,75 @@ import (
) )
var ( var (
writeFlagNames = newFlagNames(map[int64]string{ writeFlagNames = newFlagNames([]flagNameEntry{
WRITE_CACHE: "CACHE", {WRITE_CACHE, "CACHE"},
WRITE_LOCKOWNER: "LOCKOWNER", {WRITE_LOCKOWNER, "LOCKOWNER"},
}) })
readFlagNames = newFlagNames(map[int64]string{ readFlagNames = newFlagNames([]flagNameEntry{
READ_LOCKOWNER: "LOCKOWNER", {READ_LOCKOWNER, "LOCKOWNER"},
}) })
initFlagNames = newFlagNames(map[int64]string{ initFlagNames = newFlagNames([]flagNameEntry{
CAP_ASYNC_READ: "ASYNC_READ", {CAP_ASYNC_READ, "ASYNC_READ"},
CAP_POSIX_LOCKS: "POSIX_LOCKS", {CAP_POSIX_LOCKS, "POSIX_LOCKS"},
CAP_FILE_OPS: "FILE_OPS", {CAP_FILE_OPS, "FILE_OPS"},
CAP_ATOMIC_O_TRUNC: "ATOMIC_O_TRUNC", {CAP_ATOMIC_O_TRUNC, "ATOMIC_O_TRUNC"},
CAP_EXPORT_SUPPORT: "EXPORT_SUPPORT", {CAP_EXPORT_SUPPORT, "EXPORT_SUPPORT"},
CAP_BIG_WRITES: "BIG_WRITES", {CAP_BIG_WRITES, "BIG_WRITES"},
CAP_DONT_MASK: "DONT_MASK", {CAP_DONT_MASK, "DONT_MASK"},
CAP_SPLICE_WRITE: "SPLICE_WRITE", {CAP_SPLICE_WRITE, "SPLICE_WRITE"},
CAP_SPLICE_MOVE: "SPLICE_MOVE", {CAP_SPLICE_MOVE, "SPLICE_MOVE"},
CAP_SPLICE_READ: "SPLICE_READ", {CAP_SPLICE_READ, "SPLICE_READ"},
CAP_FLOCK_LOCKS: "FLOCK_LOCKS", {CAP_FLOCK_LOCKS, "FLOCK_LOCKS"},
CAP_IOCTL_DIR: "IOCTL_DIR", {CAP_IOCTL_DIR, "IOCTL_DIR"},
CAP_AUTO_INVAL_DATA: "AUTO_INVAL_DATA", {CAP_AUTO_INVAL_DATA, "AUTO_INVAL_DATA"},
CAP_READDIRPLUS: "READDIRPLUS", {CAP_READDIRPLUS, "READDIRPLUS"},
CAP_READDIRPLUS_AUTO: "READDIRPLUS_AUTO", {CAP_READDIRPLUS_AUTO, "READDIRPLUS_AUTO"},
CAP_ASYNC_DIO: "ASYNC_DIO", {CAP_ASYNC_DIO, "ASYNC_DIO"},
CAP_WRITEBACK_CACHE: "WRITEBACK_CACHE", {CAP_WRITEBACK_CACHE, "WRITEBACK_CACHE"},
CAP_NO_OPEN_SUPPORT: "NO_OPEN_SUPPORT", {CAP_NO_OPEN_SUPPORT, "NO_OPEN_SUPPORT"},
CAP_PARALLEL_DIROPS: "PARALLEL_DIROPS", {CAP_PARALLEL_DIROPS, "PARALLEL_DIROPS"},
CAP_POSIX_ACL: "POSIX_ACL", {CAP_POSIX_ACL, "POSIX_ACL"},
CAP_HANDLE_KILLPRIV: "HANDLE_KILLPRIV", {CAP_HANDLE_KILLPRIV, "HANDLE_KILLPRIV"},
CAP_ABORT_ERROR: "ABORT_ERROR", {CAP_ABORT_ERROR, "ABORT_ERROR"},
CAP_MAX_PAGES: "MAX_PAGES", {CAP_MAX_PAGES, "MAX_PAGES"},
CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS", {CAP_CACHE_SYMLINKS, "CACHE_SYMLINKS"},
CAP_SECURITY_CTX: "SECURITY_CTX", {CAP_SECURITY_CTX, "SECURITY_CTX"},
CAP_HAS_INODE_DAX: "HAS_INODE_DAX", {CAP_HAS_INODE_DAX, "HAS_INODE_DAX"},
CAP_CREATE_SUPP_GROUP: "CREATE_SUPP_GROUP", {CAP_CREATE_SUPP_GROUP, "CREATE_SUPP_GROUP"},
CAP_HAS_EXPIRE_ONLY: "HAS_EXPIRE_ONLY", {CAP_HAS_EXPIRE_ONLY, "HAS_EXPIRE_ONLY"},
CAP_DIRECT_IO_RELAX: "DIRECT_IO_RELAX", {CAP_DIRECT_IO_RELAX, "DIRECT_IO_RELAX"},
}) })
releaseFlagNames = newFlagNames(map[int64]string{ releaseFlagNames = newFlagNames([]flagNameEntry{
RELEASE_FLUSH: "FLUSH", {RELEASE_FLUSH, "FLUSH"},
}) })
openFlagNames = newFlagNames(map[int64]string{ openFlagNames = newFlagNames([]flagNameEntry{
int64(os.O_WRONLY): "WRONLY", {int64(os.O_WRONLY), "WRONLY"},
int64(os.O_RDWR): "RDWR", {int64(os.O_RDWR), "RDWR"},
int64(os.O_APPEND): "APPEND", {int64(os.O_APPEND), "APPEND"},
int64(syscall.O_ASYNC): "ASYNC", {int64(syscall.O_ASYNC), "ASYNC"},
int64(os.O_CREATE): "CREAT", {int64(os.O_CREATE), "CREAT"},
int64(os.O_EXCL): "EXCL", {int64(os.O_EXCL), "EXCL"},
int64(syscall.O_NOCTTY): "NOCTTY", {int64(syscall.O_NOCTTY), "NOCTTY"},
int64(syscall.O_NONBLOCK): "NONBLOCK", {int64(syscall.O_NONBLOCK), "NONBLOCK"},
int64(os.O_SYNC): "SYNC", {int64(os.O_SYNC), "SYNC"},
int64(os.O_TRUNC): "TRUNC", {int64(os.O_TRUNC), "TRUNC"},
int64(syscall.O_CLOEXEC): "CLOEXEC", {int64(syscall.O_CLOEXEC), "CLOEXEC"},
int64(syscall.O_DIRECTORY): "DIRECTORY", {int64(syscall.O_DIRECTORY), "DIRECTORY"},
}) })
fuseOpenFlagNames = newFlagNames(map[int64]string{ fuseOpenFlagNames = newFlagNames([]flagNameEntry{
FOPEN_DIRECT_IO: "DIRECT", {FOPEN_DIRECT_IO, "DIRECT"},
FOPEN_KEEP_CACHE: "CACHE", {FOPEN_KEEP_CACHE, "CACHE"},
FOPEN_NONSEEKABLE: "NONSEEK", {FOPEN_NONSEEKABLE, "NONSEEK"},
FOPEN_CACHE_DIR: "CACHE_DIR", {FOPEN_CACHE_DIR, "CACHE_DIR"},
FOPEN_STREAM: "STREAM", {FOPEN_STREAM, "STREAM"},
}) })
accessFlagName = newFlagNames(map[int64]string{ accessFlagName = newFlagNames([]flagNameEntry{
X_OK: "x", {X_OK, "x"},
W_OK: "w", {W_OK, "w"},
R_OK: "r", {R_OK, "r"},
}) })
getAttrFlagNames = newFlagNames(map[int64]string{ getAttrFlagNames = newFlagNames([]flagNameEntry{
FUSE_GETATTR_FH: "FH", {FUSE_GETATTR_FH, "FH"},
}) })
) )
...@@ -98,10 +98,10 @@ type flagNameEntry struct { ...@@ -98,10 +98,10 @@ type flagNameEntry struct {
} }
// newFlagNames creates flagNames from flag->name map. // newFlagNames creates flagNames from flag->name map.
func newFlagNames(names map[int64]string) *flagNames { func newFlagNames(names []flagNameEntry) *flagNames {
var v flagNames var v flagNames
for flag, name := range names { for _, e := range names {
v.set(flag, name) v.set(e.bits, e.name)
} }
return &v return &v
} }
......
...@@ -23,10 +23,10 @@ func TestFlagStringOrder(t *testing.T) { ...@@ -23,10 +23,10 @@ func TestFlagStringOrder(t *testing.T) {
// verify how flagString handles provided default. // verify how flagString handles provided default.
func TestFlagStringDefault(t *testing.T) { func TestFlagStringDefault(t *testing.T) {
names := newFlagNames(map[int64]string{ names := newFlagNames([]flagNameEntry{
1: "AAA", {1, "AAA"},
2: "BBB", {2, "BBB"},
4: "CCC", {4, "CCC"},
}) })
testv := []struct { testv := []struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment