Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should os.ModeCharDevice be taken into account? #139

Open
thaJeztah opened this issue Feb 19, 2019 · 2 comments
Open

Should os.ModeCharDevice be taken into account? #139

thaJeztah opened this issue Feb 19, 2019 · 2 comments

Comments

@thaJeztah
Copy link
Member

Relates to moby/moby#38758 / moby/moby#38404 (comment) / golang/go@a2a3dd0

Due to a change in Go 1.12, some file modes are no longer being returned as os. ModeDevice, but as os.ModeCharDevice. This caused pulling images to break on docker (moby/moby#38404 (comment)).

I'm not very familiar with this repository, but a quick search showed some similar uses in this package, so I suspect some of those will have to be updated accordingly.

continuity/fs/copy.go

Lines 137 to 140 in 004b464

case (fi.Mode() & os.ModeDevice) == os.ModeDevice:
if err := copyDevice(target, fi); err != nil {
return errors.Wrapf(err, "failed to create device")
}

continuity/resource.go

Lines 552 to 553 in c2ac4ec

case base.Mode()&os.ModeDevice != 0:
return newDevice(*base, b.Path, b.Major, b.Minor)

continuity/resource.go

Lines 434 to 437 in c2ac4ec

func newDevice(base resource, paths []string, major, minor uint64) (Device, error) {
if base.Mode()&os.ModeDevice == 0 {
return nil, fmt.Errorf("not a device")
}

continuity/context.go

Lines 501 to 502 in c2ac4ec

} else if (fi.Mode() & os.ModeDevice) == 0 {
return fmt.Errorf("%q should be a device, but is not", resource.Path())

if fi.Mode()&os.ModeDevice != 0 {

if mode&os.ModeDevice != 0 {

@thaJeztah
Copy link
Member Author

ping @cpuguy83 @AkihiroSuda @tonistiigi @dmcgowan PTAL

@thaJeztah
Copy link
Member Author

Ok, so the approach here is more defensive than the variation in Moby; os.ModeCharDevice will always be set in combination with os.ModeDevice.

The code in this repository checks if os.ModeDevice (irregardless of it being a os.ModeCharDevice or not), whereas the Moby code checks for an exact match, expecting only os.ModeDevice to be set, therefore causing it to break with Go 1.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant