Skip to content

Commit 4c7b8d6

Browse files
Merge pull request #1159 from hqhq/unify_rootfs_validation
Unify rootfs validation
2 parents 843bab9 + 81d6088 commit 4c7b8d6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

libcontainer/configs/validate/validator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func (v *ConfigValidator) Validate(config *configs.Config) error {
4646
// rootfs validates if the rootfs is an absolute path and is not a symlink
4747
// to the container's root filesystem.
4848
func (v *ConfigValidator) rootfs(config *configs.Config) error {
49+
if _, err := os.Stat(config.Rootfs); err != nil {
50+
if os.IsNotExist(err) {
51+
return fmt.Errorf("rootfs (%s) does not exist", config.Rootfs)
52+
}
53+
return err
54+
}
4955
cleaned, err := filepath.Abs(config.Rootfs)
5056
if err != nil {
5157
return err

utils_linux.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ func createContainer(context *cli.Context, id string, spec *specs.Spec) (libcont
179179
return nil, err
180180
}
181181

182-
if _, err := os.Stat(config.Rootfs); err != nil {
183-
if os.IsNotExist(err) {
184-
return nil, fmt.Errorf("rootfs (%q) does not exist", config.Rootfs)
185-
}
186-
return nil, err
187-
}
188-
189182
factory, err := loadFactory(context)
190183
if err != nil {
191184
return nil, err

0 commit comments

Comments
 (0)