This is no longer needed, as the tests are gone.
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
... | ... |
@@ -4,6 +4,9 @@ package devmapper |
4 | 4 |
|
5 | 5 |
import ( |
6 | 6 |
"fmt" |
7 |
+ "os" |
|
8 |
+ "syscall" |
|
9 |
+ |
|
7 | 10 |
"github.com/dotcloud/docker/utils" |
8 | 11 |
) |
9 | 12 |
|
... | ... |
@@ -14,7 +17,7 @@ func stringToLoopName(src string) [LoNameSize]uint8 { |
14 | 14 |
} |
15 | 15 |
|
16 | 16 |
func getNextFreeLoopbackIndex() (int, error) { |
17 |
- f, err := osOpenFile("/dev/loop-control", osORdOnly, 0644) |
|
17 |
+ f, err := os.OpenFile("/dev/loop-control", os.O_RDONLY, 0644) |
|
18 | 18 |
if err != nil { |
19 | 19 |
return 0, err |
20 | 20 |
} |
... | ... |
@@ -27,27 +30,27 @@ func getNextFreeLoopbackIndex() (int, error) { |
27 | 27 |
return index, err |
28 | 28 |
} |
29 | 29 |
|
30 |
-func openNextAvailableLoopback(index int, sparseFile *osFile) (loopFile *osFile, err error) { |
|
30 |
+func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.File, err error) { |
|
31 | 31 |
// Start looking for a free /dev/loop |
32 | 32 |
for { |
33 | 33 |
target := fmt.Sprintf("/dev/loop%d", index) |
34 | 34 |
index++ |
35 | 35 |
|
36 |
- fi, err := osStat(target) |
|
36 |
+ fi, err := os.Stat(target) |
|
37 | 37 |
if err != nil { |
38 |
- if osIsNotExist(err) { |
|
38 |
+ if os.IsNotExist(err) { |
|
39 | 39 |
utils.Errorf("There are no more loopback device available.") |
40 | 40 |
} |
41 | 41 |
return nil, ErrAttachLoopbackDevice |
42 | 42 |
} |
43 | 43 |
|
44 |
- if fi.Mode()&osModeDevice != osModeDevice { |
|
44 |
+ if fi.Mode()&os.ModeDevice != os.ModeDevice { |
|
45 | 45 |
utils.Errorf("Loopback device %s is not a block device.", target) |
46 | 46 |
continue |
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
// OpenFile adds O_CLOEXEC |
50 |
- loopFile, err = osOpenFile(target, osORdWr, 0644) |
|
50 |
+ loopFile, err = os.OpenFile(target, os.O_RDWR, 0644) |
|
51 | 51 |
if err != nil { |
52 | 52 |
utils.Errorf("Error openning loopback device: %s", err) |
53 | 53 |
return nil, ErrAttachLoopbackDevice |
... | ... |
@@ -58,7 +61,7 @@ func openNextAvailableLoopback(index int, sparseFile *osFile) (loopFile *osFile, |
58 | 58 |
loopFile.Close() |
59 | 59 |
|
60 | 60 |
// If the error is EBUSY, then try the next loopback |
61 |
- if err != sysEBusy { |
|
61 |
+ if err != syscall.EBUSY { |
|
62 | 62 |
utils.Errorf("Cannot set up loopback device %s: %s", target, err) |
63 | 63 |
return nil, ErrAttachLoopbackDevice |
64 | 64 |
} |
... | ... |
@@ -80,8 +83,8 @@ func openNextAvailableLoopback(index int, sparseFile *osFile) (loopFile *osFile, |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
// attachLoopDevice attaches the given sparse file to the next |
83 |
-// available loopback device. It returns an opened *osFile. |
|
84 |
-func attachLoopDevice(sparseName string) (loop *osFile, err error) { |
|
83 |
+// available loopback device. It returns an opened *os.File. |
|
84 |
+func attachLoopDevice(sparseName string) (loop *os.File, err error) { |
|
85 | 85 |
|
86 | 86 |
// Try to retrieve the next available loopback device via syscall. |
87 | 87 |
// If it fails, we discard error and start loopking for a |
... | ... |
@@ -92,7 +95,7 @@ func attachLoopDevice(sparseName string) (loop *osFile, err error) { |
92 | 92 |
} |
93 | 93 |
|
94 | 94 |
// OpenFile adds O_CLOEXEC |
95 |
- sparseFile, err := osOpenFile(sparseName, osORdWr, 0644) |
|
95 |
+ sparseFile, err := os.OpenFile(sparseName, os.O_RDWR, 0644) |
|
96 | 96 |
if err != nil { |
97 | 97 |
utils.Errorf("Error openning sparse file %s: %s", sparseName, err) |
98 | 98 |
return nil, ErrAttachLoopbackDevice |
... | ... |
@@ -8,6 +8,8 @@ import ( |
8 | 8 |
"fmt" |
9 | 9 |
"io" |
10 | 10 |
"io/ioutil" |
11 |
+ "os" |
|
12 |
+ "os/exec" |
|
11 | 13 |
"path" |
12 | 14 |
"path/filepath" |
13 | 15 |
"strconv" |
... | ... |
@@ -135,7 +137,7 @@ func (devices *DeviceSet) hasImage(name string) bool { |
135 | 135 |
dirname := devices.loopbackDir() |
136 | 136 |
filename := path.Join(dirname, name) |
137 | 137 |
|
138 |
- _, err := osStat(filename) |
|
138 |
+ _, err := os.Stat(filename) |
|
139 | 139 |
return err == nil |
140 | 140 |
} |
141 | 141 |
|
... | ... |
@@ -147,16 +149,16 @@ func (devices *DeviceSet) ensureImage(name string, size int64) (string, error) { |
147 | 147 |
dirname := devices.loopbackDir() |
148 | 148 |
filename := path.Join(dirname, name) |
149 | 149 |
|
150 |
- if err := osMkdirAll(dirname, 0700); err != nil && !osIsExist(err) { |
|
150 |
+ if err := os.MkdirAll(dirname, 0700); err != nil && !os.IsExist(err) { |
|
151 | 151 |
return "", err |
152 | 152 |
} |
153 | 153 |
|
154 |
- if _, err := osStat(filename); err != nil { |
|
155 |
- if !osIsNotExist(err) { |
|
154 |
+ if _, err := os.Stat(filename); err != nil { |
|
155 |
+ if !os.IsNotExist(err) { |
|
156 | 156 |
return "", err |
157 | 157 |
} |
158 | 158 |
utils.Debugf("Creating loopback file %s for device-manage use", filename) |
159 |
- file, err := osOpenFile(filename, osORdWr|osOCreate, 0600) |
|
159 |
+ file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, 0600) |
|
160 | 160 |
if err != nil { |
161 | 161 |
return "", err |
162 | 162 |
} |
... | ... |
@@ -175,7 +177,7 @@ func (devices *DeviceSet) allocateTransactionId() uint64 { |
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
func (devices *DeviceSet) removeMetadata(info *DevInfo) error { |
178 |
- if err := osRemoveAll(devices.metadataFile(info)); err != nil { |
|
178 |
+ if err := os.RemoveAll(devices.metadataFile(info)); err != nil { |
|
179 | 179 |
return fmt.Errorf("Error removing metadata file %s: %s", devices.metadataFile(info), err) |
180 | 180 |
} |
181 | 181 |
return nil |
... | ... |
@@ -204,7 +206,7 @@ func (devices *DeviceSet) saveMetadata(info *DevInfo) error { |
204 | 204 |
if err := tmpFile.Close(); err != nil { |
205 | 205 |
return fmt.Errorf("Error closing metadata file %s: %s", tmpFile.Name(), err) |
206 | 206 |
} |
207 |
- if err := osRename(tmpFile.Name(), devices.metadataFile(info)); err != nil { |
|
207 |
+ if err := os.Rename(tmpFile.Name(), devices.metadataFile(info)); err != nil { |
|
208 | 208 |
return fmt.Errorf("Error committing metadata file %s: %s", tmpFile.Name(), err) |
209 | 209 |
} |
210 | 210 |
|
... | ... |
@@ -271,9 +273,9 @@ func (devices *DeviceSet) activateDeviceIfNeeded(info *DevInfo) error { |
271 | 271 |
func (devices *DeviceSet) createFilesystem(info *DevInfo) error { |
272 | 272 |
devname := info.DevName() |
273 | 273 |
|
274 |
- err := execRun("mkfs.ext4", "-E", "discard,lazy_itable_init=0,lazy_journal_init=0", devname) |
|
274 |
+ err := exec.Command("mkfs.ext4", "-E", "discard,lazy_itable_init=0,lazy_journal_init=0", devname).Run() |
|
275 | 275 |
if err != nil { |
276 |
- err = execRun("mkfs.ext4", "-E", "discard,lazy_itable_init=0", devname) |
|
276 |
+ err = exec.Command("mkfs.ext4", "-E", "discard,lazy_itable_init=0", devname).Run() |
|
277 | 277 |
} |
278 | 278 |
if err != nil { |
279 | 279 |
utils.Debugf("\n--->Err: %s\n", err) |
... | ... |
@@ -298,7 +300,7 @@ func (devices *DeviceSet) initMetaData() error { |
298 | 298 |
// Migrate old metadatafile |
299 | 299 |
|
300 | 300 |
jsonData, err := ioutil.ReadFile(devices.oldMetadataFile()) |
301 |
- if err != nil && !osIsNotExist(err) { |
|
301 |
+ if err != nil && !os.IsNotExist(err) { |
|
302 | 302 |
utils.Debugf("\n--->Err: %s\n", err) |
303 | 303 |
return err |
304 | 304 |
} |
... | ... |
@@ -319,7 +321,7 @@ func (devices *DeviceSet) initMetaData() error { |
319 | 319 |
devices.saveMetadata(info) |
320 | 320 |
} |
321 | 321 |
} |
322 |
- if err := osRename(devices.oldMetadataFile(), devices.oldMetadataFile()+".migrated"); err != nil { |
|
322 |
+ if err := os.Rename(devices.oldMetadataFile(), devices.oldMetadataFile()+".migrated"); err != nil { |
|
323 | 323 |
return err |
324 | 324 |
} |
325 | 325 |
|
... | ... |
@@ -408,11 +410,11 @@ func (devices *DeviceSet) setupBaseImage() error { |
408 | 408 |
func setCloseOnExec(name string) { |
409 | 409 |
if fileInfos, _ := ioutil.ReadDir("/proc/self/fd"); fileInfos != nil { |
410 | 410 |
for _, i := range fileInfos { |
411 |
- link, _ := osReadlink(filepath.Join("/proc/self/fd", i.Name())) |
|
411 |
+ link, _ := os.Readlink(filepath.Join("/proc/self/fd", i.Name())) |
|
412 | 412 |
if link == name { |
413 | 413 |
fd, err := strconv.Atoi(i.Name()) |
414 | 414 |
if err == nil { |
415 |
- sysCloseOnExec(fd) |
|
415 |
+ syscall.CloseOnExec(fd) |
|
416 | 416 |
} |
417 | 417 |
} |
418 | 418 |
} |
... | ... |
@@ -440,7 +442,7 @@ func (devices *DeviceSet) ResizePool(size int64) error { |
440 | 440 |
datafilename := path.Join(dirname, "data") |
441 | 441 |
metadatafilename := path.Join(dirname, "metadata") |
442 | 442 |
|
443 |
- datafile, err := osOpenFile(datafilename, osORdWr, 0) |
|
443 |
+ datafile, err := os.OpenFile(datafilename, os.O_RDWR, 0) |
|
444 | 444 |
if datafile == nil { |
445 | 445 |
return err |
446 | 446 |
} |
... | ... |
@@ -461,7 +463,7 @@ func (devices *DeviceSet) ResizePool(size int64) error { |
461 | 461 |
} |
462 | 462 |
defer dataloopback.Close() |
463 | 463 |
|
464 |
- metadatafile, err := osOpenFile(metadatafilename, osORdWr, 0) |
|
464 |
+ metadatafile, err := os.OpenFile(metadatafilename, os.O_RDWR, 0) |
|
465 | 465 |
if metadatafile == nil { |
466 | 466 |
return err |
467 | 467 |
} |
... | ... |
@@ -504,17 +506,17 @@ func (devices *DeviceSet) ResizePool(size int64) error { |
504 | 504 |
func (devices *DeviceSet) initDevmapper(doInit bool) error { |
505 | 505 |
logInit(devices) |
506 | 506 |
|
507 |
- if err := osMkdirAll(devices.metadataDir(), 0700); err != nil && !osIsExist(err) { |
|
507 |
+ if err := os.MkdirAll(devices.metadataDir(), 0700); err != nil && !os.IsExist(err) { |
|
508 | 508 |
return err |
509 | 509 |
} |
510 | 510 |
|
511 | 511 |
// Set the device prefix from the device id and inode of the docker root dir |
512 | 512 |
|
513 |
- st, err := osStat(devices.root) |
|
513 |
+ st, err := os.Stat(devices.root) |
|
514 | 514 |
if err != nil { |
515 | 515 |
return fmt.Errorf("Error looking up dir %s: %s", devices.root, err) |
516 | 516 |
} |
517 |
- sysSt := toSysStatT(st.Sys()) |
|
517 |
+ sysSt := st.Sys().(*syscall.Stat_t) |
|
518 | 518 |
// "reg-" stands for "regular file". |
519 | 519 |
// In the future we might use "dev-" for "device file", etc. |
520 | 520 |
// docker-maj,min[-inode] stands for: |
... | ... |
@@ -845,7 +847,7 @@ func (devices *DeviceSet) Shutdown() error { |
845 | 845 |
// We use MNT_DETACH here in case it is still busy in some running |
846 | 846 |
// container. This means it'll go away from the global scope directly, |
847 | 847 |
// and the device will be released when that container dies. |
848 |
- if err := sysUnmount(info.mountPath, syscall.MNT_DETACH); err != nil { |
|
848 |
+ if err := syscall.Unmount(info.mountPath, syscall.MNT_DETACH); err != nil { |
|
849 | 849 |
utils.Debugf("Shutdown unmounting %s, error: %s\n", info.mountPath, err) |
850 | 850 |
} |
851 | 851 |
|
... | ... |
@@ -903,13 +905,13 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error { |
903 | 903 |
return fmt.Errorf("Error activating devmapper device for '%s': %s", hash, err) |
904 | 904 |
} |
905 | 905 |
|
906 |
- var flags uintptr = sysMsMgcVal |
|
906 |
+ var flags uintptr = syscall.MS_MGC_VAL |
|
907 | 907 |
|
908 | 908 |
mountOptions := label.FormatMountLabel("discard", mountLabel) |
909 |
- err = sysMount(info.DevName(), path, "ext4", flags, mountOptions) |
|
910 |
- if err != nil && err == sysEInval { |
|
909 |
+ err = syscall.Mount(info.DevName(), path, "ext4", flags, mountOptions) |
|
910 |
+ if err != nil && err == syscall.EINVAL { |
|
911 | 911 |
mountOptions = label.FormatMountLabel("", mountLabel) |
912 |
- err = sysMount(info.DevName(), path, "ext4", flags, mountOptions) |
|
912 |
+ err = syscall.Mount(info.DevName(), path, "ext4", flags, mountOptions) |
|
913 | 913 |
} |
914 | 914 |
if err != nil { |
915 | 915 |
return fmt.Errorf("Error mounting '%s' on '%s': %s", info.DevName(), path, err) |
... | ... |
@@ -946,7 +948,7 @@ func (devices *DeviceSet) UnmountDevice(hash string) error { |
946 | 946 |
} |
947 | 947 |
|
948 | 948 |
utils.Debugf("[devmapper] Unmount(%s)", info.mountPath) |
949 |
- if err := sysUnmount(info.mountPath, 0); err != nil { |
|
949 |
+ if err := syscall.Unmount(info.mountPath, 0); err != nil { |
|
950 | 950 |
utils.Debugf("\n--->Err: %s\n", err) |
951 | 951 |
return err |
952 | 952 |
} |
... | ... |
@@ -5,9 +5,11 @@ package devmapper |
5 | 5 |
import ( |
6 | 6 |
"errors" |
7 | 7 |
"fmt" |
8 |
- "github.com/dotcloud/docker/utils" |
|
8 |
+ "os" |
|
9 | 9 |
"runtime" |
10 | 10 |
"syscall" |
11 |
+ |
|
12 |
+ "github.com/dotcloud/docker/utils" |
|
11 | 13 |
) |
12 | 14 |
|
13 | 15 |
type DevmapperLogger interface { |
... | ... |
@@ -184,7 +186,7 @@ func (t *Task) GetNextTarget(next uintptr) (nextPtr uintptr, start uint64, |
184 | 184 |
start, length, targetType, params |
185 | 185 |
} |
186 | 186 |
|
187 |
-func getLoopbackBackingFile(file *osFile) (uint64, uint64, error) { |
|
187 |
+func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) { |
|
188 | 188 |
loopInfo, err := ioctlLoopGetStatus64(file.Fd()) |
189 | 189 |
if err != nil { |
190 | 190 |
utils.Errorf("Error get loopback backing file: %s\n", err) |
... | ... |
@@ -193,7 +195,7 @@ func getLoopbackBackingFile(file *osFile) (uint64, uint64, error) { |
193 | 193 |
return loopInfo.loDevice, loopInfo.loInode, nil |
194 | 194 |
} |
195 | 195 |
|
196 |
-func LoopbackSetCapacity(file *osFile) error { |
|
196 |
+func LoopbackSetCapacity(file *os.File) error { |
|
197 | 197 |
if err := ioctlLoopSetCapacity(file.Fd(), 0); err != nil { |
198 | 198 |
utils.Errorf("Error loopbackSetCapacity: %s", err) |
199 | 199 |
return ErrLoopbackSetCapacity |
... | ... |
@@ -201,20 +203,20 @@ func LoopbackSetCapacity(file *osFile) error { |
201 | 201 |
return nil |
202 | 202 |
} |
203 | 203 |
|
204 |
-func FindLoopDeviceFor(file *osFile) *osFile { |
|
204 |
+func FindLoopDeviceFor(file *os.File) *os.File { |
|
205 | 205 |
stat, err := file.Stat() |
206 | 206 |
if err != nil { |
207 | 207 |
return nil |
208 | 208 |
} |
209 |
- targetInode := stat.Sys().(*sysStatT).Ino |
|
210 |
- targetDevice := stat.Sys().(*sysStatT).Dev |
|
209 |
+ targetInode := stat.Sys().(*syscall.Stat_t).Ino |
|
210 |
+ targetDevice := stat.Sys().(*syscall.Stat_t).Dev |
|
211 | 211 |
|
212 | 212 |
for i := 0; true; i++ { |
213 | 213 |
path := fmt.Sprintf("/dev/loop%d", i) |
214 | 214 |
|
215 |
- file, err := osOpenFile(path, osORdWr, 0) |
|
215 |
+ file, err := os.OpenFile(path, os.O_RDWR, 0) |
|
216 | 216 |
if err != nil { |
217 |
- if osIsNotExist(err) { |
|
217 |
+ if os.IsNotExist(err) { |
|
218 | 218 |
return nil |
219 | 219 |
} |
220 | 220 |
|
... | ... |
@@ -284,7 +286,7 @@ func RemoveDevice(name string) error { |
284 | 284 |
return nil |
285 | 285 |
} |
286 | 286 |
|
287 |
-func GetBlockDeviceSize(file *osFile) (uint64, error) { |
|
287 |
+func GetBlockDeviceSize(file *os.File) (uint64, error) { |
|
288 | 288 |
size, err := ioctlBlkGetSize64(file.Fd()) |
289 | 289 |
if err != nil { |
290 | 290 |
utils.Errorf("Error getblockdevicesize: %s", err) |
... | ... |
@@ -294,7 +296,7 @@ func GetBlockDeviceSize(file *osFile) (uint64, error) { |
294 | 294 |
} |
295 | 295 |
|
296 | 296 |
func BlockDeviceDiscard(path string) error { |
297 |
- file, err := osOpenFile(path, osORdWr, 0) |
|
297 |
+ file, err := os.OpenFile(path, os.O_RDWR, 0) |
|
298 | 298 |
if err != nil { |
299 | 299 |
return err |
300 | 300 |
} |
... | ... |
@@ -317,7 +319,7 @@ func BlockDeviceDiscard(path string) error { |
317 | 317 |
} |
318 | 318 |
|
319 | 319 |
// This is the programmatic example of "dmsetup create" |
320 |
-func createPool(poolName string, dataFile, metadataFile *osFile) error { |
|
320 |
+func createPool(poolName string, dataFile, metadataFile *os.File) error { |
|
321 | 321 |
task, err := createTask(DeviceCreate, poolName) |
322 | 322 |
if task == nil { |
323 | 323 |
return err |
... | ... |
@@ -347,7 +349,7 @@ func createPool(poolName string, dataFile, metadataFile *osFile) error { |
347 | 347 |
return nil |
348 | 348 |
} |
349 | 349 |
|
350 |
-func reloadPool(poolName string, dataFile, metadataFile *osFile) error { |
|
350 |
+func reloadPool(poolName string, dataFile, metadataFile *os.File) error { |
|
351 | 351 |
task, err := createTask(DeviceReload, poolName) |
352 | 352 |
if task == nil { |
353 | 353 |
return err |
... | ... |
@@ -26,7 +26,7 @@ type Driver struct { |
26 | 26 |
home string |
27 | 27 |
} |
28 | 28 |
|
29 |
-var Init = func(home string) (graphdriver.Driver, error) { |
|
29 |
+func Init(home string) (graphdriver.Driver, error) { |
|
30 | 30 |
deviceSet, err := NewDeviceSet(home, true) |
31 | 31 |
if err != nil { |
32 | 32 |
return nil, err |
... | ... |
@@ -94,7 +94,7 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { |
94 | 94 |
mp := path.Join(d.home, "mnt", id) |
95 | 95 |
|
96 | 96 |
// Create the target directories if they don't exist |
97 |
- if err := osMkdirAll(mp, 0755); err != nil && !osIsExist(err) { |
|
97 |
+ if err := os.MkdirAll(mp, 0755); err != nil && !os.IsExist(err) { |
|
98 | 98 |
return "", err |
99 | 99 |
} |
100 | 100 |
|
... | ... |
@@ -104,13 +104,13 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { |
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
rootFs := path.Join(mp, "rootfs") |
107 |
- if err := osMkdirAll(rootFs, 0755); err != nil && !osIsExist(err) { |
|
107 |
+ if err := os.MkdirAll(rootFs, 0755); err != nil && !os.IsExist(err) { |
|
108 | 108 |
d.DeviceSet.UnmountDevice(id) |
109 | 109 |
return "", err |
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
idFile := path.Join(mp, "id") |
113 |
- if _, err := osStat(idFile); err != nil && osIsNotExist(err) { |
|
113 |
+ if _, err := os.Stat(idFile); err != nil && os.IsNotExist(err) { |
|
114 | 114 |
// Create an "id" file with the container/image id in it to help reconscruct this in case |
115 | 115 |
// of later problems |
116 | 116 |
if err := ioutil.WriteFile(idFile, []byte(id), 0600); err != nil { |
... | ... |
@@ -3,11 +3,12 @@ |
3 | 3 |
package devmapper |
4 | 4 |
|
5 | 5 |
import ( |
6 |
+ "syscall" |
|
6 | 7 |
"unsafe" |
7 | 8 |
) |
8 | 9 |
|
9 | 10 |
func ioctlLoopCtlGetFree(fd uintptr) (int, error) { |
10 |
- index, _, err := sysSyscall(sysSysIoctl, fd, LoopCtlGetFree, 0) |
|
11 |
+ index, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, LoopCtlGetFree, 0) |
|
11 | 12 |
if err != 0 { |
12 | 13 |
return 0, err |
13 | 14 |
} |
... | ... |
@@ -15,21 +16,21 @@ func ioctlLoopCtlGetFree(fd uintptr) (int, error) { |
15 | 15 |
} |
16 | 16 |
|
17 | 17 |
func ioctlLoopSetFd(loopFd, sparseFd uintptr) error { |
18 |
- if _, _, err := sysSyscall(sysSysIoctl, loopFd, LoopSetFd, sparseFd); err != 0 { |
|
18 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetFd, sparseFd); err != 0 { |
|
19 | 19 |
return err |
20 | 20 |
} |
21 | 21 |
return nil |
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
func ioctlLoopSetStatus64(loopFd uintptr, loopInfo *LoopInfo64) error { |
25 |
- if _, _, err := sysSyscall(sysSysIoctl, loopFd, LoopSetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
25 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
26 | 26 |
return err |
27 | 27 |
} |
28 | 28 |
return nil |
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
func ioctlLoopClrFd(loopFd uintptr) error { |
32 |
- if _, _, err := sysSyscall(sysSysIoctl, loopFd, LoopClrFd, 0); err != 0 { |
|
32 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopClrFd, 0); err != 0 { |
|
33 | 33 |
return err |
34 | 34 |
} |
35 | 35 |
return nil |
... | ... |
@@ -38,14 +39,14 @@ func ioctlLoopClrFd(loopFd uintptr) error { |
38 | 38 |
func ioctlLoopGetStatus64(loopFd uintptr) (*LoopInfo64, error) { |
39 | 39 |
loopInfo := &LoopInfo64{} |
40 | 40 |
|
41 |
- if _, _, err := sysSyscall(sysSysIoctl, loopFd, LoopGetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
41 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopGetStatus64, uintptr(unsafe.Pointer(loopInfo))); err != 0 { |
|
42 | 42 |
return nil, err |
43 | 43 |
} |
44 | 44 |
return loopInfo, nil |
45 | 45 |
} |
46 | 46 |
|
47 | 47 |
func ioctlLoopSetCapacity(loopFd uintptr, value int) error { |
48 |
- if _, _, err := sysSyscall(sysSysIoctl, loopFd, LoopSetCapacity, uintptr(value)); err != 0 { |
|
48 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, loopFd, LoopSetCapacity, uintptr(value)); err != 0 { |
|
49 | 49 |
return err |
50 | 50 |
} |
51 | 51 |
return nil |
... | ... |
@@ -53,7 +54,7 @@ func ioctlLoopSetCapacity(loopFd uintptr, value int) error { |
53 | 53 |
|
54 | 54 |
func ioctlBlkGetSize64(fd uintptr) (int64, error) { |
55 | 55 |
var size int64 |
56 |
- if _, _, err := sysSyscall(sysSysIoctl, fd, BlkGetSize64, uintptr(unsafe.Pointer(&size))); err != 0 { |
|
56 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkGetSize64, uintptr(unsafe.Pointer(&size))); err != 0 { |
|
57 | 57 |
return 0, err |
58 | 58 |
} |
59 | 59 |
return size, nil |
... | ... |
@@ -64,7 +65,7 @@ func ioctlBlkDiscard(fd uintptr, offset, length uint64) error { |
64 | 64 |
r[0] = offset |
65 | 65 |
r[1] = length |
66 | 66 |
|
67 |
- if _, _, err := sysSyscall(sysSysIoctl, fd, BlkDiscard, uintptr(unsafe.Pointer(&r[0]))); err != 0 { |
|
67 |
+ if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, BlkDiscard, uintptr(unsafe.Pointer(&r[0]))); err != 0 { |
|
68 | 68 |
return err |
69 | 69 |
} |
70 | 70 |
return nil |
... | ... |
@@ -3,25 +3,27 @@ |
3 | 3 |
package devmapper |
4 | 4 |
|
5 | 5 |
import ( |
6 |
+ "os" |
|
6 | 7 |
"path/filepath" |
8 |
+ "syscall" |
|
7 | 9 |
) |
8 | 10 |
|
9 | 11 |
// FIXME: this is copy-pasted from the aufs driver. |
10 | 12 |
// It should be moved into the core. |
11 | 13 |
|
12 |
-var Mounted = func(mountpoint string) (bool, error) { |
|
13 |
- mntpoint, err := osStat(mountpoint) |
|
14 |
+func Mounted(mountpoint string) (bool, error) { |
|
15 |
+ mntpoint, err := os.Stat(mountpoint) |
|
14 | 16 |
if err != nil { |
15 |
- if osIsNotExist(err) { |
|
17 |
+ if os.IsNotExist(err) { |
|
16 | 18 |
return false, nil |
17 | 19 |
} |
18 | 20 |
return false, err |
19 | 21 |
} |
20 |
- parent, err := osStat(filepath.Join(mountpoint, "..")) |
|
22 |
+ parent, err := os.Stat(filepath.Join(mountpoint, "..")) |
|
21 | 23 |
if err != nil { |
22 | 24 |
return false, err |
23 | 25 |
} |
24 |
- mntpointSt := toSysStatT(mntpoint.Sys()) |
|
25 |
- parentSt := toSysStatT(parent.Sys()) |
|
26 |
+ mntpointSt := mntpoint.Sys().(*syscall.Stat_t) |
|
27 |
+ parentSt := parent.Sys().(*syscall.Stat_t) |
|
26 | 28 |
return mntpointSt.Dev != parentSt.Dev, nil |
27 | 29 |
} |
28 | 30 |
deleted file mode 100644 |
... | ... |
@@ -1,57 +0,0 @@ |
1 |
-// +build linux,amd64 |
|
2 |
- |
|
3 |
-package devmapper |
|
4 |
- |
|
5 |
-import ( |
|
6 |
- "os" |
|
7 |
- "os/exec" |
|
8 |
- "syscall" |
|
9 |
-) |
|
10 |
- |
|
11 |
-type ( |
|
12 |
- sysStatT syscall.Stat_t |
|
13 |
- sysErrno syscall.Errno |
|
14 |
- |
|
15 |
- osFile struct{ *os.File } |
|
16 |
-) |
|
17 |
- |
|
18 |
-var ( |
|
19 |
- sysMount = syscall.Mount |
|
20 |
- sysUnmount = syscall.Unmount |
|
21 |
- sysCloseOnExec = syscall.CloseOnExec |
|
22 |
- sysSyscall = syscall.Syscall |
|
23 |
- |
|
24 |
- osOpenFile = func(name string, flag int, perm os.FileMode) (*osFile, error) { |
|
25 |
- f, err := os.OpenFile(name, flag, perm) |
|
26 |
- return &osFile{File: f}, err |
|
27 |
- } |
|
28 |
- osOpen = func(name string) (*osFile, error) { f, err := os.Open(name); return &osFile{File: f}, err } |
|
29 |
- osNewFile = os.NewFile |
|
30 |
- osCreate = os.Create |
|
31 |
- osStat = os.Stat |
|
32 |
- osIsNotExist = os.IsNotExist |
|
33 |
- osIsExist = os.IsExist |
|
34 |
- osMkdirAll = os.MkdirAll |
|
35 |
- osRemoveAll = os.RemoveAll |
|
36 |
- osRename = os.Rename |
|
37 |
- osReadlink = os.Readlink |
|
38 |
- |
|
39 |
- execRun = func(name string, args ...string) error { return exec.Command(name, args...).Run() } |
|
40 |
-) |
|
41 |
- |
|
42 |
-const ( |
|
43 |
- sysMsMgcVal = syscall.MS_MGC_VAL |
|
44 |
- sysMsRdOnly = syscall.MS_RDONLY |
|
45 |
- sysEInval = syscall.EINVAL |
|
46 |
- sysSysIoctl = syscall.SYS_IOCTL |
|
47 |
- sysEBusy = syscall.EBUSY |
|
48 |
- |
|
49 |
- osORdOnly = os.O_RDONLY |
|
50 |
- osORdWr = os.O_RDWR |
|
51 |
- osOCreate = os.O_CREATE |
|
52 |
- osModeDevice = os.ModeDevice |
|
53 |
-) |
|
54 |
- |
|
55 |
-func toSysStatT(i interface{}) *sysStatT { |
|
56 |
- return (*sysStatT)(i.(*syscall.Stat_t)) |
|
57 |
-} |