Browse Source

daemon/graphdriver: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
d2a6956afb

+ 5 - 5
daemon/graphdriver/btrfs/btrfs.go

@@ -83,7 +83,7 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
 		GID: idMap.RootPair().GID,
 		GID: idMap.RootPair().GID,
 	}
 	}
 
 
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
@@ -237,7 +237,7 @@ func subvolSnapshot(src, dest, name string) error {
 	var args C.struct_btrfs_ioctl_vol_args_v2
 	var args C.struct_btrfs_ioctl_vol_args_v2
 	args.fd = C.__s64(getDirFd(srcDir))
 	args.fd = C.__s64(getDirFd(srcDir))
 
 
-	var cs = C.CString(name)
+	cs := C.CString(name)
 	C.set_name_btrfs_ioctl_vol_args_v2(&args, cs)
 	C.set_name_btrfs_ioctl_vol_args_v2(&args, cs)
 	free(cs)
 	free(cs)
 
 
@@ -495,7 +495,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
 		GID: root.GID,
 		GID: root.GID,
 	}
 	}
 
 
-	if err := idtools.MkdirAllAndChown(subvolumes, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(subvolumes, 0o710, dirID); err != nil {
 		return err
 		return err
 	}
 	}
 	if parent == "" {
 	if parent == "" {
@@ -530,10 +530,10 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
 		if err := d.setStorageSize(path.Join(subvolumes, id), driver); err != nil {
 		if err := d.setStorageSize(path.Join(subvolumes, id), driver); err != nil {
 			return err
 			return err
 		}
 		}
-		if err := idtools.MkdirAllAndChown(quotas, 0700, idtools.CurrentIdentity()); err != nil {
+		if err := idtools.MkdirAllAndChown(quotas, 0o700, idtools.CurrentIdentity()); err != nil {
 			return err
 			return err
 		}
 		}
-		if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(driver.options.size)), 0644); err != nil {
+		if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(driver.options.size)), 0o644); err != nil {
 			return err
 			return err
 		}
 		}
 	}
 	}

+ 4 - 4
daemon/graphdriver/copy/copy_test.go

@@ -94,7 +94,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
 	for i := 0; i < 10; i++ {
 	for i := 0; i < 10; i++ {
 		dirName := filepath.Join(srcDir, fmt.Sprintf("srcdir-%d", i))
 		dirName := filepath.Join(srcDir, fmt.Sprintf("srcdir-%d", i))
 		// Owner all bits set
 		// Owner all bits set
-		assert.NilError(t, os.Mkdir(dirName, randomMode(0700)))
+		assert.NilError(t, os.Mkdir(dirName, randomMode(0o700)))
 		populateSrcDir(t, dirName, remainingDepth-1)
 		populateSrcDir(t, dirName, remainingDepth-1)
 		assert.NilError(t, system.Chtimes(dirName, aTime, mTime))
 		assert.NilError(t, system.Chtimes(dirName, aTime, mTime))
 	}
 	}
@@ -102,7 +102,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
 	for i := 0; i < 10; i++ {
 	for i := 0; i < 10; i++ {
 		fileName := filepath.Join(srcDir, fmt.Sprintf("srcfile-%d", i))
 		fileName := filepath.Join(srcDir, fmt.Sprintf("srcfile-%d", i))
 		// Owner read bit set
 		// Owner read bit set
-		assert.NilError(t, os.WriteFile(fileName, []byte{}, randomMode(0400)))
+		assert.NilError(t, os.WriteFile(fileName, []byte{}, randomMode(0o400)))
 		assert.NilError(t, system.Chtimes(fileName, aTime, mTime))
 		assert.NilError(t, system.Chtimes(fileName, aTime, mTime))
 	}
 	}
 }
 }
@@ -118,7 +118,7 @@ func doCopyTest(t *testing.T, copyWithFileRange, copyWithFileClone *bool) {
 	buf := make([]byte, 1024)
 	buf := make([]byte, 1024)
 	_, err = r.Read(buf)
 	_, err = r.Read(buf)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	assert.NilError(t, os.WriteFile(srcFilename, buf, 0777))
+	assert.NilError(t, os.WriteFile(srcFilename, buf, 0o777))
 	fileinfo, err := os.Stat(srcFilename)
 	fileinfo, err := os.Stat(srcFilename)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
@@ -143,7 +143,7 @@ func TestCopyHardlink(t *testing.T) {
 	srcFile2 := filepath.Join(srcDir, "file2")
 	srcFile2 := filepath.Join(srcDir, "file2")
 	dstFile1 := filepath.Join(dstDir, "file1")
 	dstFile1 := filepath.Join(dstDir, "file1")
 	dstFile2 := filepath.Join(dstDir, "file2")
 	dstFile2 := filepath.Join(dstDir, "file2")
-	assert.NilError(t, os.WriteFile(srcFile1, []byte{}, 0777))
+	assert.NilError(t, os.WriteFile(srcFile1, []byte{}, 0o777))
 	assert.NilError(t, os.Link(srcFile1, srcFile2))
 	assert.NilError(t, os.Link(srcFile1, srcFile2))
 
 
 	assert.Check(t, DirCopy(srcDir, dstDir, Content, false))
 	assert.Check(t, DirCopy(srcDir, dstDir, Content, false))

+ 2 - 4
daemon/graphdriver/driver.go

@@ -24,10 +24,8 @@ const (
 	FsMagicUnsupported = FsMagic(0x00000000)
 	FsMagicUnsupported = FsMagic(0x00000000)
 )
 )
 
 
-var (
-	// All registered drivers
-	drivers map[string]InitFunc
-)
+// All registered drivers
+var drivers map[string]InitFunc
 
 
 // CreateOpts contains optional arguments for Create() and CreateReadWrite()
 // CreateOpts contains optional arguments for Create() and CreateReadWrite()
 // methods.
 // methods.

+ 2 - 4
daemon/graphdriver/driver_freebsd.go

@@ -6,10 +6,8 @@ import (
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
 )
 )
 
 
-var (
-	// List of drivers that should be used in an order
-	priority = "zfs"
-)
+// List of drivers that should be used in an order
+var priority = "zfs"
 
 
 // Mounted checks if the given path is mounted as the fs type
 // Mounted checks if the given path is mounted as the fs type
 func Mounted(fsType FsMagic, mountPath string) (bool, error) {
 func Mounted(fsType FsMagic, mountPath string) (bool, error) {

+ 1 - 2
daemon/graphdriver/driver_linux.go

@@ -109,8 +109,7 @@ func NewDefaultChecker() Checker {
 	return &defaultChecker{}
 	return &defaultChecker{}
 }
 }
 
 
-type defaultChecker struct {
-}
+type defaultChecker struct{}
 
 
 func (c *defaultChecker) IsMounted(path string) bool {
 func (c *defaultChecker) IsMounted(path string) bool {
 	m, _ := mountinfo.Mounted(path)
 	m, _ := mountinfo.Mounted(path)

+ 3 - 3
daemon/graphdriver/driver_test.go

@@ -14,19 +14,19 @@ func TestIsEmptyDir(t *testing.T) {
 	defer os.RemoveAll(tmp)
 	defer os.RemoveAll(tmp)
 
 
 	d := filepath.Join(tmp, "empty-dir")
 	d := filepath.Join(tmp, "empty-dir")
-	err = os.Mkdir(d, 0755)
+	err = os.Mkdir(d, 0o755)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	empty := isEmptyDir(d)
 	empty := isEmptyDir(d)
 	assert.Check(t, empty)
 	assert.Check(t, empty)
 
 
 	d = filepath.Join(tmp, "dir-with-subdir")
 	d = filepath.Join(tmp, "dir-with-subdir")
-	err = os.MkdirAll(filepath.Join(d, "subdir"), 0755)
+	err = os.MkdirAll(filepath.Join(d, "subdir"), 0o755)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	empty = isEmptyDir(d)
 	empty = isEmptyDir(d)
 	assert.Check(t, !empty)
 	assert.Check(t, !empty)
 
 
 	d = filepath.Join(tmp, "dir-with-empty-file")
 	d = filepath.Join(tmp, "dir-with-empty-file")
-	err = os.Mkdir(d, 0755)
+	err = os.Mkdir(d, 0o755)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	f, err := os.CreateTemp(d, "file")
 	f, err := os.CreateTemp(d, "file")
 	assert.NilError(t, err)
 	assert.NilError(t, err)

+ 2 - 4
daemon/graphdriver/driver_unsupported.go

@@ -2,10 +2,8 @@
 
 
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
 
 
-var (
-	// List of drivers that should be used in an order
-	priority = "unsupported"
-)
+// List of drivers that should be used in an order
+var priority = "unsupported"
 
 
 // GetFSMagic returns the filesystem id given the path.
 // GetFSMagic returns the filesystem id given the path.
 func GetFSMagic(rootpath string) (FsMagic, error) {
 func GetFSMagic(rootpath string) (FsMagic, error) {

+ 2 - 4
daemon/graphdriver/driver_windows.go

@@ -1,9 +1,7 @@
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
 
 
-var (
-	// List of drivers that should be used in order
-	priority = "windowsfilter"
-)
+// List of drivers that should be used in order
+var priority = "windowsfilter"
 
 
 // GetFSMagic returns the filesystem id given the path.
 // GetFSMagic returns the filesystem id given the path.
 func GetFSMagic(rootpath string) (FsMagic, error) {
 func GetFSMagic(rootpath string) (FsMagic, error) {

+ 7 - 7
daemon/graphdriver/fsdiff.go

@@ -12,11 +12,9 @@ import (
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"
 )
 )
 
 
-var (
-	// ApplyUncompressedLayer defines the unpack method used by the graph
-	// driver.
-	ApplyUncompressedLayer = chrootarchive.ApplyUncompressedLayer
-)
+// ApplyUncompressedLayer defines the unpack method used by the graph
+// driver.
+var ApplyUncompressedLayer = chrootarchive.ApplyUncompressedLayer
 
 
 // NaiveDiffDriver takes a ProtoDriver and adds the
 // NaiveDiffDriver takes a ProtoDriver and adds the
 // capability of the Diffing methods on the local file system,
 // capability of the Diffing methods on the local file system,
@@ -41,8 +39,10 @@ type NaiveDiffDriver struct {
 //	ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error)
 //	ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error)
 //	DiffSize(id, parent string) (size int64, err error)
 //	DiffSize(id, parent string) (size int64, err error)
 func NewNaiveDiffDriver(driver ProtoDriver, idMap idtools.IdentityMapping) Driver {
 func NewNaiveDiffDriver(driver ProtoDriver, idMap idtools.IdentityMapping) Driver {
-	return &NaiveDiffDriver{ProtoDriver: driver,
-		IDMap: idMap}
+	return &NaiveDiffDriver{
+		ProtoDriver: driver,
+		IDMap:       idMap,
+	}
 }
 }
 
 
 // Diff produces an archive of the changes between the specified
 // Diff produces an archive of the changes between the specified

+ 13 - 17
daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go

@@ -30,10 +30,8 @@ import (
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
 )
 )
 
 
-var (
-	// untar defines the untar method
-	untar = chrootarchive.UntarUncompressed
-)
+// untar defines the untar method
+var untar = chrootarchive.UntarUncompressed
 
 
 const (
 const (
 	driverName    = "fuse-overlayfs"
 	driverName    = "fuse-overlayfs"
@@ -65,9 +63,7 @@ type Driver struct {
 	locker    *locker.Locker
 	locker    *locker.Locker
 }
 }
 
 
-var (
-	logger = log.G(context.TODO()).WithField("storage-driver", driverName)
-)
+var logger = log.G(context.TODO()).WithField("storage-driver", driverName)
 
 
 func init() {
 func init() {
 	graphdriver.Register(driverName, Init)
 	graphdriver.Register(driverName, Init)
@@ -91,10 +87,10 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
 		GID: idMap.RootPair().GID,
 		GID: idMap.RootPair().GID,
 	}
 	}
 
 
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
-	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, currentID); err != nil {
+	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0o700, currentID); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
@@ -173,10 +169,10 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 	dir := d.dir(id)
 	dir := d.dir(id)
 	root := d.idMap.RootPair()
 	root := d.idMap.RootPair()
 
 
-	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0710, root); err != nil {
+	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0o710, root); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := idtools.MkdirAndChown(dir, 0710, root); err != nil {
+	if err := idtools.MkdirAndChown(dir, 0o710, root); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -191,7 +187,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		return fmt.Errorf("--storage-opt is not supported")
 		return fmt.Errorf("--storage-opt is not supported")
 	}
 	}
 
 
-	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0755, root); err != nil {
+	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0o755, root); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -201,7 +197,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 	}
 	}
 
 
 	// Write link id to link file
 	// Write link id to link file
-	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0644); err != nil {
+	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -210,11 +206,11 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		return nil
 		return nil
 	}
 	}
 
 
-	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0710, root); err != nil {
+	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0o710, root); err != nil {
 		return err
 		return err
 	}
 	}
 
 
-	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0600); err != nil {
+	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -223,7 +219,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		return err
 		return err
 	}
 	}
 	if lower != "" {
 	if lower != "" {
-		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0666); err != nil {
+		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
 			return err
 			return err
 		}
 		}
 	}
 	}
@@ -363,7 +359,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
 	mountData := label.FormatMountLabel(opts, mountLabel)
 	mountData := label.FormatMountLabel(opts, mountLabel)
 	mountTarget := mergedDir
 	mountTarget := mergedDir
 
 
-	if err := idtools.MkdirAndChown(mergedDir, 0700, d.idMap.RootPair()); err != nil {
+	if err := idtools.MkdirAndChown(mergedDir, 0o700, d.idMap.RootPair()); err != nil {
 		return "", err
 		return "", err
 	}
 	}
 
 

+ 4 - 6
daemon/graphdriver/graphtest/graphtest_unix.go

@@ -18,9 +18,7 @@ import (
 	is "gotest.tools/v3/assert/cmp"
 	is "gotest.tools/v3/assert/cmp"
 )
 )
 
 
-var (
-	drv *Driver
-)
+var drv *Driver
 
 
 // Driver conforms to graphdriver.Driver interface and
 // Driver conforms to graphdriver.Driver interface and
 // contains information such as root and reference count of the number of clients using it.
 // contains information such as root and reference count of the number of clients using it.
@@ -35,7 +33,7 @@ func newDriver(t testing.TB, name string, options []string) *Driver {
 	root, err := os.MkdirTemp("", "docker-graphtest-")
 	root, err := os.MkdirTemp("", "docker-graphtest-")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	assert.NilError(t, os.MkdirAll(root, 0755))
+	assert.NilError(t, os.MkdirAll(root, 0o755))
 	d, err := graphdriver.GetDriver(name, nil, graphdriver.Options{DriverOptions: options, Root: root})
 	d, err := graphdriver.GetDriver(name, nil, graphdriver.Options{DriverOptions: options, Root: root})
 	if err != nil {
 	if err != nil {
 		t.Logf("graphdriver: %v\n", err)
 		t.Logf("graphdriver: %v\n", err)
@@ -95,7 +93,7 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str
 	dir, err := driver.Get("empty", "")
 	dir, err := driver.Get("empty", "")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	verifyFile(t, dir, 0755|os.ModeDir, 0, 0)
+	verifyFile(t, dir, 0o755|os.ModeDir, 0, 0)
 
 
 	// Verify that the directory is empty
 	// Verify that the directory is empty
 	fis, err := readDir(dir)
 	fis, err := readDir(dir)
@@ -296,7 +294,7 @@ func writeRandomFile(path string, size uint64) error {
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	return os.WriteFile(path, data, 0700)
+	return os.WriteFile(path, data, 0o700)
 }
 }
 
 
 // DriverTestSetQuota Create a driver and test setting quota.
 // DriverTestSetQuota Create a driver and test setting quota.

+ 15 - 15
daemon/graphdriver/graphtest/testutil.go

@@ -36,17 +36,17 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error {
 	}
 	}
 	defer drv.Put(layer)
 	defer drv.Put(layer)
 
 
-	if err := os.WriteFile(filepath.Join(root, "file-a"), randomContent(64, seed), 0755); err != nil {
+	if err := os.WriteFile(filepath.Join(root, "file-a"), randomContent(64, seed), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.MkdirAll(filepath.Join(root, "dir-b"), 0755); err != nil {
+	if err := os.MkdirAll(filepath.Join(root, "dir-b"), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.WriteFile(filepath.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil {
+	if err := os.WriteFile(filepath.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
 
 
-	return os.WriteFile(filepath.Join(root, "file-c"), randomContent(128*128, seed+2), 0755)
+	return os.WriteFile(filepath.Join(root, "file-c"), randomContent(128*128, seed+2), 0o755)
 }
 }
 
 
 func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error {
 func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error {
@@ -75,7 +75,7 @@ func addFile(drv graphdriver.Driver, layer, filename string, content []byte) err
 	}
 	}
 	defer drv.Put(layer)
 	defer drv.Put(layer)
 
 
-	return os.WriteFile(filepath.Join(root, filename), content, 0755)
+	return os.WriteFile(filepath.Join(root, filename), content, 0o755)
 }
 }
 
 
 func addDirectory(drv graphdriver.Driver, layer, dir string) error {
 func addDirectory(drv graphdriver.Driver, layer, dir string) error {
@@ -85,7 +85,7 @@ func addDirectory(drv graphdriver.Driver, layer, dir string) error {
 	}
 	}
 	defer drv.Put(layer)
 	defer drv.Put(layer)
 
 
-	return os.MkdirAll(filepath.Join(root, dir), 0755)
+	return os.MkdirAll(filepath.Join(root, dir), 0o755)
 }
 }
 
 
 func removeAll(drv graphdriver.Driver, layer string, names ...string) error {
 func removeAll(drv graphdriver.Driver, layer string, names ...string) error {
@@ -128,12 +128,12 @@ func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) e
 
 
 	for i := 0; i < count; i += 100 {
 	for i := 0; i < count; i += 100 {
 		dir := filepath.Join(root, fmt.Sprintf("directory-%d", i))
 		dir := filepath.Join(root, fmt.Sprintf("directory-%d", i))
-		if err := os.MkdirAll(dir, 0755); err != nil {
+		if err := os.MkdirAll(dir, 0o755); err != nil {
 			return err
 			return err
 		}
 		}
 		for j := 0; i+j < count && j < 100; j++ {
 		for j := 0; i+j < count && j < 100; j++ {
 			file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j))
 			file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j))
-			if err := os.WriteFile(file, randomContent(64, seed+int64(i+j)), 0755); err != nil {
+			if err := os.WriteFile(file, randomContent(64, seed+int64(i+j)), 0o755); err != nil {
 				return err
 				return err
 			}
 			}
 		}
 		}
@@ -152,7 +152,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
 	var changes []archive.Change
 	var changes []archive.Change
 	for i := 0; i < count; i += 100 {
 	for i := 0; i < count; i += 100 {
 		archiveRoot := fmt.Sprintf("/directory-%d", i)
 		archiveRoot := fmt.Sprintf("/directory-%d", i)
-		if err := os.MkdirAll(filepath.Join(root, archiveRoot), 0755); err != nil {
+		if err := os.MkdirAll(filepath.Join(root, archiveRoot), 0o755); err != nil {
 			return nil, err
 			return nil, err
 		}
 		}
 		for j := 0; i+j < count && j < 100; j++ {
 		for j := 0; i+j < count && j < 100; j++ {
@@ -168,14 +168,14 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
 			case 0:
 			case 0:
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j))
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j))
 				change.Kind = archive.ChangeModify
 				change.Kind = archive.ChangeModify
-				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
+				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0o755); err != nil {
 					return nil, err
 					return nil, err
 				}
 				}
 			// Add file
 			// Add file
 			case 1:
 			case 1:
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j))
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j))
 				change.Kind = archive.ChangeAdd
 				change.Kind = archive.ChangeAdd
-				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
+				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0o755); err != nil {
 					return nil, err
 					return nil, err
 				}
 				}
 			// Remove file
 			// Remove file
@@ -254,17 +254,17 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
 	}
 	}
 	defer drv.Put(layer)
 	defer drv.Put(layer)
 
 
-	if err := os.WriteFile(filepath.Join(root, "top-id"), []byte(layer), 0755); err != nil {
+	if err := os.WriteFile(filepath.Join(root, "top-id"), []byte(layer), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
 	layerDir := filepath.Join(root, fmt.Sprintf("layer-%d", i))
 	layerDir := filepath.Join(root, fmt.Sprintf("layer-%d", i))
-	if err := os.MkdirAll(layerDir, 0755); err != nil {
+	if err := os.MkdirAll(layerDir, 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.WriteFile(filepath.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil {
+	if err := os.WriteFile(filepath.Join(layerDir, "layer-id"), []byte(layer), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	return os.WriteFile(filepath.Join(layerDir, "parent-id"), []byte(parent), 0755)
+	return os.WriteFile(filepath.Join(layerDir, "parent-id"), []byte(parent), 0o755)
 }
 }
 
 
 func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {
 func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {

+ 4 - 4
daemon/graphdriver/graphtest/testutil_unix.go

@@ -45,11 +45,11 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) {
 	defer driver.Put(name)
 	defer driver.Put(name)
 
 
 	subdir := filepath.Join(dirFS, "a subdir")
 	subdir := filepath.Join(dirFS, "a subdir")
-	assert.NilError(t, os.Mkdir(subdir, 0705|os.ModeSticky))
+	assert.NilError(t, os.Mkdir(subdir, 0o705|os.ModeSticky))
 	assert.NilError(t, contdriver.LocalDriver.Lchown(subdir, 1, 2))
 	assert.NilError(t, contdriver.LocalDriver.Lchown(subdir, 1, 2))
 
 
 	file := filepath.Join(dirFS, "a file")
 	file := filepath.Join(dirFS, "a file")
-	err = os.WriteFile(file, []byte("Some data"), 0222|os.ModeSetuid)
+	err = os.WriteFile(file, []byte("Some data"), 0o222|os.ModeSetuid)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 }
 }
 
 
@@ -59,10 +59,10 @@ func verifyBase(t testing.TB, driver graphdriver.Driver, name string) {
 	defer driver.Put(name)
 	defer driver.Put(name)
 
 
 	subdir := filepath.Join(dirFS, "a subdir")
 	subdir := filepath.Join(dirFS, "a subdir")
-	verifyFile(t, subdir, 0705|os.ModeDir|os.ModeSticky, 1, 2)
+	verifyFile(t, subdir, 0o705|os.ModeDir|os.ModeSticky, 1, 2)
 
 
 	file := filepath.Join(dirFS, "a file")
 	file := filepath.Join(dirFS, "a file")
-	verifyFile(t, file, 0222|os.ModeSetuid, 0, 0)
+	verifyFile(t, file, 0o222|os.ModeSetuid, 0, 0)
 
 
 	files, err := readDir(dirFS)
 	files, err := readDir(dirFS)
 	assert.NilError(t, err)
 	assert.NilError(t, err)

+ 10 - 10
daemon/graphdriver/overlay2/check.go

@@ -40,22 +40,22 @@ func doesSupportNativeDiff(d string) error {
 	}()
 	}()
 
 
 	// Make directories l1/d, l1/d1, l2/d, l3, work, merged
 	// Make directories l1/d, l1/d1, l2/d, l3, work, merged
-	if err := os.MkdirAll(filepath.Join(td, "l1", "d"), 0755); err != nil {
+	if err := os.MkdirAll(filepath.Join(td, "l1", "d"), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.MkdirAll(filepath.Join(td, "l1", "d1"), 0755); err != nil {
+	if err := os.MkdirAll(filepath.Join(td, "l1", "d1"), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.MkdirAll(filepath.Join(td, "l2", "d"), 0755); err != nil {
+	if err := os.MkdirAll(filepath.Join(td, "l2", "d"), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.Mkdir(filepath.Join(td, "l3"), 0755); err != nil {
+	if err := os.Mkdir(filepath.Join(td, "l3"), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.Mkdir(filepath.Join(td, workDirName), 0755); err != nil {
+	if err := os.Mkdir(filepath.Join(td, workDirName), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.Mkdir(filepath.Join(td, mergedDirName), 0755); err != nil {
+	if err := os.Mkdir(filepath.Join(td, mergedDirName), 0o755); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -75,7 +75,7 @@ func doesSupportNativeDiff(d string) error {
 	}()
 	}()
 
 
 	// Touch file in d to force copy up of opaque directory "d" from "l2" to "l3"
 	// Touch file in d to force copy up of opaque directory "d" from "l2" to "l3"
-	if err := os.WriteFile(filepath.Join(td, mergedDirName, "d", "f"), []byte{}, 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(td, mergedDirName, "d", "f"), []byte{}, 0o644); err != nil {
 		return errors.Wrap(err, "failed to write to merged directory")
 		return errors.Wrap(err, "failed to write to merged directory")
 	}
 	}
 
 
@@ -149,13 +149,13 @@ func usingMetacopy(d string) (bool, error) {
 
 
 	l1, l2, work, merged := filepath.Join(td, "l1"), filepath.Join(td, "l2"), filepath.Join(td, "work"), filepath.Join(td, "merged")
 	l1, l2, work, merged := filepath.Join(td, "l1"), filepath.Join(td, "l2"), filepath.Join(td, "work"), filepath.Join(td, "merged")
 	for _, dir := range []string{l1, l2, work, merged} {
 	for _, dir := range []string{l1, l2, work, merged} {
-		if err := os.Mkdir(dir, 0755); err != nil {
+		if err := os.Mkdir(dir, 0o755); err != nil {
 			return false, err
 			return false, err
 		}
 		}
 	}
 	}
 
 
 	// Create empty file in l1 with 0700 permissions for metacopy test
 	// Create empty file in l1 with 0700 permissions for metacopy test
-	if err := os.WriteFile(filepath.Join(l1, "f"), []byte{}, 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(l1, "f"), []byte{}, 0o700); err != nil {
 		return false, err
 		return false, err
 	}
 	}
 
 
@@ -180,7 +180,7 @@ func usingMetacopy(d string) (bool, error) {
 	}()
 	}()
 
 
 	// Make a change that only impacts the inode, in the upperdir
 	// Make a change that only impacts the inode, in the upperdir
-	if err := os.Chmod(filepath.Join(merged, "f"), 0600); err != nil {
+	if err := os.Chmod(filepath.Join(merged, "f"), 0o600); err != nil {
 		return false, errors.Wrap(err, "error changing permissions on file for metacopy check")
 		return false, errors.Wrap(err, "error changing permissions on file for metacopy check")
 	}
 	}
 
 

+ 12 - 14
daemon/graphdriver/overlay2/overlay.go

@@ -32,10 +32,8 @@ import (
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
 )
 )
 
 
-var (
-	// untar defines the untar method
-	untar = chrootarchive.UntarUncompressed
-)
+// untar defines the untar method
+var untar = chrootarchive.UntarUncompressed
 
 
 // This backend uses the overlay union filesystem for containers
 // This backend uses the overlay union filesystem for containers
 // with diff directories for each layer.
 // with diff directories for each layer.
@@ -168,10 +166,10 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
 		UID: cur.UID,
 		UID: cur.UID,
 		GID: idMap.RootPair().GID,
 		GID: idMap.RootPair().GID,
 	}
 	}
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
-	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, cur); err != nil {
+	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0o700, cur); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
@@ -347,10 +345,10 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		GID: root.GID,
 		GID: root.GID,
 	}
 	}
 
 
-	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0o710, dirID); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := idtools.MkdirAndChown(dir, 0710, dirID); err != nil {
+	if err := idtools.MkdirAndChown(dir, 0o710, dirID); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -375,7 +373,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		}
 		}
 	}
 	}
 
 
-	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0755, root); err != nil {
+	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0o755, root); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -385,7 +383,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 	}
 	}
 
 
 	// Write link id to link file
 	// Write link id to link file
-	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0644); err != nil {
+	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -394,11 +392,11 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		return nil
 		return nil
 	}
 	}
 
 
-	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0700, root); err != nil {
+	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0o700, root); err != nil {
 		return err
 		return err
 	}
 	}
 
 
-	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0600); err != nil {
+	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -407,7 +405,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
 		return err
 		return err
 	}
 	}
 	if lower != "" {
 	if lower != "" {
-		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0666); err != nil {
+		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
 			return err
 			return err
 		}
 		}
 	}
 	}
@@ -567,7 +565,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
 	mountTarget := mergedDir
 	mountTarget := mergedDir
 
 
 	root := d.idMap.RootPair()
 	root := d.idMap.RootPair()
-	if err := idtools.MkdirAndChown(mergedDir, 0700, root); err != nil {
+	if err := idtools.MkdirAndChown(mergedDir, 0o700, root); err != nil {
 		return "", err
 		return "", err
 	}
 	}
 
 

+ 1 - 1
daemon/graphdriver/overlayutils/overlayutils.go

@@ -60,7 +60,7 @@ func SupportsOverlay(d string, checkMultipleLowers bool) error {
 	}()
 	}()
 
 
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
-		if err := os.Mkdir(filepath.Join(td, dir), 0755); err != nil {
+		if err := os.Mkdir(filepath.Join(td, dir), 0o755); err != nil {
 			return err
 			return err
 		}
 		}
 	}
 	}

+ 2 - 2
daemon/graphdriver/overlayutils/userxattr.go

@@ -71,7 +71,7 @@ func NeedsUserXAttr(d string) (bool, error) {
 		log.G(context.TODO()).WithError(err).Warnf("Failed to remove check directory %v", tdRoot)
 		log.G(context.TODO()).WithError(err).Warnf("Failed to remove check directory %v", tdRoot)
 	}
 	}
 
 
-	if err := os.MkdirAll(tdRoot, 0700); err != nil {
+	if err := os.MkdirAll(tdRoot, 0o700); err != nil {
 		return false, err
 		return false, err
 	}
 	}
 
 
@@ -87,7 +87,7 @@ func NeedsUserXAttr(d string) (bool, error) {
 	}
 	}
 
 
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
-		if err := os.Mkdir(filepath.Join(td, dir), 0755); err != nil {
+		if err := os.Mkdir(filepath.Join(td, dir), 0o755); err != nil {
 			return false, err
 			return false, err
 		}
 		}
 	}
 	}

+ 5 - 7
daemon/graphdriver/vfs/driver.go

@@ -21,10 +21,8 @@ const (
 	bestEffortXattrsOptValue = "i_want_broken_containers"
 	bestEffortXattrsOptValue = "i_want_broken_containers"
 )
 )
 
 
-var (
-	// CopyDir defines the copy method to use.
-	CopyDir = dirCopy
-)
+// CopyDir defines the copy method to use.
+var CopyDir = dirCopy
 
 
 func init() {
 func init() {
 	graphdriver.Register("vfs", Init)
 	graphdriver.Register("vfs", Init)
@@ -46,7 +44,7 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
 		UID: idtools.CurrentIdentity().UID,
 		UID: idtools.CurrentIdentity().UID,
 		GID: d.idMapping.RootPair().GID,
 		GID: d.idMapping.RootPair().GID,
 	}
 	}
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
@@ -170,10 +168,10 @@ func (d *Driver) create(id, parent string, size uint64) error {
 		UID: idtools.CurrentIdentity().UID,
 		UID: idtools.CurrentIdentity().UID,
 		GID: rootIDs.GID,
 		GID: rootIDs.GID,
 	}
 	}
-	if err := idtools.MkdirAllAndChown(filepath.Dir(dir), 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(filepath.Dir(dir), 0o710, dirID); err != nil {
 		return err
 		return err
 	}
 	}
-	if err := idtools.MkdirAndChown(dir, 0755, rootIDs); err != nil {
+	if err := idtools.MkdirAndChown(dir, 0o755, rootIDs); err != nil {
 		return err
 		return err
 	}
 	}
 
 

+ 1 - 2
daemon/graphdriver/vfs/quota_unsupported.go

@@ -4,8 +4,7 @@ package vfs // import "github.com/docker/docker/daemon/graphdriver/vfs"
 
 
 import "github.com/docker/docker/quota"
 import "github.com/docker/docker/quota"
 
 
-type driverQuota struct {
-}
+type driverQuota struct{}
 
 
 func setupDriverQuota(driver *Driver) error {
 func setupDriverQuota(driver *Driver) error {
 	return nil
 	return nil

+ 2 - 3
daemon/graphdriver/windows/windows.go

@@ -73,8 +73,7 @@ func init() {
 	}
 	}
 }
 }
 
 
-type checker struct {
-}
+type checker struct{}
 
 
 func (c *checker) IsMounted(path string) bool {
 func (c *checker) IsMounted(path string) bool {
 	return false
 	return false
@@ -846,7 +845,7 @@ func (d *Driver) resolveID(id string) (string, error) {
 
 
 // setID stores the layerId in disk.
 // setID stores the layerId in disk.
 func (d *Driver) setID(id, altID string) error {
 func (d *Driver) setID(id, altID string) error {
-	return os.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0600)
+	return os.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0o600)
 }
 }
 
 
 // getLayerChain returns the layer chain information.
 // getLayerChain returns the layer chain information.

+ 3 - 3
daemon/graphdriver/zfs/zfs.go

@@ -56,7 +56,7 @@ func Init(base string, opt []string, idMap idtools.IdentityMapping) (graphdriver
 		return nil, graphdriver.ErrPrerequisites
 		return nil, graphdriver.ErrPrerequisites
 	}
 	}
 
 
-	file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 0600)
+	file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 0o600)
 	if err != nil {
 	if err != nil {
 		logger.Debugf("cannot open /dev/zfs: %v", err)
 		logger.Debugf("cannot open /dev/zfs: %v", err)
 		return nil, graphdriver.ErrPrerequisites
 		return nil, graphdriver.ErrPrerequisites
@@ -109,7 +109,7 @@ func Init(base string, opt []string, idMap idtools.IdentityMapping) (graphdriver
 		UID: idtools.CurrentIdentity().UID,
 		UID: idtools.CurrentIdentity().UID,
 		GID: idMap.RootPair().GID,
 		GID: idMap.RootPair().GID,
 	}
 	}
-	if err := idtools.MkdirAllAndChown(base, 0710, dirID); err != nil {
+	if err := idtools.MkdirAllAndChown(base, 0o710, dirID); err != nil {
 		return nil, fmt.Errorf("Failed to create '%s': %v", base, err)
 		return nil, fmt.Errorf("Failed to create '%s': %v", base, err)
 	}
 	}
 
 
@@ -388,7 +388,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
 
 
 	root := d.idMap.RootPair()
 	root := d.idMap.RootPair()
 	// Create the target directories if they don't exist
 	// Create the target directories if they don't exist
-	if err := idtools.MkdirAllAndChown(mountpoint, 0755, root); err != nil {
+	if err := idtools.MkdirAllAndChown(mountpoint, 0o755, root); err != nil {
 		return "", err
 		return "", err
 	}
 	}
 
 

+ 1 - 1
daemon/graphdriver/zfs/zfs_freebsd.go

@@ -3,8 +3,8 @@ package zfs // import "github.com/docker/docker/daemon/graphdriver/zfs"
 import (
 import (
 	"strings"
 	"strings"
 
 
-	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/containerd/containerd/log"
 	"github.com/containerd/containerd/log"
+	"github.com/docker/docker/daemon/graphdriver"
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
 )
 )