Browse code

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 authored on 2022/01/20 21:59:20
Showing 22 changed files
... ...
@@ -83,7 +83,7 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
83 83
 		GID: idMap.RootPair().GID,
84 84
 	}
85 85
 
86
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
86
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
87 87
 		return nil, err
88 88
 	}
89 89
 
... ...
@@ -237,7 +237,7 @@ func subvolSnapshot(src, dest, name string) error {
237 237
 	var args C.struct_btrfs_ioctl_vol_args_v2
238 238
 	args.fd = C.__s64(getDirFd(srcDir))
239 239
 
240
-	var cs = C.CString(name)
240
+	cs := C.CString(name)
241 241
 	C.set_name_btrfs_ioctl_vol_args_v2(&args, cs)
242 242
 	free(cs)
243 243
 
... ...
@@ -495,7 +495,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
495 495
 		GID: root.GID,
496 496
 	}
497 497
 
498
-	if err := idtools.MkdirAllAndChown(subvolumes, 0710, dirID); err != nil {
498
+	if err := idtools.MkdirAllAndChown(subvolumes, 0o710, dirID); err != nil {
499 499
 		return err
500 500
 	}
501 501
 	if parent == "" {
... ...
@@ -530,10 +530,10 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
530 530
 		if err := d.setStorageSize(path.Join(subvolumes, id), driver); err != nil {
531 531
 			return err
532 532
 		}
533
-		if err := idtools.MkdirAllAndChown(quotas, 0700, idtools.CurrentIdentity()); err != nil {
533
+		if err := idtools.MkdirAllAndChown(quotas, 0o700, idtools.CurrentIdentity()); err != nil {
534 534
 			return err
535 535
 		}
536
-		if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(driver.options.size)), 0644); err != nil {
536
+		if err := os.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(driver.options.size)), 0o644); err != nil {
537 537
 			return err
538 538
 		}
539 539
 	}
... ...
@@ -94,7 +94,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
94 94
 	for i := 0; i < 10; i++ {
95 95
 		dirName := filepath.Join(srcDir, fmt.Sprintf("srcdir-%d", i))
96 96
 		// Owner all bits set
97
-		assert.NilError(t, os.Mkdir(dirName, randomMode(0700)))
97
+		assert.NilError(t, os.Mkdir(dirName, randomMode(0o700)))
98 98
 		populateSrcDir(t, dirName, remainingDepth-1)
99 99
 		assert.NilError(t, system.Chtimes(dirName, aTime, mTime))
100 100
 	}
... ...
@@ -102,7 +102,7 @@ func populateSrcDir(t *testing.T, srcDir string, remainingDepth int) {
102 102
 	for i := 0; i < 10; i++ {
103 103
 		fileName := filepath.Join(srcDir, fmt.Sprintf("srcfile-%d", i))
104 104
 		// Owner read bit set
105
-		assert.NilError(t, os.WriteFile(fileName, []byte{}, randomMode(0400)))
105
+		assert.NilError(t, os.WriteFile(fileName, []byte{}, randomMode(0o400)))
106 106
 		assert.NilError(t, system.Chtimes(fileName, aTime, mTime))
107 107
 	}
108 108
 }
... ...
@@ -118,7 +118,7 @@ func doCopyTest(t *testing.T, copyWithFileRange, copyWithFileClone *bool) {
118 118
 	buf := make([]byte, 1024)
119 119
 	_, err = r.Read(buf)
120 120
 	assert.NilError(t, err)
121
-	assert.NilError(t, os.WriteFile(srcFilename, buf, 0777))
121
+	assert.NilError(t, os.WriteFile(srcFilename, buf, 0o777))
122 122
 	fileinfo, err := os.Stat(srcFilename)
123 123
 	assert.NilError(t, err)
124 124
 
... ...
@@ -143,7 +143,7 @@ func TestCopyHardlink(t *testing.T) {
143 143
 	srcFile2 := filepath.Join(srcDir, "file2")
144 144
 	dstFile1 := filepath.Join(dstDir, "file1")
145 145
 	dstFile2 := filepath.Join(dstDir, "file2")
146
-	assert.NilError(t, os.WriteFile(srcFile1, []byte{}, 0777))
146
+	assert.NilError(t, os.WriteFile(srcFile1, []byte{}, 0o777))
147 147
 	assert.NilError(t, os.Link(srcFile1, srcFile2))
148 148
 
149 149
 	assert.Check(t, DirCopy(srcDir, dstDir, Content, false))
... ...
@@ -24,10 +24,8 @@ const (
24 24
 	FsMagicUnsupported = FsMagic(0x00000000)
25 25
 )
26 26
 
27
-var (
28
-	// All registered drivers
29
-	drivers map[string]InitFunc
30
-)
27
+// All registered drivers
28
+var drivers map[string]InitFunc
31 29
 
32 30
 // CreateOpts contains optional arguments for Create() and CreateReadWrite()
33 31
 // methods.
... ...
@@ -6,10 +6,8 @@ import (
6 6
 	"golang.org/x/sys/unix"
7 7
 )
8 8
 
9
-var (
10
-	// List of drivers that should be used in an order
11
-	priority = "zfs"
12
-)
9
+// List of drivers that should be used in an order
10
+var priority = "zfs"
13 11
 
14 12
 // Mounted checks if the given path is mounted as the fs type
15 13
 func Mounted(fsType FsMagic, mountPath string) (bool, error) {
... ...
@@ -109,8 +109,7 @@ func NewDefaultChecker() Checker {
109 109
 	return &defaultChecker{}
110 110
 }
111 111
 
112
-type defaultChecker struct {
113
-}
112
+type defaultChecker struct{}
114 113
 
115 114
 func (c *defaultChecker) IsMounted(path string) bool {
116 115
 	m, _ := mountinfo.Mounted(path)
... ...
@@ -14,19 +14,19 @@ func TestIsEmptyDir(t *testing.T) {
14 14
 	defer os.RemoveAll(tmp)
15 15
 
16 16
 	d := filepath.Join(tmp, "empty-dir")
17
-	err = os.Mkdir(d, 0755)
17
+	err = os.Mkdir(d, 0o755)
18 18
 	assert.NilError(t, err)
19 19
 	empty := isEmptyDir(d)
20 20
 	assert.Check(t, empty)
21 21
 
22 22
 	d = filepath.Join(tmp, "dir-with-subdir")
23
-	err = os.MkdirAll(filepath.Join(d, "subdir"), 0755)
23
+	err = os.MkdirAll(filepath.Join(d, "subdir"), 0o755)
24 24
 	assert.NilError(t, err)
25 25
 	empty = isEmptyDir(d)
26 26
 	assert.Check(t, !empty)
27 27
 
28 28
 	d = filepath.Join(tmp, "dir-with-empty-file")
29
-	err = os.Mkdir(d, 0755)
29
+	err = os.Mkdir(d, 0o755)
30 30
 	assert.NilError(t, err)
31 31
 	f, err := os.CreateTemp(d, "file")
32 32
 	assert.NilError(t, err)
... ...
@@ -2,10 +2,8 @@
2 2
 
3 3
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
4 4
 
5
-var (
6
-	// List of drivers that should be used in an order
7
-	priority = "unsupported"
8
-)
5
+// List of drivers that should be used in an order
6
+var priority = "unsupported"
9 7
 
10 8
 // GetFSMagic returns the filesystem id given the path.
11 9
 func GetFSMagic(rootpath string) (FsMagic, error) {
... ...
@@ -1,9 +1,7 @@
1 1
 package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
2 2
 
3
-var (
4
-	// List of drivers that should be used in order
5
-	priority = "windowsfilter"
6
-)
3
+// List of drivers that should be used in order
4
+var priority = "windowsfilter"
7 5
 
8 6
 // GetFSMagic returns the filesystem id given the path.
9 7
 func GetFSMagic(rootpath string) (FsMagic, error) {
... ...
@@ -12,11 +12,9 @@ import (
12 12
 	"github.com/docker/docker/pkg/ioutils"
13 13
 )
14 14
 
15
-var (
16
-	// ApplyUncompressedLayer defines the unpack method used by the graph
17
-	// driver.
18
-	ApplyUncompressedLayer = chrootarchive.ApplyUncompressedLayer
19
-)
15
+// ApplyUncompressedLayer defines the unpack method used by the graph
16
+// driver.
17
+var ApplyUncompressedLayer = chrootarchive.ApplyUncompressedLayer
20 18
 
21 19
 // NaiveDiffDriver takes a ProtoDriver and adds the
22 20
 // capability of the Diffing methods on the local file system,
... ...
@@ -41,8 +39,10 @@ type NaiveDiffDriver struct {
41 41
 //	ApplyDiff(id, parent string, diff archive.Reader) (size int64, err error)
42 42
 //	DiffSize(id, parent string) (size int64, err error)
43 43
 func NewNaiveDiffDriver(driver ProtoDriver, idMap idtools.IdentityMapping) Driver {
44
-	return &NaiveDiffDriver{ProtoDriver: driver,
45
-		IDMap: idMap}
44
+	return &NaiveDiffDriver{
45
+		ProtoDriver: driver,
46
+		IDMap:       idMap,
47
+	}
46 48
 }
47 49
 
48 50
 // Diff produces an archive of the changes between the specified
... ...
@@ -30,10 +30,8 @@ import (
30 30
 	"golang.org/x/sys/unix"
31 31
 )
32 32
 
33
-var (
34
-	// untar defines the untar method
35
-	untar = chrootarchive.UntarUncompressed
36
-)
33
+// untar defines the untar method
34
+var untar = chrootarchive.UntarUncompressed
37 35
 
38 36
 const (
39 37
 	driverName    = "fuse-overlayfs"
... ...
@@ -65,9 +63,7 @@ type Driver struct {
65 65
 	locker    *locker.Locker
66 66
 }
67 67
 
68
-var (
69
-	logger = log.G(context.TODO()).WithField("storage-driver", driverName)
70
-)
68
+var logger = log.G(context.TODO()).WithField("storage-driver", driverName)
71 69
 
72 70
 func init() {
73 71
 	graphdriver.Register(driverName, Init)
... ...
@@ -91,10 +87,10 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
91 91
 		GID: idMap.RootPair().GID,
92 92
 	}
93 93
 
94
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
94
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
95 95
 		return nil, err
96 96
 	}
97
-	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, currentID); err != nil {
97
+	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0o700, currentID); err != nil {
98 98
 		return nil, err
99 99
 	}
100 100
 
... ...
@@ -173,10 +169,10 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
173 173
 	dir := d.dir(id)
174 174
 	root := d.idMap.RootPair()
175 175
 
176
-	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0710, root); err != nil {
176
+	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0o710, root); err != nil {
177 177
 		return err
178 178
 	}
179
-	if err := idtools.MkdirAndChown(dir, 0710, root); err != nil {
179
+	if err := idtools.MkdirAndChown(dir, 0o710, root); err != nil {
180 180
 		return err
181 181
 	}
182 182
 
... ...
@@ -191,7 +187,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
191 191
 		return fmt.Errorf("--storage-opt is not supported")
192 192
 	}
193 193
 
194
-	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0755, root); err != nil {
194
+	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0o755, root); err != nil {
195 195
 		return err
196 196
 	}
197 197
 
... ...
@@ -201,7 +197,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
201 201
 	}
202 202
 
203 203
 	// Write link id to link file
204
-	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0644); err != nil {
204
+	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
205 205
 		return err
206 206
 	}
207 207
 
... ...
@@ -210,11 +206,11 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
210 210
 		return nil
211 211
 	}
212 212
 
213
-	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0710, root); err != nil {
213
+	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0o710, root); err != nil {
214 214
 		return err
215 215
 	}
216 216
 
217
-	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0600); err != nil {
217
+	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
218 218
 		return err
219 219
 	}
220 220
 
... ...
@@ -223,7 +219,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
223 223
 		return err
224 224
 	}
225 225
 	if lower != "" {
226
-		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0666); err != nil {
226
+		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
227 227
 			return err
228 228
 		}
229 229
 	}
... ...
@@ -363,7 +359,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
363 363
 	mountData := label.FormatMountLabel(opts, mountLabel)
364 364
 	mountTarget := mergedDir
365 365
 
366
-	if err := idtools.MkdirAndChown(mergedDir, 0700, d.idMap.RootPair()); err != nil {
366
+	if err := idtools.MkdirAndChown(mergedDir, 0o700, d.idMap.RootPair()); err != nil {
367 367
 		return "", err
368 368
 	}
369 369
 
... ...
@@ -18,9 +18,7 @@ import (
18 18
 	is "gotest.tools/v3/assert/cmp"
19 19
 )
20 20
 
21
-var (
22
-	drv *Driver
23
-)
21
+var drv *Driver
24 22
 
25 23
 // Driver conforms to graphdriver.Driver interface and
26 24
 // 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 {
35 35
 	root, err := os.MkdirTemp("", "docker-graphtest-")
36 36
 	assert.NilError(t, err)
37 37
 
38
-	assert.NilError(t, os.MkdirAll(root, 0755))
38
+	assert.NilError(t, os.MkdirAll(root, 0o755))
39 39
 	d, err := graphdriver.GetDriver(name, nil, graphdriver.Options{DriverOptions: options, Root: root})
40 40
 	if err != nil {
41 41
 		t.Logf("graphdriver: %v\n", err)
... ...
@@ -95,7 +93,7 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str
95 95
 	dir, err := driver.Get("empty", "")
96 96
 	assert.NilError(t, err)
97 97
 
98
-	verifyFile(t, dir, 0755|os.ModeDir, 0, 0)
98
+	verifyFile(t, dir, 0o755|os.ModeDir, 0, 0)
99 99
 
100 100
 	// Verify that the directory is empty
101 101
 	fis, err := readDir(dir)
... ...
@@ -296,7 +294,7 @@ func writeRandomFile(path string, size uint64) error {
296 296
 	if err != nil {
297 297
 		return err
298 298
 	}
299
-	return os.WriteFile(path, data, 0700)
299
+	return os.WriteFile(path, data, 0o700)
300 300
 }
301 301
 
302 302
 // DriverTestSetQuota Create a driver and test setting quota.
... ...
@@ -36,17 +36,17 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error {
36 36
 	}
37 37
 	defer drv.Put(layer)
38 38
 
39
-	if err := os.WriteFile(filepath.Join(root, "file-a"), randomContent(64, seed), 0755); err != nil {
39
+	if err := os.WriteFile(filepath.Join(root, "file-a"), randomContent(64, seed), 0o755); err != nil {
40 40
 		return err
41 41
 	}
42
-	if err := os.MkdirAll(filepath.Join(root, "dir-b"), 0755); err != nil {
42
+	if err := os.MkdirAll(filepath.Join(root, "dir-b"), 0o755); err != nil {
43 43
 		return err
44 44
 	}
45
-	if err := os.WriteFile(filepath.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil {
45
+	if err := os.WriteFile(filepath.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0o755); err != nil {
46 46
 		return err
47 47
 	}
48 48
 
49
-	return os.WriteFile(filepath.Join(root, "file-c"), randomContent(128*128, seed+2), 0755)
49
+	return os.WriteFile(filepath.Join(root, "file-c"), randomContent(128*128, seed+2), 0o755)
50 50
 }
51 51
 
52 52
 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
75 75
 	}
76 76
 	defer drv.Put(layer)
77 77
 
78
-	return os.WriteFile(filepath.Join(root, filename), content, 0755)
78
+	return os.WriteFile(filepath.Join(root, filename), content, 0o755)
79 79
 }
80 80
 
81 81
 func addDirectory(drv graphdriver.Driver, layer, dir string) error {
... ...
@@ -85,7 +85,7 @@ func addDirectory(drv graphdriver.Driver, layer, dir string) error {
85 85
 	}
86 86
 	defer drv.Put(layer)
87 87
 
88
-	return os.MkdirAll(filepath.Join(root, dir), 0755)
88
+	return os.MkdirAll(filepath.Join(root, dir), 0o755)
89 89
 }
90 90
 
91 91
 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
128 128
 
129 129
 	for i := 0; i < count; i += 100 {
130 130
 		dir := filepath.Join(root, fmt.Sprintf("directory-%d", i))
131
-		if err := os.MkdirAll(dir, 0755); err != nil {
131
+		if err := os.MkdirAll(dir, 0o755); err != nil {
132 132
 			return err
133 133
 		}
134 134
 		for j := 0; i+j < count && j < 100; j++ {
135 135
 			file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j))
136
-			if err := os.WriteFile(file, randomContent(64, seed+int64(i+j)), 0755); err != nil {
136
+			if err := os.WriteFile(file, randomContent(64, seed+int64(i+j)), 0o755); err != nil {
137 137
 				return err
138 138
 			}
139 139
 		}
... ...
@@ -152,7 +152,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
152 152
 	var changes []archive.Change
153 153
 	for i := 0; i < count; i += 100 {
154 154
 		archiveRoot := fmt.Sprintf("/directory-%d", i)
155
-		if err := os.MkdirAll(filepath.Join(root, archiveRoot), 0755); err != nil {
155
+		if err := os.MkdirAll(filepath.Join(root, archiveRoot), 0o755); err != nil {
156 156
 			return nil, err
157 157
 		}
158 158
 		for j := 0; i+j < count && j < 100; j++ {
... ...
@@ -168,14 +168,14 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
168 168
 			case 0:
169 169
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j))
170 170
 				change.Kind = archive.ChangeModify
171
-				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
171
+				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0o755); err != nil {
172 172
 					return nil, err
173 173
 				}
174 174
 			// Add file
175 175
 			case 1:
176 176
 				change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j))
177 177
 				change.Kind = archive.ChangeAdd
178
-				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
178
+				if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0o755); err != nil {
179 179
 					return nil, err
180 180
 				}
181 181
 			// Remove file
... ...
@@ -254,17 +254,17 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
254 254
 	}
255 255
 	defer drv.Put(layer)
256 256
 
257
-	if err := os.WriteFile(filepath.Join(root, "top-id"), []byte(layer), 0755); err != nil {
257
+	if err := os.WriteFile(filepath.Join(root, "top-id"), []byte(layer), 0o755); err != nil {
258 258
 		return err
259 259
 	}
260 260
 	layerDir := filepath.Join(root, fmt.Sprintf("layer-%d", i))
261
-	if err := os.MkdirAll(layerDir, 0755); err != nil {
261
+	if err := os.MkdirAll(layerDir, 0o755); err != nil {
262 262
 		return err
263 263
 	}
264
-	if err := os.WriteFile(filepath.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil {
264
+	if err := os.WriteFile(filepath.Join(layerDir, "layer-id"), []byte(layer), 0o755); err != nil {
265 265
 		return err
266 266
 	}
267
-	return os.WriteFile(filepath.Join(layerDir, "parent-id"), []byte(parent), 0755)
267
+	return os.WriteFile(filepath.Join(layerDir, "parent-id"), []byte(parent), 0o755)
268 268
 }
269 269
 
270 270
 func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {
... ...
@@ -45,11 +45,11 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) {
45 45
 	defer driver.Put(name)
46 46
 
47 47
 	subdir := filepath.Join(dirFS, "a subdir")
48
-	assert.NilError(t, os.Mkdir(subdir, 0705|os.ModeSticky))
48
+	assert.NilError(t, os.Mkdir(subdir, 0o705|os.ModeSticky))
49 49
 	assert.NilError(t, contdriver.LocalDriver.Lchown(subdir, 1, 2))
50 50
 
51 51
 	file := filepath.Join(dirFS, "a file")
52
-	err = os.WriteFile(file, []byte("Some data"), 0222|os.ModeSetuid)
52
+	err = os.WriteFile(file, []byte("Some data"), 0o222|os.ModeSetuid)
53 53
 	assert.NilError(t, err)
54 54
 }
55 55
 
... ...
@@ -59,10 +59,10 @@ func verifyBase(t testing.TB, driver graphdriver.Driver, name string) {
59 59
 	defer driver.Put(name)
60 60
 
61 61
 	subdir := filepath.Join(dirFS, "a subdir")
62
-	verifyFile(t, subdir, 0705|os.ModeDir|os.ModeSticky, 1, 2)
62
+	verifyFile(t, subdir, 0o705|os.ModeDir|os.ModeSticky, 1, 2)
63 63
 
64 64
 	file := filepath.Join(dirFS, "a file")
65
-	verifyFile(t, file, 0222|os.ModeSetuid, 0, 0)
65
+	verifyFile(t, file, 0o222|os.ModeSetuid, 0, 0)
66 66
 
67 67
 	files, err := readDir(dirFS)
68 68
 	assert.NilError(t, err)
... ...
@@ -40,22 +40,22 @@ func doesSupportNativeDiff(d string) error {
40 40
 	}()
41 41
 
42 42
 	// Make directories l1/d, l1/d1, l2/d, l3, work, merged
43
-	if err := os.MkdirAll(filepath.Join(td, "l1", "d"), 0755); err != nil {
43
+	if err := os.MkdirAll(filepath.Join(td, "l1", "d"), 0o755); err != nil {
44 44
 		return err
45 45
 	}
46
-	if err := os.MkdirAll(filepath.Join(td, "l1", "d1"), 0755); err != nil {
46
+	if err := os.MkdirAll(filepath.Join(td, "l1", "d1"), 0o755); err != nil {
47 47
 		return err
48 48
 	}
49
-	if err := os.MkdirAll(filepath.Join(td, "l2", "d"), 0755); err != nil {
49
+	if err := os.MkdirAll(filepath.Join(td, "l2", "d"), 0o755); err != nil {
50 50
 		return err
51 51
 	}
52
-	if err := os.Mkdir(filepath.Join(td, "l3"), 0755); err != nil {
52
+	if err := os.Mkdir(filepath.Join(td, "l3"), 0o755); err != nil {
53 53
 		return err
54 54
 	}
55
-	if err := os.Mkdir(filepath.Join(td, workDirName), 0755); err != nil {
55
+	if err := os.Mkdir(filepath.Join(td, workDirName), 0o755); err != nil {
56 56
 		return err
57 57
 	}
58
-	if err := os.Mkdir(filepath.Join(td, mergedDirName), 0755); err != nil {
58
+	if err := os.Mkdir(filepath.Join(td, mergedDirName), 0o755); err != nil {
59 59
 		return err
60 60
 	}
61 61
 
... ...
@@ -75,7 +75,7 @@ func doesSupportNativeDiff(d string) error {
75 75
 	}()
76 76
 
77 77
 	// Touch file in d to force copy up of opaque directory "d" from "l2" to "l3"
78
-	if err := os.WriteFile(filepath.Join(td, mergedDirName, "d", "f"), []byte{}, 0644); err != nil {
78
+	if err := os.WriteFile(filepath.Join(td, mergedDirName, "d", "f"), []byte{}, 0o644); err != nil {
79 79
 		return errors.Wrap(err, "failed to write to merged directory")
80 80
 	}
81 81
 
... ...
@@ -149,13 +149,13 @@ func usingMetacopy(d string) (bool, error) {
149 149
 
150 150
 	l1, l2, work, merged := filepath.Join(td, "l1"), filepath.Join(td, "l2"), filepath.Join(td, "work"), filepath.Join(td, "merged")
151 151
 	for _, dir := range []string{l1, l2, work, merged} {
152
-		if err := os.Mkdir(dir, 0755); err != nil {
152
+		if err := os.Mkdir(dir, 0o755); err != nil {
153 153
 			return false, err
154 154
 		}
155 155
 	}
156 156
 
157 157
 	// Create empty file in l1 with 0700 permissions for metacopy test
158
-	if err := os.WriteFile(filepath.Join(l1, "f"), []byte{}, 0700); err != nil {
158
+	if err := os.WriteFile(filepath.Join(l1, "f"), []byte{}, 0o700); err != nil {
159 159
 		return false, err
160 160
 	}
161 161
 
... ...
@@ -180,7 +180,7 @@ func usingMetacopy(d string) (bool, error) {
180 180
 	}()
181 181
 
182 182
 	// Make a change that only impacts the inode, in the upperdir
183
-	if err := os.Chmod(filepath.Join(merged, "f"), 0600); err != nil {
183
+	if err := os.Chmod(filepath.Join(merged, "f"), 0o600); err != nil {
184 184
 		return false, errors.Wrap(err, "error changing permissions on file for metacopy check")
185 185
 	}
186 186
 
... ...
@@ -32,10 +32,8 @@ import (
32 32
 	"golang.org/x/sys/unix"
33 33
 )
34 34
 
35
-var (
36
-	// untar defines the untar method
37
-	untar = chrootarchive.UntarUncompressed
38
-)
35
+// untar defines the untar method
36
+var untar = chrootarchive.UntarUncompressed
39 37
 
40 38
 // This backend uses the overlay union filesystem for containers
41 39
 // with diff directories for each layer.
... ...
@@ -168,10 +166,10 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
168 168
 		UID: cur.UID,
169 169
 		GID: idMap.RootPair().GID,
170 170
 	}
171
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
171
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
172 172
 		return nil, err
173 173
 	}
174
-	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, cur); err != nil {
174
+	if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0o700, cur); err != nil {
175 175
 		return nil, err
176 176
 	}
177 177
 
... ...
@@ -347,10 +345,10 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
347 347
 		GID: root.GID,
348 348
 	}
349 349
 
350
-	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0710, dirID); err != nil {
350
+	if err := idtools.MkdirAllAndChown(path.Dir(dir), 0o710, dirID); err != nil {
351 351
 		return err
352 352
 	}
353
-	if err := idtools.MkdirAndChown(dir, 0710, dirID); err != nil {
353
+	if err := idtools.MkdirAndChown(dir, 0o710, dirID); err != nil {
354 354
 		return err
355 355
 	}
356 356
 
... ...
@@ -375,7 +373,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
375 375
 		}
376 376
 	}
377 377
 
378
-	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0755, root); err != nil {
378
+	if err := idtools.MkdirAndChown(path.Join(dir, diffDirName), 0o755, root); err != nil {
379 379
 		return err
380 380
 	}
381 381
 
... ...
@@ -385,7 +383,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
385 385
 	}
386 386
 
387 387
 	// Write link id to link file
388
-	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0644); err != nil {
388
+	if err := os.WriteFile(path.Join(dir, "link"), []byte(lid), 0o644); err != nil {
389 389
 		return err
390 390
 	}
391 391
 
... ...
@@ -394,11 +392,11 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
394 394
 		return nil
395 395
 	}
396 396
 
397
-	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0700, root); err != nil {
397
+	if err := idtools.MkdirAndChown(path.Join(dir, workDirName), 0o700, root); err != nil {
398 398
 		return err
399 399
 	}
400 400
 
401
-	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0600); err != nil {
401
+	if err := os.WriteFile(path.Join(d.dir(parent), "committed"), []byte{}, 0o600); err != nil {
402 402
 		return err
403 403
 	}
404 404
 
... ...
@@ -407,7 +405,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts) (retErr
407 407
 		return err
408 408
 	}
409 409
 	if lower != "" {
410
-		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0666); err != nil {
410
+		if err := os.WriteFile(path.Join(dir, lowerFile), []byte(lower), 0o666); err != nil {
411 411
 			return err
412 412
 		}
413 413
 	}
... ...
@@ -567,7 +565,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
567 567
 	mountTarget := mergedDir
568 568
 
569 569
 	root := d.idMap.RootPair()
570
-	if err := idtools.MkdirAndChown(mergedDir, 0700, root); err != nil {
570
+	if err := idtools.MkdirAndChown(mergedDir, 0o700, root); err != nil {
571 571
 		return "", err
572 572
 	}
573 573
 
... ...
@@ -60,7 +60,7 @@ func SupportsOverlay(d string, checkMultipleLowers bool) error {
60 60
 	}()
61 61
 
62 62
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
63
-		if err := os.Mkdir(filepath.Join(td, dir), 0755); err != nil {
63
+		if err := os.Mkdir(filepath.Join(td, dir), 0o755); err != nil {
64 64
 			return err
65 65
 		}
66 66
 	}
... ...
@@ -71,7 +71,7 @@ func NeedsUserXAttr(d string) (bool, error) {
71 71
 		log.G(context.TODO()).WithError(err).Warnf("Failed to remove check directory %v", tdRoot)
72 72
 	}
73 73
 
74
-	if err := os.MkdirAll(tdRoot, 0700); err != nil {
74
+	if err := os.MkdirAll(tdRoot, 0o700); err != nil {
75 75
 		return false, err
76 76
 	}
77 77
 
... ...
@@ -87,7 +87,7 @@ func NeedsUserXAttr(d string) (bool, error) {
87 87
 	}
88 88
 
89 89
 	for _, dir := range []string{"lower1", "lower2", "upper", "work", "merged"} {
90
-		if err := os.Mkdir(filepath.Join(td, dir), 0755); err != nil {
90
+		if err := os.Mkdir(filepath.Join(td, dir), 0o755); err != nil {
91 91
 			return false, err
92 92
 		}
93 93
 	}
... ...
@@ -21,10 +21,8 @@ const (
21 21
 	bestEffortXattrsOptValue = "i_want_broken_containers"
22 22
 )
23 23
 
24
-var (
25
-	// CopyDir defines the copy method to use.
26
-	CopyDir = dirCopy
27
-)
24
+// CopyDir defines the copy method to use.
25
+var CopyDir = dirCopy
28 26
 
29 27
 func init() {
30 28
 	graphdriver.Register("vfs", Init)
... ...
@@ -46,7 +44,7 @@ func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdr
46 46
 		UID: idtools.CurrentIdentity().UID,
47 47
 		GID: d.idMapping.RootPair().GID,
48 48
 	}
49
-	if err := idtools.MkdirAllAndChown(home, 0710, dirID); err != nil {
49
+	if err := idtools.MkdirAllAndChown(home, 0o710, dirID); err != nil {
50 50
 		return nil, err
51 51
 	}
52 52
 
... ...
@@ -170,10 +168,10 @@ func (d *Driver) create(id, parent string, size uint64) error {
170 170
 		UID: idtools.CurrentIdentity().UID,
171 171
 		GID: rootIDs.GID,
172 172
 	}
173
-	if err := idtools.MkdirAllAndChown(filepath.Dir(dir), 0710, dirID); err != nil {
173
+	if err := idtools.MkdirAllAndChown(filepath.Dir(dir), 0o710, dirID); err != nil {
174 174
 		return err
175 175
 	}
176
-	if err := idtools.MkdirAndChown(dir, 0755, rootIDs); err != nil {
176
+	if err := idtools.MkdirAndChown(dir, 0o755, rootIDs); err != nil {
177 177
 		return err
178 178
 	}
179 179
 
... ...
@@ -4,8 +4,7 @@ package vfs // import "github.com/docker/docker/daemon/graphdriver/vfs"
4 4
 
5 5
 import "github.com/docker/docker/quota"
6 6
 
7
-type driverQuota struct {
8
-}
7
+type driverQuota struct{}
9 8
 
10 9
 func setupDriverQuota(driver *Driver) error {
11 10
 	return nil
... ...
@@ -73,8 +73,7 @@ func init() {
73 73
 	}
74 74
 }
75 75
 
76
-type checker struct {
77
-}
76
+type checker struct{}
78 77
 
79 78
 func (c *checker) IsMounted(path string) bool {
80 79
 	return false
... ...
@@ -846,7 +845,7 @@ func (d *Driver) resolveID(id string) (string, error) {
846 846
 
847 847
 // setID stores the layerId in disk.
848 848
 func (d *Driver) setID(id, altID string) error {
849
-	return os.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0600)
849
+	return os.WriteFile(filepath.Join(d.dir(id), "layerId"), []byte(altID), 0o600)
850 850
 }
851 851
 
852 852
 // getLayerChain returns the layer chain information.
... ...
@@ -56,7 +56,7 @@ func Init(base string, opt []string, idMap idtools.IdentityMapping) (graphdriver
56 56
 		return nil, graphdriver.ErrPrerequisites
57 57
 	}
58 58
 
59
-	file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 0600)
59
+	file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 0o600)
60 60
 	if err != nil {
61 61
 		logger.Debugf("cannot open /dev/zfs: %v", err)
62 62
 		return nil, graphdriver.ErrPrerequisites
... ...
@@ -109,7 +109,7 @@ func Init(base string, opt []string, idMap idtools.IdentityMapping) (graphdriver
109 109
 		UID: idtools.CurrentIdentity().UID,
110 110
 		GID: idMap.RootPair().GID,
111 111
 	}
112
-	if err := idtools.MkdirAllAndChown(base, 0710, dirID); err != nil {
112
+	if err := idtools.MkdirAllAndChown(base, 0o710, dirID); err != nil {
113 113
 		return nil, fmt.Errorf("Failed to create '%s': %v", base, err)
114 114
 	}
115 115
 
... ...
@@ -388,7 +388,7 @@ func (d *Driver) Get(id, mountLabel string) (_ string, retErr error) {
388 388
 
389 389
 	root := d.idMap.RootPair()
390 390
 	// Create the target directories if they don't exist
391
-	if err := idtools.MkdirAllAndChown(mountpoint, 0755, root); err != nil {
391
+	if err := idtools.MkdirAllAndChown(mountpoint, 0o755, root); err != nil {
392 392
 		return "", err
393 393
 	}
394 394
 
... ...
@@ -3,8 +3,8 @@ package zfs // import "github.com/docker/docker/daemon/graphdriver/zfs"
3 3
 import (
4 4
 	"strings"
5 5
 
6
-	"github.com/docker/docker/daemon/graphdriver"
7 6
 	"github.com/containerd/containerd/log"
7
+	"github.com/docker/docker/daemon/graphdriver"
8 8
 	"golang.org/x/sys/unix"
9 9
 )
10 10