mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Unify rootfs validation
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
@@ -46,6 +46,12 @@ func (v *ConfigValidator) Validate(config *configs.Config) error {
|
|||||||
// rootfs validates if the rootfs is an absolute path and is not a symlink
|
// rootfs validates if the rootfs is an absolute path and is not a symlink
|
||||||
// to the container's root filesystem.
|
// to the container's root filesystem.
|
||||||
func (v *ConfigValidator) rootfs(config *configs.Config) error {
|
func (v *ConfigValidator) rootfs(config *configs.Config) error {
|
||||||
|
if _, err := os.Stat(config.Rootfs); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("rootfs (%s) does not exist", config.Rootfs)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
cleaned, err := filepath.Abs(config.Rootfs)
|
cleaned, err := filepath.Abs(config.Rootfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -179,13 +179,6 @@ func createContainer(context *cli.Context, id string, spec *specs.Spec) (libcont
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(config.Rootfs); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return nil, fmt.Errorf("rootfs (%q) does not exist", config.Rootfs)
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
factory, err := loadFactory(context)
|
factory, err := loadFactory(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user