Skip to content

Commit 508d86a

Browse files
authored
Merge pull request #123 from kolyshkin/path-error
driver/{Mknod,Mkfifo,Lchmod}: return PathError
2 parents aae7d98 + f5b895a commit 508d86a

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

driver/driver_unix.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import (
2929
)
3030

3131
func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error {
32-
return devices.Mknod(path, mode, major, minor)
32+
err := devices.Mknod(path, mode, major, minor)
33+
if err != nil {
34+
err = &os.PathError{Op: "mknod", Path: path, Err: err}
35+
}
36+
return err
3337
}
3438

3539
func (d *driver) Mkfifo(path string, mode os.FileMode) error {
@@ -38,7 +42,11 @@ func (d *driver) Mkfifo(path string, mode os.FileMode) error {
3842
}
3943
// mknod with a mode that has ModeNamedPipe set creates a fifo, not a
4044
// device.
41-
return devices.Mknod(path, mode, 0, 0)
45+
err := devices.Mknod(path, mode, 0, 0)
46+
if err != nil {
47+
err = &os.PathError{Op: "mkfifo", Path: path, Err: err}
48+
}
49+
return err
4250
}
4351

4452
// Getxattr returns all of the extended attributes for the file at path p.

driver/driver_windows.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ import (
2020
"os"
2121

2222
"github.com/containerd/continuity/sysx"
23-
"github.com/pkg/errors"
2423
)
2524

2625
func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error {
27-
return errors.Wrap(ErrNotSupported, "cannot create device node on Windows")
26+
return &os.PathError{Op: "mknod", Path: path, Err: ErrNotSupported}
2827
}
2928

3029
func (d *driver) Mkfifo(path string, mode os.FileMode) error {
31-
return errors.Wrap(ErrNotSupported, "cannot create fifo on Windows")
30+
return &os.PathError{Op: "mkfifo", Path: path, Err: ErrNotSupported}
3231
}
3332

3433
// Lchmod changes the mode of an file not following symlinks.

driver/lchmod_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ func (d *driver) Lchmod(path string, mode os.FileMode) error {
3131
return nil
3232
}
3333

34-
return unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), 0)
34+
err := unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), 0)
35+
if err != nil {
36+
err = &os.PathError{Op: "lchmod", Path: path, Err: err}
37+
}
38+
return err
3539
}

driver/lchmod_unix.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@ import (
2626

2727
// Lchmod changes the mode of a file not following symlinks.
2828
func (d *driver) Lchmod(path string, mode os.FileMode) error {
29-
return unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), unix.AT_SYMLINK_NOFOLLOW)
29+
err := unix.Fchmodat(unix.AT_FDCWD, path, uint32(mode), unix.AT_SYMLINK_NOFOLLOW)
30+
if err != nil {
31+
err = &os.PathError{Op: "lchmod", Path: path, Err: err}
32+
}
33+
return err
3034
}

0 commit comments

Comments
 (0)