diff --git a/api/server/server_linux.go b/api/server/server_unix.go similarity index 99% rename from api/server/server_linux.go rename to api/server/server_unix.go index 09c3c1322c2d50b096deb8b637a569b994017f39..84df45bcd171cadfc6afaaa4dd0d8f9487b87d5f 100644 --- a/api/server/server_linux.go +++ b/api/server/server_unix.go @@ -1,4 +1,4 @@ -// +build linux +// +build freebsd linux package server diff --git a/builder/internals_linux.go b/builder/internals_unix.go similarity index 98% rename from builder/internals_linux.go rename to builder/internals_unix.go index 76308c68951e5d0097143cea118a6e082ae23dec..3d8ad54e9009d34d5bb79f1c8889ca657a631627 100644 --- a/builder/internals_linux.go +++ b/builder/internals_unix.go @@ -1,4 +1,4 @@ -// +build linux +// +build freebsd linux package builder diff --git a/daemon/config_linux.go b/daemon/config_unix.go similarity index 99% rename from daemon/config_linux.go rename to daemon/config_unix.go index eb1c125d8c8f1462b0b830436f9198078b30fe01..5fd4934b583e7eb721e5dfc9ffd4a230c4e39917 100644 --- a/daemon/config_linux.go +++ b/daemon/config_unix.go @@ -1,3 +1,5 @@ +// +build linux freebsd + package daemon import ( diff --git a/daemon/container_unix.go b/daemon/container_unix.go index 4bc0c7127975d82e477c210b1692b14a564455af..9126ceae5a7d5c048a5cedc4e4aef24e73d4acd6 100644 --- a/daemon/container_unix.go +++ b/daemon/container_unix.go @@ -1,4 +1,4 @@ -// +build !windows +// +build linux freebsd package daemon diff --git a/daemon/daemon_no_aufs.go b/daemon/daemon_no_aufs.go index 921b39582523ba0b6fc9cf74818461f42f56929f..a74f7753364fc9b00ad8d9fb10b150653dcf0d43 100644 --- a/daemon/daemon_no_aufs.go +++ b/daemon/daemon_no_aufs.go @@ -1,4 +1,4 @@ -// +build exclude_graphdriver_aufs,linux +// +build exclude_graphdriver_aufs,linux freebsd package daemon diff --git a/daemon/daemon_zfs.go b/daemon/daemon_zfs.go index 2fc1d8707e6579928226814f49e9634dd82c0400..d27eff7270745c94c8d032f11e4051fe3c40e08f 100644 --- a/daemon/daemon_zfs.go +++ b/daemon/daemon_zfs.go @@ -1,4 +1,4 @@ -// +build !exclude_graphdriver_zfs,linux +// +build !exclude_graphdriver_zfs,linux !exclude_graphdriver_zfs,freebsd package daemon diff --git a/daemon/exec_freebsd.go b/daemon/exec_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..6f1e5e3c1d0757575aeb4086f623981de3400582 --- /dev/null +++ b/daemon/exec_freebsd.go @@ -0,0 +1,9 @@ +// +build freebsd + +package daemon + +// checkExecSupport returns an error if the exec driver does not support exec, +// or nil if it is supported. +func checkExecSupport(drivername string) error { + return nil +} diff --git a/daemon/execdriver/execdrivers/execdrivers_freebsd.go b/daemon/execdriver/execdrivers/execdrivers_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..ffb463cefd601fd958768cbb7269147af7abba73 --- /dev/null +++ b/daemon/execdriver/execdrivers/execdrivers_freebsd.go @@ -0,0 +1,19 @@ +// +build freebsd + +package execdrivers + +import ( + "fmt" + + "github.com/docker/docker/daemon/execdriver" + "github.com/docker/docker/pkg/sysinfo" +) + +// NewDriver returns a new execdriver.Driver from the given name configured with the provided options. +func NewDriver(name string, options []string, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) { + switch name { + case "jail": + return nil, fmt.Errorf("jail driver not yet supported on FreeBSD") + } + return nil, fmt.Errorf("unknown exec driver %s", name) +} diff --git a/daemon/graphdriver/driver_freebsd.go b/daemon/graphdriver/driver_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..be4eb52653644b74e81e8e5f2243242159a3aed3 --- /dev/null +++ b/daemon/graphdriver/driver_freebsd.go @@ -0,0 +1,8 @@ +package graphdriver + +var ( + // Slice of drivers that should be used in an order + priority = []string{ + "zfs", + } +) diff --git a/daemon/graphdriver/driver_unsupported.go b/daemon/graphdriver/driver_unsupported.go index 3f368648781b13e1eb344ca8b57ade26e9d1f2d5..bb3b5ef74324e46ffde01fbb6aaead0b41fda9dd 100644 --- a/daemon/graphdriver/driver_unsupported.go +++ b/daemon/graphdriver/driver_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows +// +build !linux,!windows,!freebsd package graphdriver diff --git a/daemon/graphdriver/zfs/zfs.go b/daemon/graphdriver/zfs/zfs.go index 664baf1648eb04d40a42794a2ae1d3b8eb7a7dc9..605e14b7cd81ba6c3b47ad2a86ac720701eae438 100644 --- a/daemon/graphdriver/zfs/zfs.go +++ b/daemon/graphdriver/zfs/zfs.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux freebsd package zfs diff --git a/daemon/stats_freebsd.go b/daemon/stats_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..4ec7c657ce617c480148926e09eade6e85fcb4f4 --- /dev/null +++ b/daemon/stats_freebsd.go @@ -0,0 +1,14 @@ +package daemon + +import ( + "github.com/docker/docker/api/types" + "github.com/opencontainers/runc/libcontainer" +) + +// convertStatsToAPITypes converts the libcontainer.Stats to the api specific +// structs. This is done to preserve API compatibility and versioning. +func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats { + // TODO FreeBSD. Refactor accordingly to fill in stats. + s := &types.Stats{} + return s +} diff --git a/daemon/utils_freebsd.go b/daemon/utils_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..1e1ed1b3580fc2608fd122b7ca41a71114c60845 --- /dev/null +++ b/daemon/utils_freebsd.go @@ -0,0 +1,9 @@ +package daemon + +import ( + "github.com/docker/docker/runconfig" +) + +func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) { + return nil, nil +} diff --git a/daemon/utils_unix.go b/daemon/utils_linux.go similarity index 100% rename from daemon/utils_unix.go rename to daemon/utils_linux.go diff --git a/daemon/volumes_linux.go b/daemon/volumes_unix.go similarity index 100% rename from daemon/volumes_linux.go rename to daemon/volumes_unix.go diff --git a/docker/daemon_linux.go b/docker/daemon_linux.go new file mode 100644 index 0000000000000000000000000000000000000000..fd41fe74f80dbfe50299b1c37651210784bbc58b --- /dev/null +++ b/docker/daemon_linux.go @@ -0,0 +1,7 @@ +// +build daemon + +package main + +import ( + _ "github.com/docker/docker/daemon/execdriver/lxc" +) diff --git a/docker/daemon_unix.go b/docker/daemon_unix.go index a2c1a63a62864e26dc439ceb5169f9a00ad1c4b6..beaffc4506bf2aa80886bb717a82ec1e6c7bef96 100644 --- a/docker/daemon_unix.go +++ b/docker/daemon_unix.go @@ -11,7 +11,6 @@ import ( "github.com/docker/docker/daemon" "github.com/docker/docker/pkg/system" - _ "github.com/docker/docker/daemon/execdriver/lxc" _ "github.com/docker/docker/daemon/execdriver/native" ) diff --git a/pkg/directory/directory_linux.go b/pkg/directory/directory_unix.go similarity index 97% rename from pkg/directory/directory_linux.go rename to pkg/directory/directory_unix.go index 80fb9a83321a87f37b2023454ad874a9dbfda32b..dbebdd3c2c648940e946bf15d62bcf01ea7ca7ab 100644 --- a/pkg/directory/directory_linux.go +++ b/pkg/directory/directory_unix.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux freebsd package directory diff --git a/pkg/parsers/operatingsystem/operatingsystem_freebsd.go b/pkg/parsers/operatingsystem/operatingsystem_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..0589cf2ae30d806c034ef7da46e6b6ed2af76015 --- /dev/null +++ b/pkg/parsers/operatingsystem/operatingsystem_freebsd.go @@ -0,0 +1,18 @@ +package operatingsystem + +import ( + "errors" +) + +// GetOperatingSystem gets the name of the current operating system. +func GetOperatingSystem() (string, error) { + // TODO: Implement OS detection + return "", errors.New("Cannot detect OS version") +} + +// IsContainerized returns true if we are running inside a container. +// No-op on FreeBSD, always returns false. +func IsContainerized() (bool, error) { + // TODO: Implement jail detection + return false, errors.New("Cannot detect if we are in container") +} diff --git a/pkg/reexec/command_freebsd.go b/pkg/reexec/command_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..c7f797a5fa5c2fc07d2e6fbce359fc6b7acb098a --- /dev/null +++ b/pkg/reexec/command_freebsd.go @@ -0,0 +1,23 @@ +// +build freebsd + +package reexec + +import ( + "os/exec" +) + +// Self returns the path to the current process's binary. +// Uses os.Args[0]. +func Self() string { + return naiveSelf() +} + +// Command returns *exec.Cmd which have Path as current binary. +// For example if current binary is "docker" at "/usr/bin/", then cmd.Path will +// be set to "/usr/bin/docker". +func Command(args ...string) *exec.Cmd { + return &exec.Cmd{ + Path: Self(), + Args: args, + } +} diff --git a/pkg/reexec/command_unsupported.go b/pkg/reexec/command_unsupported.go index 630eecbd968228d826e35ce3e56b230e3394e8aa..ad4ea38ebbe100d78d407477939155cbc6a92a95 100644 --- a/pkg/reexec/command_unsupported.go +++ b/pkg/reexec/command_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows +// +build !linux,!windows,!freebsd package reexec diff --git a/pkg/sockets/unix_socket.go b/pkg/sockets/unix_socket.go index 42e558eee1004ea62f6fb19adff147e47600d541..a69c28b041d464829c907d40d75dc32ab128c989 100644 --- a/pkg/sockets/unix_socket.go +++ b/pkg/sockets/unix_socket.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux freebsd package sockets diff --git a/pkg/sysinfo/sysinfo_freebsd.go b/pkg/sysinfo/sysinfo_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..25896f9935bb415dfd4f4bb99d9aa4fae190c0df --- /dev/null +++ b/pkg/sysinfo/sysinfo_freebsd.go @@ -0,0 +1,7 @@ +package sysinfo + +// TODO FreeBSD +func New(quiet bool) *SysInfo { + sysInfo := &SysInfo{} + return sysInfo +} diff --git a/pkg/system/stat_freebsd.go b/pkg/system/stat_freebsd.go new file mode 100644 index 0000000000000000000000000000000000000000..4b2198b3aab42adb530d646f41f6fbc9fd7afb5b --- /dev/null +++ b/pkg/system/stat_freebsd.go @@ -0,0 +1,27 @@ +package system + +import ( + "syscall" +) + +// fromStatT converts a syscall.Stat_t type to a system.Stat_t type +func fromStatT(s *syscall.Stat_t) (*Stat_t, error) { + return &Stat_t{size: s.Size, + mode: uint32(s.Mode), + uid: s.Uid, + gid: s.Gid, + rdev: uint64(s.Rdev), + mtim: s.Mtimespec}, nil +} + +// Stat takes a path to a file and returns +// a system.Stat_t type pertaining to that file. +// +// Throws an error if the file does not exist +func Stat(path string) (*Stat_t, error) { + s := &syscall.Stat_t{} + if err := syscall.Stat(path, s); err != nil { + return nil, err + } + return fromStatT(s) +} diff --git a/pkg/system/stat_unsupported.go b/pkg/system/stat_unsupported.go index 7e0d0348fa037e585565ceab5cb2b7c85ce81934..5251ae2129fc591421391b7983a705ddd8006b74 100644 --- a/pkg/system/stat_unsupported.go +++ b/pkg/system/stat_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows +// +build !linux,!windows,!freebsd package system