vfs: factor flags into vfsflags and remove global variables

This commit is contained in:
Nick Craig-Wood 2017-10-29 11:00:56 +00:00
parent 1a8f824bad
commit e8883e9fdb
16 changed files with 144 additions and 115 deletions

View file

@ -0,0 +1,19 @@
// +build linux darwin freebsd
package vfsflags
import (
"github.com/spf13/pflag"
"golang.org/x/sys/unix"
)
// add any extra platform specific flags
func platformFlags(flags *pflag.FlagSet) {
flags.IntVarP(&Opt.Umask, "umask", "", Opt.Umask, "Override the permission bits set by the filesystem.")
Opt.Umask = unix.Umask(0) // read the umask
unix.Umask(Opt.Umask) // set it back to what it was
Opt.UID = uint32(unix.Geteuid())
Opt.GID = uint32(unix.Getegid())
flags.Uint32VarP(&Opt.UID, "uid", "", Opt.UID, "Override the uid field set by the filesystem.")
flags.Uint32VarP(&Opt.GID, "gid", "", Opt.GID, "Override the gid field set by the filesystem.")
}