Skip to content

Commit c63fa7a

Browse files
E4242E4242
authored andcommitted
Able to build without error (imgfs)
1 parent 8310735 commit c63fa7a

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

runsc/boot/fs.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func mountExpFS(ctx context.Context, layerFDs []int, submounts []string) (*fs.In
273273
var currentNode *fs.Inode
274274

275275
if submounts != nil {
276-
msrc := fs.NewPseudoMountSource()
276+
msrc := fs.NewPseudoMountSource(ctx)
277277
mountTree, err := ramfs.MakeDirectoryTree(ctx, msrc, submounts)
278278
if err != nil {
279279
return nil, fmt.Errorf("creating mount tree: %v", err)
@@ -305,7 +305,7 @@ func mountExpFS(ctx context.Context, layerFDs []int, submounts []string) (*fs.In
305305

306306
// subtargets takes a set of Mounts and returns only the targets that are
307307
// children of the given root. The returned paths are relative to the root.
308-
func subtargets(root string, mnts []specs.Mount, layerFDs []int) []string {
308+
func subtargets(root string, mnts []specs.Mount) []string {
309309
var targets []string
310310
for _, mnt := range mnts {
311311
if relPath, isSubpath := fs.IsSubpath(mnt.Destination, root); isSubpath {
@@ -315,8 +315,8 @@ func subtargets(root string, mnts []specs.Mount, layerFDs []int) []string {
315315
return targets
316316
}
317317

318-
func setupContainerFS(ctx context.Context, conf *Config, mntr *containerMounter, procArgs *kernel.CreateProcessArgs) error {
319-
mns, err := mntr.setupFS(conf, procArgs)
318+
func setupContainerFS(ctx context.Context, conf *Config, mntr *containerMounter, procArgs *kernel.CreateProcessArgs, layerFDs []int) error {
319+
mns, err := mntr.setupFS(conf, procArgs, layerFDs)
320320
if err != nil {
321321
return err
322322
}
@@ -618,7 +618,7 @@ func (c *containerMounter) processHints(conf *Config) error {
618618
// setupFS is used to set up the file system for all containers. This is the
619619
// main entry point method, with most of the other being internal only. It
620620
// returns the mount namespace that is created for the container.
621-
func (c *containerMounter) setupFS(conf *Config, procArgs *kernel.CreateProcessArgs) (*fs.MountNamespace, error) {
621+
func (c *containerMounter) setupFS(conf *Config, procArgs *kernel.CreateProcessArgs, layerFDs []int) (*fs.MountNamespace, error) {
622622
log.Infof("Configuring container's file system")
623623

624624
// Create context with root credentials to mount the filesystem (the current
@@ -630,7 +630,7 @@ func (c *containerMounter) setupFS(conf *Config, procArgs *kernel.CreateProcessA
630630
rootProcArgs.MaxSymlinkTraversals = linux.MaxSymlinkTraversals
631631
rootCtx := rootProcArgs.NewContext(c.k)
632632

633-
mns, err := c.createMountNamespace(rootCtx, conf)
633+
mns, err := c.createMountNamespace(rootCtx, conf, layerFDs)
634634
if err != nil {
635635
return nil, err
636636
}
@@ -644,8 +644,8 @@ func (c *containerMounter) setupFS(conf *Config, procArgs *kernel.CreateProcessA
644644
return mns, nil
645645
}
646646

647-
func (c *containerMounter) createMountNamespace(ctx context.Context, conf *Config) (*fs.MountNamespace, error) {
648-
rootInode, err := c.createRootMount(ctx, conf)
647+
func (c *containerMounter) createMountNamespace(ctx context.Context, conf *Config, layerFDs []int) (*fs.MountNamespace, error) {
648+
rootInode, err := c.createRootMount(ctx, conf, layerFDs)
649649
if err != nil {
650650
return nil, fmt.Errorf("creating filesystem for container: %v", err)
651651
}
@@ -656,7 +656,7 @@ func (c *containerMounter) createMountNamespace(ctx context.Context, conf *Confi
656656
return mns, nil
657657
}
658658

659-
func (c *containerMounter) mountSubmounts(ctx context.Context, conf *Config, mns *fs.MountNamespace, layerFDs []int) error {
659+
func (c *containerMounter) mountSubmounts(ctx context.Context, conf *Config, mns *fs.MountNamespace) error {
660660
root := mns.Root()
661661
defer root.DecRef()
662662

@@ -667,7 +667,7 @@ func (c *containerMounter) mountSubmounts(ctx context.Context, conf *Config, mns
667667
return fmt.Errorf("mount shared mount %q to %q: %v", hint.name, m.Destination, err)
668668
}
669669
} else {
670-
_, dirent, err_submount := mountSubmount(ctx, conf, mns, root, fds, m, mounts);
670+
_, dirent, err_submount := c.mountSubmount(ctx, conf, mns, root, m);
671671
if dirent != nil {
672672
dirent.DecRef()
673673
}
@@ -740,17 +740,22 @@ func (c *containerMounter) createRootMount(ctx context.Context, conf *Config, la
740740
// First construct the filesystem from the spec.Root.
741741
mf := fs.MountSourceFlags{ReadOnly: c.root.Readonly || conf.Overlay}
742742

743-
if conf.OverlayfsStaleRead {
743+
//if conf.OverlayfsStaleRead {
744744
// We can't check for overlayfs here because sandbox is chroot'ed and gofer
745745
// can only send mount options for specs.Mounts (specs.Root is missing
746746
// Options field). So assume root is always on top of overlayfs.
747-
opts = append(opts, "overlayfs_stale_read")
748-
}
747+
// opts = append(opts, "overlayfs_stale_read")
748+
//}
749749

750-
rootInode, err := p9FS.Mount(ctx, rootDevice, mf, strings.Join(opts, ","), nil)
751-
if err != nil {
752-
return nil, fmt.Errorf("creating root mount point: %v", err)
753-
}
750+
var (
751+
rootInode *fs.Inode
752+
err error
753+
)
754+
755+
//rootInode, err := p9FS.Mount(ctx, rootDevice, mf, strings.Join(opts, ","), nil)
756+
//if err != nil {
757+
// return nil, fmt.Errorf("creating root mount point: %v", err)
758+
//}
754759

755760
// We need to overlay the root on top of a ramfs with stub directories
756761
// for submount paths. "/dev" "/sys" "/proc" and "/tmp" are always

runsc/boot/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ func (l *Loader) run() error {
558558
if err := mntr.processHints(l.conf); err != nil {
559559
return err
560560
}
561-
if err := setupContainerFS(ctx, l.conf, mntr, &l.rootProcArgs); err != nil {
561+
if err := setupContainerFS(ctx, l.conf, mntr, &l.rootProcArgs, l.layerFDs); err != nil {
562562
return err
563563
}
564564

@@ -702,7 +702,7 @@ func (l *Loader) startContainer(spec *specs.Spec, conf *Config, cid string, file
702702
l.startGoferMonitor(cid, goferFDs)
703703

704704
mntr := newContainerMounter(spec, goferFDs, l.k, l.mountHints)
705-
if err := setupContainerFS(ctx, conf, mntr, &procArgs); err != nil {
705+
if err := setupContainerFS(ctx, conf, mntr, &procArgs, l.layerFDs); err != nil {
706706
return err
707707
}
708708

runsc/sandbox/sandbox.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func (s *Sandbox) createSandboxProcess(conf *boot.Config, args *Args, startSyncF
443443
}
444444

445445
//Experiemntal Feature: use multiple layers of imgfs to replace gofer.
446-
files, err := ioutil.ReadDir(spec.Root.Path)
446+
files, err := ioutil.ReadDir(args.Spec.Root.Path)
447447
var layers []string
448448
for _, file := range files {
449449
if strings.HasSuffix(file.Name(), ".img") {
@@ -453,7 +453,7 @@ func (s *Sandbox) createSandboxProcess(conf *boot.Config, args *Args, startSyncF
453453
// Layers have their order. We assume the layer with lower ascii order is the lower layer. e.g. layer1.img > layer2.img > layer3.img
454454
sort.Strings(layers)
455455
for _, layer := range layers {
456-
layerFile, err := os.OpenFile(path.Join(spec.Root.Path, layer), os.O_RDONLY, 0644)
456+
layerFile, err := os.OpenFile(path.Join(args.Spec.Root.Path, layer), os.O_RDONLY, 0644)
457457
if err != nil {
458458
return fmt.Errorf("opening layer file: %v", err)
459459
}

0 commit comments

Comments
 (0)