@@ -604,7 +604,7 @@ func (v *Validator) CheckLinux() (errs error) {
604
604
tmpItem := nsTypeList [ns .Type ]
605
605
tmpItem .num = tmpItem .num + 1
606
606
if tmpItem .num > 1 {
607
- errs = multierror .Append (errs , fmt .Errorf ("duplicated namespace %q" , ns .Type ))
607
+ errs = multierror .Append (errs , specerror . NewError ( specerror . NSErrorOnDup , fmt .Errorf ("duplicated namespace %q" , ns .Type ), rspec . Version ))
608
608
}
609
609
610
610
if len (ns .Path ) == 0 {
@@ -663,7 +663,8 @@ func (v *Validator) CheckLinux() (errs error) {
663
663
} else {
664
664
fStat , ok := fi .Sys ().(* syscall.Stat_t )
665
665
if ! ok {
666
- errs = multierror .Append (errs , fmt .Errorf ("cannot determine state for device %s" , device .Path ))
666
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesAvailable ,
667
+ fmt .Errorf ("cannot determine state for device %s" , device .Path ), rspec .Version ))
667
668
continue
668
669
}
669
670
var devType string
@@ -678,35 +679,40 @@ func (v *Validator) CheckLinux() (errs error) {
678
679
devType = "unmatched"
679
680
}
680
681
if devType != device .Type || (devType == "c" && device .Type == "u" ) {
681
- errs = multierror .Append (errs , fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ))
682
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesFileNotMatch ,
683
+ fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ), rspec .Version ))
682
684
continue
683
685
}
684
686
if devType != "p" {
685
687
dev := fStat .Rdev
686
688
major := (dev >> 8 ) & 0xfff
687
689
minor := (dev & 0xff ) | ((dev >> 12 ) & 0xfff00 )
688
690
if int64 (major ) != device .Major || int64 (minor ) != device .Minor {
689
- errs = multierror .Append (errs , fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ))
691
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesFileNotMatch ,
692
+ fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ), rspec .Version ))
690
693
continue
691
694
}
692
695
}
693
696
if device .FileMode != nil {
694
697
expectedPerm := * device .FileMode & os .ModePerm
695
698
actualPerm := fi .Mode () & os .ModePerm
696
699
if expectedPerm != actualPerm {
697
- errs = multierror .Append (errs , fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ))
700
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesFileNotMatch ,
701
+ fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ), rspec .Version ))
698
702
continue
699
703
}
700
704
}
701
705
if device .UID != nil {
702
706
if * device .UID != fStat .Uid {
703
- errs = multierror .Append (errs , fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ))
707
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesFileNotMatch ,
708
+ fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ), rspec .Version ))
704
709
continue
705
710
}
706
711
}
707
712
if device .GID != nil {
708
713
if * device .GID != fStat .Gid {
709
- errs = multierror .Append (errs , fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ))
714
+ errs = multierror .Append (errs , specerror .NewError (specerror .DevicesFileNotMatch ,
715
+ fmt .Errorf ("unmatched %s already exists in filesystem" , device .Path ), rspec .Version ))
710
716
continue
711
717
}
712
718
}
0 commit comments