github.com/ruphin/docker@v1.10.1/daemon/graphdriver/driver_linux.go (about)

     1  // +build linux
     2  
     3  package graphdriver
     4  
     5  import (
     6  	"path/filepath"
     7  	"syscall"
     8  )
     9  
    10  const (
    11  	// FsMagicAufs filesystem id for Aufs
    12  	FsMagicAufs = FsMagic(0x61756673)
    13  	// FsMagicBtrfs filesystem id for Btrfs
    14  	FsMagicBtrfs = FsMagic(0x9123683E)
    15  	// FsMagicCramfs filesystem id for Cramfs
    16  	FsMagicCramfs = FsMagic(0x28cd3d45)
    17  	// FsMagicExtfs filesystem id for Extfs
    18  	FsMagicExtfs = FsMagic(0x0000EF53)
    19  	// FsMagicF2fs filesystem id for F2fs
    20  	FsMagicF2fs = FsMagic(0xF2F52010)
    21  	// FsMagicGPFS filesystem id for GPFS
    22  	FsMagicGPFS = FsMagic(0x47504653)
    23  	// FsMagicJffs2Fs filesystem if for Jffs2Fs
    24  	FsMagicJffs2Fs = FsMagic(0x000072b6)
    25  	// FsMagicJfs filesystem id for Jfs
    26  	FsMagicJfs = FsMagic(0x3153464a)
    27  	// FsMagicNfsFs filesystem id for NfsFs
    28  	FsMagicNfsFs = FsMagic(0x00006969)
    29  	// FsMagicRAMFs filesystem id for RamFs
    30  	FsMagicRAMFs = FsMagic(0x858458f6)
    31  	// FsMagicReiserFs filesystem id for ReiserFs
    32  	FsMagicReiserFs = FsMagic(0x52654973)
    33  	// FsMagicSmbFs filesystem id for SmbFs
    34  	FsMagicSmbFs = FsMagic(0x0000517B)
    35  	// FsMagicSquashFs filesystem id for SquashFs
    36  	FsMagicSquashFs = FsMagic(0x73717368)
    37  	// FsMagicTmpFs filesystem id for TmpFs
    38  	FsMagicTmpFs = FsMagic(0x01021994)
    39  	// FsMagicVxFS filesystem id for VxFs
    40  	FsMagicVxFS = FsMagic(0xa501fcf5)
    41  	// FsMagicXfs filesystem id for Xfs
    42  	FsMagicXfs = FsMagic(0x58465342)
    43  	// FsMagicZfs filesystem id for Zfs
    44  	FsMagicZfs = FsMagic(0x2fc12fc1)
    45  )
    46  
    47  var (
    48  	// Slice of drivers that should be used in an order
    49  	priority = []string{
    50  		"aufs",
    51  		"btrfs",
    52  		"zfs",
    53  		"devicemapper",
    54  		"overlay",
    55  		"vfs",
    56  	}
    57  
    58  	// FsNames maps filesystem id to name of the filesystem.
    59  	FsNames = map[FsMagic]string{
    60  		FsMagicAufs:        "aufs",
    61  		FsMagicBtrfs:       "btrfs",
    62  		FsMagicCramfs:      "cramfs",
    63  		FsMagicExtfs:       "extfs",
    64  		FsMagicF2fs:        "f2fs",
    65  		FsMagicGPFS:        "gpfs",
    66  		FsMagicJffs2Fs:     "jffs2",
    67  		FsMagicJfs:         "jfs",
    68  		FsMagicNfsFs:       "nfs",
    69  		FsMagicRAMFs:       "ramfs",
    70  		FsMagicReiserFs:    "reiserfs",
    71  		FsMagicSmbFs:       "smb",
    72  		FsMagicSquashFs:    "squashfs",
    73  		FsMagicTmpFs:       "tmpfs",
    74  		FsMagicUnsupported: "unsupported",
    75  		FsMagicVxFS:        "vxfs",
    76  		FsMagicXfs:         "xfs",
    77  		FsMagicZfs:         "zfs",
    78  	}
    79  )
    80  
    81  // GetFSMagic returns the filesystem id given the path.
    82  func GetFSMagic(rootpath string) (FsMagic, error) {
    83  	var buf syscall.Statfs_t
    84  	if err := syscall.Statfs(filepath.Dir(rootpath), &buf); err != nil {
    85  		return 0, err
    86  	}
    87  	return FsMagic(buf.Type), nil
    88  }