vfs: factor out the VFS option initialization for re-use #3259

This commit is contained in:
Nick Craig-Wood
2022-06-16 11:11:14 +01:00
parent 6c832a72ee
commit 626a416ff8
2 changed files with 13 additions and 6 deletions

View File

@@ -62,3 +62,14 @@ var DefaultOpt = Options{
ReadAhead: 0 * fs.Mebi,
UsedIsSize: false,
}
// Init the options, making sure everything is withing range
func (opt *Options) Init() {
// Mask the permissions with the umask
opt.DirPerms &= ^os.FileMode(opt.Umask)
opt.FilePerms &= ^os.FileMode(opt.Umask)
// Make sure directories are returned as directories
opt.DirPerms |= os.ModeDir
}