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 (
)
var (
writeFlagNames = newFlagNames(map[int64]string{
WRITE_CACHE: "CACHE",
WRITE_LOCKOWNER: "LOCKOWNER",
writeFlagNames = newFlagNames([]flagNameEntry{
{WRITE_CACHE, "CACHE"},
{WRITE_LOCKOWNER, "LOCKOWNER"},
})
readFlagNames = newFlagNames(map[int64]string{
READ_LOCKOWNER: "LOCKOWNER",
readFlagNames = newFlagNames([]flagNameEntry{
{READ_LOCKOWNER, "LOCKOWNER"},
})
initFlagNames = newFlagNames(map[int64]string{
CAP_ASYNC_READ: "ASYNC_READ",
CAP_POSIX_LOCKS: "POSIX_LOCKS",
CAP_FILE_OPS: "FILE_OPS",
CAP_ATOMIC_O_TRUNC: "ATOMIC_O_TRUNC",
CAP_EXPORT_SUPPORT: "EXPORT_SUPPORT",
CAP_BIG_WRITES: "BIG_WRITES",
CAP_DONT_MASK: "DONT_MASK",
CAP_SPLICE_WRITE: "SPLICE_WRITE",
CAP_SPLICE_MOVE: "SPLICE_MOVE",
CAP_SPLICE_READ: "SPLICE_READ",
CAP_FLOCK_LOCKS: "FLOCK_LOCKS",
CAP_IOCTL_DIR: "IOCTL_DIR",
CAP_AUTO_INVAL_DATA: "AUTO_INVAL_DATA",
CAP_READDIRPLUS: "READDIRPLUS",
CAP_READDIRPLUS_AUTO: "READDIRPLUS_AUTO",
CAP_ASYNC_DIO: "ASYNC_DIO",
CAP_WRITEBACK_CACHE: "WRITEBACK_CACHE",
CAP_NO_OPEN_SUPPORT: "NO_OPEN_SUPPORT",
CAP_PARALLEL_DIROPS: "PARALLEL_DIROPS",
CAP_POSIX_ACL: "POSIX_ACL",
CAP_HANDLE_KILLPRIV: "HANDLE_KILLPRIV",
CAP_ABORT_ERROR: "ABORT_ERROR",
CAP_MAX_PAGES: "MAX_PAGES",
CAP_CACHE_SYMLINKS: "CACHE_SYMLINKS",
CAP_SECURITY_CTX: "SECURITY_CTX",
CAP_HAS_INODE_DAX: "HAS_INODE_DAX",
CAP_CREATE_SUPP_GROUP: "CREATE_SUPP_GROUP",
CAP_HAS_EXPIRE_ONLY: "HAS_EXPIRE_ONLY",
CAP_DIRECT_IO_RELAX: "DIRECT_IO_RELAX",
initFlagNames = newFlagNames([]flagNameEntry{
{CAP_ASYNC_READ, "ASYNC_READ"},
{CAP_POSIX_LOCKS, "POSIX_LOCKS"},
{CAP_FILE_OPS, "FILE_OPS"},
{CAP_ATOMIC_O_TRUNC, "ATOMIC_O_TRUNC"},
{CAP_EXPORT_SUPPORT, "EXPORT_SUPPORT"},
{CAP_BIG_WRITES, "BIG_WRITES"},
{CAP_DONT_MASK, "DONT_MASK"},
{CAP_SPLICE_WRITE, "SPLICE_WRITE"},
{CAP_SPLICE_MOVE, "SPLICE_MOVE"},
{CAP_SPLICE_READ, "SPLICE_READ"},
{CAP_FLOCK_LOCKS, "FLOCK_LOCKS"},
{CAP_IOCTL_DIR, "IOCTL_DIR"},
{CAP_AUTO_INVAL_DATA, "AUTO_INVAL_DATA"},
{CAP_READDIRPLUS, "READDIRPLUS"},
{CAP_READDIRPLUS_AUTO, "READDIRPLUS_AUTO"},
{CAP_ASYNC_DIO, "ASYNC_DIO"},
{CAP_WRITEBACK_CACHE, "WRITEBACK_CACHE"},
{CAP_NO_OPEN_SUPPORT, "NO_OPEN_SUPPORT"},
{CAP_PARALLEL_DIROPS, "PARALLEL_DIROPS"},
{CAP_POSIX_ACL, "POSIX_ACL"},
{CAP_HANDLE_KILLPRIV, "HANDLE_KILLPRIV"},
{CAP_ABORT_ERROR, "ABORT_ERROR"},
{CAP_MAX_PAGES, "MAX_PAGES"},
{CAP_CACHE_SYMLINKS, "CACHE_SYMLINKS"},
{CAP_SECURITY_CTX, "SECURITY_CTX"},
{CAP_HAS_INODE_DAX, "HAS_INODE_DAX"},
{CAP_CREATE_SUPP_GROUP, "CREATE_SUPP_GROUP"},
{CAP_HAS_EXPIRE_ONLY, "HAS_EXPIRE_ONLY"},
{CAP_DIRECT_IO_RELAX, "DIRECT_IO_RELAX"},
})
releaseFlagNames = newFlagNames(map[int64]string{
RELEASE_FLUSH: "FLUSH",
releaseFlagNames = newFlagNames([]flagNameEntry{
{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(syscall.O_CLOEXEC): "CLOEXEC",
int64(syscall.O_DIRECTORY): "DIRECTORY",
openFlagNames = newFlagNames([]flagNameEntry{
{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(syscall.O_CLOEXEC), "CLOEXEC"},
{int64(syscall.O_DIRECTORY), "DIRECTORY"},
})
fuseOpenFlagNames = newFlagNames(map[int64]string{
FOPEN_DIRECT_IO: "DIRECT",
FOPEN_KEEP_CACHE: "CACHE",
FOPEN_NONSEEKABLE: "NONSEEK",
FOPEN_CACHE_DIR: "CACHE_DIR",
FOPEN_STREAM: "STREAM",
fuseOpenFlagNames = newFlagNames([]flagNameEntry{
{FOPEN_DIRECT_IO, "DIRECT"},
{FOPEN_KEEP_CACHE, "CACHE"},
{FOPEN_NONSEEKABLE, "NONSEEK"},
{FOPEN_CACHE_DIR, "CACHE_DIR"},
{FOPEN_STREAM, "STREAM"},
})
accessFlagName = newFlagNames(map[int64]string{
X_OK: "x",
W_OK: "w",
R_OK: "r",
accessFlagName = newFlagNames([]flagNameEntry{
{X_OK, "x"},
{W_OK, "w"},
{R_OK, "r"},
})
getAttrFlagNames = newFlagNames(map[int64]string{
FUSE_GETATTR_FH: "FH",
getAttrFlagNames = newFlagNames([]flagNameEntry{
{FUSE_GETATTR_FH, "FH"},
})
)
......@@ -98,10 +98,10 @@ type flagNameEntry struct {
}
// newFlagNames creates flagNames from flag->name map.
func newFlagNames(names map[int64]string) *flagNames {
func newFlagNames(names []flagNameEntry) *flagNames {
var v flagNames
for flag, name := range names {
v.set(flag, name)
for _, e := range names {
v.set(e.bits, e.name)
}
return &v
}
......
......@@ -23,10 +23,10 @@ func TestFlagStringOrder(t *testing.T) {
// verify how flagString handles provided default.
func TestFlagStringDefault(t *testing.T) {
names := newFlagNames(map[int64]string{
1: "AAA",
2: "BBB",
4: "CCC",
names := newFlagNames([]flagNameEntry{
{1, "AAA"},
{2, "BBB"},
{4, "CCC"},
})
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