本文整理汇总了Golang中github.com/subgraph/oz/fs.Filesystem类的典型用法代码示例。如果您正苦于以下问题:Golang Filesystem类的具体用法?Golang Filesystem怎么用?Golang Filesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filesystem类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: bindWhitelist
func (st *initState) bindWhitelist(fsys *fs.Filesystem, wlist []oz.WhitelistItem) error {
if wlist == nil {
return nil
}
for _, wl := range wlist {
flags := 0
if wl.CanCreate {
flags |= fs.BindCanCreate
}
if wl.Ignore {
flags |= fs.BindIgnore
}
if wl.ReadOnly {
flags |= fs.BindReadOnly
}
if wl.Force {
flags |= fs.BindForce
}
if wl.NoFollow {
flags |= fs.BindNoFollow
}
if wl.Path == "" {
continue
}
if err := fsys.BindTo(wl.Path, wl.Target, flags, st.display, st.user); err != nil {
return err
}
}
return nil
}
开发者ID:tdr130,项目名称:oz,代码行数:30,代码来源:init.go
示例2: mount
func mount(fpath string, fsys *fs.Filesystem, log *logging.Logger) {
if _, err := os.Stat(fpath); err == nil {
//log.Notice("Adding file `%s`.", fpath)
if err := fsys.BindPath(fpath, fs.BindCanCreate, nil); err != nil {
log.Error("%v while adding `%s`!", err, fpath)
os.Exit(1)
}
}
}
开发者ID:drptbl,项目名称:oz,代码行数:9,代码来源:mount.go
示例3: applyBlacklist
func (st *initState) applyBlacklist(fsys *fs.Filesystem, blist []oz.BlacklistItem) error {
if blist == nil {
return nil
}
for _, bl := range blist {
if err := fsys.BlacklistPath(bl.Path, st.user); err != nil {
return err
}
}
return nil
}
开发者ID:drptbl,项目名称:oz,代码行数:11,代码来源:init.go
示例4: unmount
func unmount(fpath string, fsys *fs.Filesystem, log *logging.Logger) {
sbpath := path.Join(fsys.Root(), fpath)
if _, err := os.Stat(sbpath); err == nil {
//log.Notice("Removing file `%s`.", fpath)
if err := fsys.UnbindPath(fpath); err != nil {
log.Error("%v", err)
os.Exit(1)
}
} else {
log.Warning("%v", err)
}
}
开发者ID:tdr130,项目名称:oz,代码行数:12,代码来源:mount.go
示例5: bindWhitelist
func (st *initState) bindWhitelist(fsys *fs.Filesystem, wlist []oz.WhitelistItem) error {
if wlist == nil {
return nil
}
for _, wl := range wlist {
flags := fs.BindCanCreate
if wl.ReadOnly {
flags |= fs.BindReadOnly
}
if err := fsys.BindPath(wl.Path, flags, st.user); err != nil {
return err
}
}
return nil
}
开发者ID:drptbl,项目名称:oz,代码行数:15,代码来源:init.go
示例6: mount
func mount(fpath string, readonly bool, fsys *fs.Filesystem, log *logging.Logger) {
//log.Notice("Adding file `%s`.", fpath)
// TODO: Check if target is empty directory (and not a mountpoint) and allow the bind in that case
if _, err := os.Stat(fpath); err != nil {
log.Error("%v", err)
os.Exit(1)
}
flags := 0 //fs.BindCanCreate
if readonly {
flags |= fs.BindReadOnly
}
if err := fsys.BindPath(fpath, flags, -1, nil); err != nil {
log.Error("%v", err)
os.Exit(1)
}
}
开发者ID:tdr130,项目名称:oz,代码行数:16,代码来源:mount.go
示例7: setupRootfs
func setupRootfs(fsys *fs.Filesystem, uid, gid uint32, useFullDev bool) error {
if err := os.MkdirAll(fsys.Root(), 0755); err != nil {
return fmt.Errorf("could not create rootfs path '%s': %v", fsys.Root(), err)
}
if err := syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, ""); err != nil {
return fmt.Errorf("failed to set MS_PRIVATE on '%s': %v", "/", err)
}
flags := uintptr(syscall.MS_NOSUID | syscall.MS_NOEXEC | syscall.MS_NODEV)
if err := syscall.Mount("", fsys.Root(), "tmpfs", flags, "mode=755,gid=0"); err != nil {
return fmt.Errorf("failed to mount tmpfs on '%s': %v", fsys.Root(), err)
}
if err := syscall.Mount("", fsys.Root(), "", syscall.MS_PRIVATE, ""); err != nil {
return fmt.Errorf("failed to set MS_PRIVATE on '%s': %v", fsys.Root(), err)
}
for _, p := range basicBindDirs {
if err := fsys.BindPath(p, fs.BindReadOnly, nil); err != nil {
return fmt.Errorf("failed to bind directory '%s': %v", p, err)
}
}
for _, p := range basicEmptyDirs {
if err := fsys.CreateEmptyDir(p); err != nil {
return fmt.Errorf("failed to create empty directory '%s': %v", p, err)
}
}
rup := path.Join(fsys.Root(), "/run/user", strconv.FormatUint(uint64(uid), 10))
if err := os.MkdirAll(rup, 0700); err != nil {
return fmt.Errorf("failed to create user rundir: %v", err)
}
if err := os.Chown(rup, int(uid), int(gid)); err != nil {
return fmt.Errorf("failed to chiwn user rundir: %v", err)
}
dp := path.Join(fsys.Root(), "dev")
if err := syscall.Mount("", dp, "tmpfs", syscall.MS_NOSUID|syscall.MS_NOEXEC, "mode=755"); err != nil {
return err
}
if !useFullDev {
for _, d := range basicDevices {
if err := fsys.CreateDevice(d.path, d.dev, d.mode, d.gid); err != nil {
return err
}
}
}
tp := path.Join(fsys.Root(), "/tmp")
tflags := uintptr(syscall.MS_NODEV | syscall.MS_NOSUID | syscall.MS_NOEXEC | syscall.MS_REC)
if err := syscall.Mount("", tp, "tmpfs", tflags, "mode=777"); err != nil {
return err
}
for _, sl := range append(basicSymlinks, deviceSymlinks...) {
if err := fsys.CreateSymlink(sl[0], sl[1]); err != nil {
return err
}
}
if err := fsys.CreateBlacklistPaths(); err != nil {
return err
}
for _, bl := range basicBlacklist {
if err := fsys.BlacklistPath(bl, nil); err != nil {
return err
}
}
return nil
}
开发者ID:Safe3,项目名称:oz,代码行数:74,代码来源:rootfs.go
示例8: setupRootfs
func setupRootfs(fsys *fs.Filesystem) error {
if err := os.MkdirAll(fsys.Root(), 0755); err != nil {
return fmt.Errorf("could not create rootfs path '%s': %v", fsys.Root(), err)
}
if err := syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, ""); err != nil {
return fmt.Errorf("failed to set MS_PRIVATE on '%s': %v", "/", err)
}
flags := uintptr(syscall.MS_NOSUID | syscall.MS_NOEXEC | syscall.MS_NODEV)
if err := syscall.Mount("", fsys.Root(), "tmpfs", flags, "mode=755,gid=0"); err != nil {
return fmt.Errorf("failed to mount tmpfs on '%s': %v", fsys.Root(), err)
}
if err := syscall.Mount("", fsys.Root(), "", syscall.MS_PRIVATE, ""); err != nil {
return fmt.Errorf("failed to set MS_PRIVATE on '%s': %v", fsys.Root(), err)
}
for _, p := range basicBindDirs {
if err := fsys.BindPath(p, fs.BindReadOnly, nil); err != nil {
return fmt.Errorf("failed to bind directory '%s': %v", p, err)
}
}
for _, p := range basicEmptyDirs {
if err := fsys.CreateEmptyDir(p); err != nil {
return fmt.Errorf("failed to create empty directory '%s': %v", p, err)
}
}
dp := path.Join(fsys.Root(), "dev")
if err := syscall.Mount("", dp, "tmpfs", syscall.MS_NOSUID|syscall.MS_NOEXEC, "mode=755"); err != nil {
return err
}
for _, d := range basicDevices {
if err := fsys.CreateDevice(d.path, d.dev, d.mode); err != nil {
return err
}
}
for _, sl := range append(basicSymlinks, deviceSymlinks...) {
if err := fsys.CreateSymlink(sl[0], sl[1]); err != nil {
return err
}
}
if err := fsys.CreateBlacklistPaths(); err != nil {
return err
}
for _, bl := range basicBlacklist {
if err := fsys.BlacklistPath(bl, nil); err != nil {
return err
}
}
return nil
}
开发者ID:drptbl,项目名称:oz,代码行数:58,代码来源:rootfs.go
注:本文中的github.com/subgraph/oz/fs.Filesystem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论