Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion driver/driver_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"sort"

"github.com/containerd/continuity/devices"
"github.com/containerd/continuity/sysx"
"golang.org/x/sys/unix"
)

func (d *driver) Mknod(path string, mode os.FileMode, major, minor int) error {
Expand All @@ -35,7 +37,17 @@ func (d *driver) Lchmod(path string, mode os.FileMode) (err error) {
}
}

return sysx.Fchmodat(0, path, uint32(mode), sysx.AtSymlinkNofollow)
flags := unix.AT_SYMLINK_NOFOLLOW
if runtime.GOOS == "linux" {
// Chmod on symlinks is not supported on Linux, i.e. unix.Fchmodat
// returns EOPNOTSUPP if AT_SYMLINK_NOFOLLOW is specified even
// if the path isn't a symlink (also see
// https://github.com/golang/go/issues/20130).
if mode&os.ModeSymlink == 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't going to work, normally only a os.ModePerm is passed in

flags = 0
}
}
return unix.Fchmodat(0, path, uint32(mode), flags)
}

// Getxattr returns all of the extended attributes for the file at path p.
Expand Down
18 changes: 0 additions & 18 deletions sysx/chmod_darwin.go

This file was deleted.

25 changes: 0 additions & 25 deletions sysx/chmod_darwin_386.go

This file was deleted.

25 changes: 0 additions & 25 deletions sysx/chmod_darwin_amd64.go

This file was deleted.

17 changes: 0 additions & 17 deletions sysx/chmod_freebsd.go

This file was deleted.

25 changes: 0 additions & 25 deletions sysx/chmod_freebsd_amd64.go

This file was deleted.

12 changes: 0 additions & 12 deletions sysx/chmod_linux.go

This file was deleted.

11 changes: 0 additions & 11 deletions sysx/chmod_solaris.go

This file was deleted.

1 change: 0 additions & 1 deletion sysx/xattr_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package sysx
//sys setxattr(path string, attr string, data []byte, flags int) (err error)
//sys removexattr(path string, attr string, options int) (err error)
//sys listxattr(path string, dest []byte, options int) (sz int, err error)
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)

const (
xattrNoFollow = 0x01
Expand Down