Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion runsc/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,29 @@ func (c *Container) createGoferProcess(conf *config.Config, mountHints *boot.Pod
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("opening rootfs image %q: %v", rootfsHint.Mount.Source, err)
}
return []*os.File{ioFile}, nil, nil, nil, nil
ioFiles := []*os.File{ioFile}
cu := cleanup.Make(func() {
for _, f := range ioFiles {
_ = f.Close()
}
})
defer cu.Clean()
cfgIdx := 1
for _, m := range c.Spec.Mounts {
if !specutils.HasMountConfig(m) {
continue
}
if c.GoferMountConfs[cfgIdx].ShouldUseErofs() {
f, err := os.Open(m.Source)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("opening EROFS image %q: %v", m.Source, err)
}
ioFiles = append(ioFiles, f)
}
cfgIdx++
}
cu.Release()
return ioFiles, nil, nil, nil, nil
}

// Ensure we don't leak FDs to the gofer process.
Expand Down
13 changes: 12 additions & 1 deletion runsc/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4460,7 +4460,7 @@ func createRootfsEROFS(dir string) (string, string, error) {
// Handcraft the following mount points that the sentry mounts need, because EROFS
// does not support creating synthetic directories yet and we may not want to use
// overlay in some tests.
for _, dir := range []string{"dev", "proc", "sys", "tmp"} {
for _, dir := range []string{"data", "dev", "proc", "sys", "tmp"} {
if err := os.Mkdir(filepath.Join(rootfsDir, dir), 0755); err != nil {
return "", "", fmt.Errorf("os.Mkdir() failed: %v", err)
}
Expand Down Expand Up @@ -4523,6 +4523,17 @@ func TestRootfsEROFS(t *testing.T) {
Source: mountDir,
},
},

// Case 3: EROFS rootfs with an EROFS backed config mount. This stays
// in goferless mode and requires donating both EROFS image FDs.
{
{
Type: erofs.Name,
Destination: "/data",
Source: rootfsImage,
Options: []string{"ro"},
},
},
} {
spec.Mounts = mounts

Expand Down