mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Intermediate ram fs dirs should be writable.
We construct a ramfs tree of "scaffolding" directories for all mount points, so that a directory exists that each mount point can be mounted over. We were creating these directories without write permissions, which meant that they were not wribable even when underlayed under a writable filesystem. They should be writable. PiperOrigin-RevId: 242507789 Change-Id: I86645e35417560d862442ff5962da211dbe9b731
This commit is contained in:
committed by
Shentubot
parent
fbe7ba4661
commit
70906f1d24
@@ -28,6 +28,13 @@ import (
|
||||
// MakeDirectoryTree constructs a ramfs tree of all directories containing
|
||||
// subdirs. Each element of subdir must be a clean path, and cannot be empty or
|
||||
// "/".
|
||||
//
|
||||
// All directories in the created tree will have full (read-write-execute)
|
||||
// permissions, but note that file creation inside the directories is not
|
||||
// actually supported because ramfs.Dir.CreateOpts == nil. However, these
|
||||
// directory trees are normally "underlayed" under another filesystem (possibly
|
||||
// the root), and file creation inside these directories in the overlay will be
|
||||
// possible if the upper is writeable.
|
||||
func MakeDirectoryTree(ctx context.Context, msrc *fs.MountSource, subdirs []string) (*fs.Inode, error) {
|
||||
root := emptyDir(ctx, msrc)
|
||||
for _, subdir := range subdirs {
|
||||
@@ -58,9 +65,9 @@ func makeSubdir(ctx context.Context, msrc *fs.MountSource, root *Dir, subdir str
|
||||
}
|
||||
}
|
||||
|
||||
// emptyDir returns an empty *ramfs.Dir that is traversable but not writable.
|
||||
// emptyDir returns an empty *ramfs.Dir with all permissions granted.
|
||||
func emptyDir(ctx context.Context, msrc *fs.MountSource) *fs.Inode {
|
||||
dir := NewDir(ctx, make(map[string]*fs.Inode), fs.RootOwner, fs.FilePermsFromMode(0555))
|
||||
dir := NewDir(ctx, make(map[string]*fs.Inode), fs.RootOwner, fs.FilePermsFromMode(0777))
|
||||
return fs.NewInode(dir, msrc, fs.StableAttr{
|
||||
DeviceID: anon.PseudoDevice.DeviceID(),
|
||||
InodeID: anon.PseudoDevice.NextIno(),
|
||||
|
||||
Reference in New Issue
Block a user