commit
0f137226d8
|
@ -24,23 +24,23 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/mount",
|
"ImportPath": "github.com/docker/docker/pkg/mount",
|
||||||
"Comment": "v1.4.1-4127-gb81f2ee",
|
"Comment": "v1.4.1-4831-g0f5c9d3",
|
||||||
"Rev": "b81f2ee5f20d094c13893f565ce716595c539d22"
|
"Rev": "0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/symlink",
|
"ImportPath": "github.com/docker/docker/pkg/symlink",
|
||||||
"Comment": "v1.4.1-4127-gb81f2ee",
|
"Comment": "v1.4.1-4831-g0f5c9d3",
|
||||||
"Rev": "b81f2ee5f20d094c13893f565ce716595c539d22"
|
"Rev": "0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/term",
|
"ImportPath": "github.com/docker/docker/pkg/term",
|
||||||
"Comment": "v1.4.1-4127-gb81f2ee",
|
"Comment": "v1.4.1-4831-g0f5c9d3",
|
||||||
"Rev": "b81f2ee5f20d094c13893f565ce716595c539d22"
|
"Rev": "0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/docker/docker/pkg/units",
|
"ImportPath": "github.com/docker/docker/pkg/units",
|
||||||
"Comment": "v1.4.1-4127-gb81f2ee",
|
"Comment": "v1.4.1-4831-g0f5c9d3",
|
||||||
"Rev": "b81f2ee5f20d094c13893f565ce716595c539d22"
|
"Rev": "0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/godbus/dbus",
|
"ImportPath": "github.com/godbus/dbus",
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetMounts retrieves a list of mounts for the current running process.
|
// GetMounts retrieves a list of mounts for the current running process.
|
||||||
func GetMounts() ([]*MountInfo, error) {
|
func GetMounts() ([]*Info, error) {
|
||||||
return parseMountTable()
|
return parseMountTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package mount
|
package mount
|
||||||
|
|
||||||
// MountInfo reveals information about a particular mounted filesystem. This
|
// Info reveals information about a particular mounted filesystem. This
|
||||||
// struct is populated from the content in the /proc/<pid>/mountinfo file.
|
// struct is populated from the content in the /proc/<pid>/mountinfo file.
|
||||||
type MountInfo struct {
|
type Info struct {
|
||||||
// Id is a unique identifier of the mount (may be reused after umount).
|
// ID is a unique identifier of the mount (may be reused after umount).
|
||||||
Id int
|
ID int
|
||||||
|
|
||||||
// Parent indicates the ID of the mount parent (or of self for the top of the
|
// Parent indicates the ID of the mount parent (or of self for the top of the
|
||||||
// mount tree).
|
// mount tree).
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
|
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
|
||||||
// bind mounts.
|
// bind mounts.
|
||||||
func parseMountTable() ([]*MountInfo, error) {
|
func parseMountTable() ([]*Info, error) {
|
||||||
var rawEntries *C.struct_statfs
|
var rawEntries *C.struct_statfs
|
||||||
|
|
||||||
count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
|
count := int(C.getmntinfo(&rawEntries, C.MNT_WAIT))
|
||||||
|
@ -29,9 +29,9 @@ func parseMountTable() ([]*MountInfo, error) {
|
||||||
header.Len = count
|
header.Len = count
|
||||||
header.Data = uintptr(unsafe.Pointer(rawEntries))
|
header.Data = uintptr(unsafe.Pointer(rawEntries))
|
||||||
|
|
||||||
var out []*MountInfo
|
var out []*Info
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
var mountinfo MountInfo
|
var mountinfo Info
|
||||||
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0])
|
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0])
|
||||||
mountinfo.Source = C.GoString(&entry.f_mntfromname[0])
|
mountinfo.Source = C.GoString(&entry.f_mntfromname[0])
|
||||||
mountinfo.Fstype = C.GoString(&entry.f_fstypename[0])
|
mountinfo.Fstype = C.GoString(&entry.f_fstypename[0])
|
||||||
|
|
|
@ -30,7 +30,7 @@ const (
|
||||||
|
|
||||||
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
|
// Parse /proc/self/mountinfo because comparing Dev and ino does not work from
|
||||||
// bind mounts
|
// bind mounts
|
||||||
func parseMountTable() ([]*MountInfo, error) {
|
func parseMountTable() ([]*Info, error) {
|
||||||
f, err := os.Open("/proc/self/mountinfo")
|
f, err := os.Open("/proc/self/mountinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -40,10 +40,10 @@ func parseMountTable() ([]*MountInfo, error) {
|
||||||
return parseInfoFile(f)
|
return parseInfoFile(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
func parseInfoFile(r io.Reader) ([]*Info, error) {
|
||||||
var (
|
var (
|
||||||
s = bufio.NewScanner(r)
|
s = bufio.NewScanner(r)
|
||||||
out = []*MountInfo{}
|
out = []*Info{}
|
||||||
)
|
)
|
||||||
|
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
|
@ -52,13 +52,13 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
p = &MountInfo{}
|
p = &Info{}
|
||||||
text = s.Text()
|
text = s.Text()
|
||||||
optionalFields string
|
optionalFields string
|
||||||
)
|
)
|
||||||
|
|
||||||
if _, err := fmt.Sscanf(text, mountinfoFormat,
|
if _, err := fmt.Sscanf(text, mountinfoFormat,
|
||||||
&p.Id, &p.Parent, &p.Major, &p.Minor,
|
&p.ID, &p.Parent, &p.Major, &p.Minor,
|
||||||
&p.Root, &p.Mountpoint, &p.Opts, &optionalFields); err != nil {
|
&p.Root, &p.Mountpoint, &p.Opts, &optionalFields); err != nil {
|
||||||
return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
return nil, fmt.Errorf("Scanning '%s' failed: %s", text, err)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func parseInfoFile(r io.Reader) ([]*MountInfo, error) {
|
||||||
// PidMountInfo collects the mounts for a specific process ID. If the process
|
// PidMountInfo collects the mounts for a specific process ID. If the process
|
||||||
// ID is unknown, it is better to use `GetMounts` which will inspect
|
// ID is unknown, it is better to use `GetMounts` which will inspect
|
||||||
// "/proc/self/mountinfo" instead.
|
// "/proc/self/mountinfo" instead.
|
||||||
func PidMountInfo(pid int) ([]*MountInfo, error) {
|
func PidMountInfo(pid int) ([]*Info, error) {
|
||||||
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
|
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
4
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_linux_test.go
generated
vendored
4
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_linux_test.go
generated
vendored
|
@ -457,8 +457,8 @@ func TestParseFedoraMountinfoFields(t *testing.T) {
|
||||||
if len(infos) != expectedLength {
|
if len(infos) != expectedLength {
|
||||||
t.Fatalf("Expected %d entries, got %d", expectedLength, len(infos))
|
t.Fatalf("Expected %d entries, got %d", expectedLength, len(infos))
|
||||||
}
|
}
|
||||||
mi := MountInfo{
|
mi := Info{
|
||||||
Id: 15,
|
ID: 15,
|
||||||
Parent: 35,
|
Parent: 35,
|
||||||
Major: 0,
|
Major: 0,
|
||||||
Minor: 3,
|
Minor: 3,
|
||||||
|
|
2
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go
generated
vendored
2
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go
generated
vendored
|
@ -7,6 +7,6 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseMountTable() ([]*MountInfo, error) {
|
func parseMountTable() ([]*Info, error) {
|
||||||
return nil, fmt.Errorf("mount.parseMountTable is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
|
return nil, fmt.Errorf("mount.parseMountTable is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
|
||||||
}
|
}
|
||||||
|
|
2
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/sharedsubtree_linux_test.go
generated
vendored
2
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/sharedsubtree_linux_test.go
generated
vendored
|
@ -107,7 +107,7 @@ func TestSubtreePrivate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing that when a target is a shared mount,
|
// Testing that when a target is a shared mount,
|
||||||
// then child mounts propogate to the source
|
// then child mounts propagate to the source
|
||||||
func TestSubtreeShared(t *testing.T) {
|
func TestSubtreeShared(t *testing.T) {
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
tmp := path.Join(os.TempDir(), "mount-tests")
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
if err := os.MkdirAll(tmp, 0777); err != nil {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package term
|
package term
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -51,7 +51,7 @@ func CustomSize(format string, size float64, base float64, _map []string) string
|
||||||
// HumanSize returns a human-readable approximation of a size
|
// HumanSize returns a human-readable approximation of a size
|
||||||
// using SI standard (eg. "44kB", "17MB")
|
// using SI standard (eg. "44kB", "17MB")
|
||||||
func HumanSize(size float64) string {
|
func HumanSize(size float64) string {
|
||||||
return CustomSize("%.4g %s", float64(size), 1000.0, decimapAbbrs)
|
return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BytesSize(size float64) string {
|
func BytesSize(size float64) string {
|
||||||
|
|
|
@ -421,7 +421,7 @@ func mknodDevice(dest string, node *configs.Device) error {
|
||||||
return syscall.Chown(dest, int(node.Uid), int(node.Gid))
|
return syscall.Chown(dest, int(node.Uid), int(node.Gid))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMountInfo(mountinfo []*mount.MountInfo, dir string) *mount.MountInfo {
|
func getMountInfo(mountinfo []*mount.Info, dir string) *mount.Info {
|
||||||
for _, m := range mountinfo {
|
for _, m := range mountinfo {
|
||||||
if m.Mountpoint == dir {
|
if m.Mountpoint == dir {
|
||||||
return m
|
return m
|
||||||
|
|
Loading…
Reference in New Issue