|
@@ -1,37 +1,13 @@
|
|
package docker
|
|
package docker
|
|
|
|
|
|
-/*
|
|
|
|
-#include <sys/ioctl.h>
|
|
|
|
-#include <linux/fs.h>
|
|
|
|
-#include <errno.h>
|
|
|
|
-
|
|
|
|
-// See linux.git/fs/btrfs/ioctl.h
|
|
|
|
-#define BTRFS_IOCTL_MAGIC 0x94
|
|
|
|
-#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
|
|
|
|
-
|
|
|
|
-int
|
|
|
|
-btrfs_reflink(int fd_out, int fd_in)
|
|
|
|
-{
|
|
|
|
- int res;
|
|
|
|
- res = ioctl(fd_out, BTRFS_IOC_CLONE, fd_in);
|
|
|
|
- if (res < 0)
|
|
|
|
- return errno;
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-*/
|
|
|
|
-import "C"
|
|
|
|
import (
|
|
import (
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/dotcloud/docker/archive"
|
|
"github.com/dotcloud/docker/archive"
|
|
"github.com/dotcloud/docker/namesgenerator"
|
|
"github.com/dotcloud/docker/namesgenerator"
|
|
"github.com/dotcloud/docker/utils"
|
|
"github.com/dotcloud/docker/utils"
|
|
- "io"
|
|
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
- "os"
|
|
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
- "syscall"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type Change struct {
|
|
type Change struct {
|
|
@@ -346,13 +322,6 @@ func migratePortMappings(config *Config, hostConfig *HostConfig) error {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-func BtrfsReflink(fd_out, fd_in uintptr) error {
|
|
|
|
- res := C.btrfs_reflink(C.int(fd_out), C.int(fd_in))
|
|
|
|
- if res != 0 {
|
|
|
|
- return syscall.Errno(res)
|
|
|
|
- }
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
|
|
|
|
// Links come in the format of
|
|
// Links come in the format of
|
|
// name:alias
|
|
// name:alias
|
|
@@ -386,14 +355,3 @@ func (c *checker) Exists(name string) bool {
|
|
func generateRandomName(runtime *Runtime) (string, error) {
|
|
func generateRandomName(runtime *Runtime) (string, error) {
|
|
return namesgenerator.GenerateRandomName(&checker{runtime})
|
|
return namesgenerator.GenerateRandomName(&checker{runtime})
|
|
}
|
|
}
|
|
-
|
|
|
|
-func CopyFile(dstFile, srcFile *os.File) error {
|
|
|
|
- err := BtrfsReflink(dstFile.Fd(), srcFile.Fd())
|
|
|
|
- if err == nil {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Fall back to normal copy
|
|
|
|
- _, err = io.Copy(dstFile, srcFile)
|
|
|
|
- return err
|
|
|
|
-}
|
|
|