aufs.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. // +build linux
  2. /*
  3. aufs driver directory structure
  4. .
  5. ├── layers // Metadata of layers
  6. │ ├── 1
  7. │ ├── 2
  8. │ └── 3
  9. ├── diff // Content of the layer
  10. │ ├── 1 // Contains layers that need to be mounted for the id
  11. │ ├── 2
  12. │ └── 3
  13. └── mnt // Mount points for the rw layers to be mounted
  14. ├── 1
  15. ├── 2
  16. └── 3
  17. */
  18. package aufs
  19. import (
  20. "bufio"
  21. "fmt"
  22. "io"
  23. "io/ioutil"
  24. "os"
  25. "os/exec"
  26. "path"
  27. "path/filepath"
  28. "strings"
  29. "sync"
  30. "time"
  31. "github.com/docker/docker/daemon/graphdriver"
  32. "github.com/docker/docker/pkg/archive"
  33. "github.com/docker/docker/pkg/chrootarchive"
  34. "github.com/docker/docker/pkg/containerfs"
  35. "github.com/docker/docker/pkg/directory"
  36. "github.com/docker/docker/pkg/idtools"
  37. "github.com/docker/docker/pkg/locker"
  38. mountpk "github.com/docker/docker/pkg/mount"
  39. "github.com/docker/docker/pkg/system"
  40. rsystem "github.com/opencontainers/runc/libcontainer/system"
  41. "github.com/opencontainers/selinux/go-selinux/label"
  42. "github.com/pkg/errors"
  43. "github.com/sirupsen/logrus"
  44. "github.com/vbatts/tar-split/tar/storage"
  45. "golang.org/x/sys/unix"
  46. )
  47. var (
  48. // ErrAufsNotSupported is returned if aufs is not supported by the host.
  49. ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems")
  50. // ErrAufsNested means aufs cannot be used bc we are in a user namespace
  51. ErrAufsNested = fmt.Errorf("AUFS cannot be used in non-init user namespace")
  52. backingFs = "<unknown>"
  53. enableDirpermLock sync.Once
  54. enableDirperm bool
  55. )
  56. func init() {
  57. graphdriver.Register("aufs", Init)
  58. }
  59. // Driver contains information about the filesystem mounted.
  60. type Driver struct {
  61. sync.Mutex
  62. root string
  63. uidMaps []idtools.IDMap
  64. gidMaps []idtools.IDMap
  65. ctr *graphdriver.RefCounter
  66. pathCacheLock sync.Mutex
  67. pathCache map[string]string
  68. naiveDiff graphdriver.DiffDriver
  69. locker *locker.Locker
  70. }
  71. // Init returns a new AUFS driver.
  72. // An error is returned if AUFS is not supported.
  73. func Init(root string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) {
  74. // Try to load the aufs kernel module
  75. if err := supportsAufs(); err != nil {
  76. return nil, graphdriver.ErrNotSupported
  77. }
  78. // Perform feature detection on /var/lib/docker/aufs if it's an existing directory.
  79. // This covers situations where /var/lib/docker/aufs is a mount, and on a different
  80. // filesystem than /var/lib/docker.
  81. // If the path does not exist, fall back to using /var/lib/docker for feature detection.
  82. testdir := root
  83. if _, err := os.Stat(testdir); os.IsNotExist(err) {
  84. testdir = filepath.Dir(testdir)
  85. }
  86. fsMagic, err := graphdriver.GetFSMagic(testdir)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if fsName, ok := graphdriver.FsNames[fsMagic]; ok {
  91. backingFs = fsName
  92. }
  93. switch fsMagic {
  94. case graphdriver.FsMagicAufs, graphdriver.FsMagicBtrfs, graphdriver.FsMagicEcryptfs:
  95. logrus.Errorf("AUFS is not supported over %s", backingFs)
  96. return nil, graphdriver.ErrIncompatibleFS
  97. }
  98. paths := []string{
  99. "mnt",
  100. "diff",
  101. "layers",
  102. }
  103. a := &Driver{
  104. root: root,
  105. uidMaps: uidMaps,
  106. gidMaps: gidMaps,
  107. pathCache: make(map[string]string),
  108. ctr: graphdriver.NewRefCounter(graphdriver.NewFsChecker(graphdriver.FsMagicAufs)),
  109. locker: locker.New(),
  110. }
  111. rootUID, rootGID, err := idtools.GetRootUIDGID(uidMaps, gidMaps)
  112. if err != nil {
  113. return nil, err
  114. }
  115. // Create the root aufs driver dir
  116. if err := idtools.MkdirAllAndChown(root, 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil {
  117. return nil, err
  118. }
  119. if err := mountpk.MakePrivate(root); err != nil {
  120. return nil, err
  121. }
  122. // Populate the dir structure
  123. for _, p := range paths {
  124. if err := idtools.MkdirAllAndChown(path.Join(root, p), 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil {
  125. return nil, err
  126. }
  127. }
  128. logger := logrus.WithFields(logrus.Fields{
  129. "module": "graphdriver",
  130. "driver": "aufs",
  131. })
  132. for _, path := range []string{"mnt", "diff"} {
  133. p := filepath.Join(root, path)
  134. entries, err := ioutil.ReadDir(p)
  135. if err != nil {
  136. logger.WithError(err).WithField("dir", p).Error("error reading dir entries")
  137. continue
  138. }
  139. for _, entry := range entries {
  140. if !entry.IsDir() {
  141. continue
  142. }
  143. if strings.HasSuffix(entry.Name(), "-removing") {
  144. logger.WithField("dir", entry.Name()).Debug("Cleaning up stale layer dir")
  145. if err := system.EnsureRemoveAll(filepath.Join(p, entry.Name())); err != nil {
  146. logger.WithField("dir", entry.Name()).WithError(err).Error("Error removing stale layer dir")
  147. }
  148. }
  149. }
  150. }
  151. a.naiveDiff = graphdriver.NewNaiveDiffDriver(a, uidMaps, gidMaps)
  152. return a, nil
  153. }
  154. // Return a nil error if the kernel supports aufs
  155. // We cannot modprobe because inside dind modprobe fails
  156. // to run
  157. func supportsAufs() error {
  158. // We can try to modprobe aufs first before looking at
  159. // proc/filesystems for when aufs is supported
  160. exec.Command("modprobe", "aufs").Run()
  161. if rsystem.RunningInUserNS() {
  162. return ErrAufsNested
  163. }
  164. f, err := os.Open("/proc/filesystems")
  165. if err != nil {
  166. return err
  167. }
  168. defer f.Close()
  169. s := bufio.NewScanner(f)
  170. for s.Scan() {
  171. if strings.Contains(s.Text(), "aufs") {
  172. return nil
  173. }
  174. }
  175. return ErrAufsNotSupported
  176. }
  177. func (a *Driver) rootPath() string {
  178. return a.root
  179. }
  180. func (*Driver) String() string {
  181. return "aufs"
  182. }
  183. // Status returns current information about the filesystem such as root directory, number of directories mounted, etc.
  184. func (a *Driver) Status() [][2]string {
  185. ids, _ := loadIds(path.Join(a.rootPath(), "layers"))
  186. return [][2]string{
  187. {"Root Dir", a.rootPath()},
  188. {"Backing Filesystem", backingFs},
  189. {"Dirs", fmt.Sprintf("%d", len(ids))},
  190. {"Dirperm1 Supported", fmt.Sprintf("%v", useDirperm())},
  191. }
  192. }
  193. // GetMetadata not implemented
  194. func (a *Driver) GetMetadata(id string) (map[string]string, error) {
  195. return nil, nil
  196. }
  197. // Exists returns true if the given id is registered with
  198. // this driver
  199. func (a *Driver) Exists(id string) bool {
  200. if _, err := os.Lstat(path.Join(a.rootPath(), "layers", id)); err != nil {
  201. return false
  202. }
  203. return true
  204. }
  205. // CreateReadWrite creates a layer that is writable for use as a container
  206. // file system.
  207. func (a *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts) error {
  208. return a.Create(id, parent, opts)
  209. }
  210. // Create three folders for each id
  211. // mnt, layers, and diff
  212. func (a *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
  213. if opts != nil && len(opts.StorageOpt) != 0 {
  214. return fmt.Errorf("--storage-opt is not supported for aufs")
  215. }
  216. if err := a.createDirsFor(id); err != nil {
  217. return err
  218. }
  219. // Write the layers metadata
  220. f, err := os.Create(path.Join(a.rootPath(), "layers", id))
  221. if err != nil {
  222. return err
  223. }
  224. defer f.Close()
  225. if parent != "" {
  226. ids, err := getParentIDs(a.rootPath(), parent)
  227. if err != nil {
  228. return err
  229. }
  230. if _, err := fmt.Fprintln(f, parent); err != nil {
  231. return err
  232. }
  233. for _, i := range ids {
  234. if _, err := fmt.Fprintln(f, i); err != nil {
  235. return err
  236. }
  237. }
  238. }
  239. return nil
  240. }
  241. // createDirsFor creates two directories for the given id.
  242. // mnt and diff
  243. func (a *Driver) createDirsFor(id string) error {
  244. paths := []string{
  245. "mnt",
  246. "diff",
  247. }
  248. rootUID, rootGID, err := idtools.GetRootUIDGID(a.uidMaps, a.gidMaps)
  249. if err != nil {
  250. return err
  251. }
  252. // Directory permission is 0755.
  253. // The path of directories are <aufs_root_path>/mnt/<image_id>
  254. // and <aufs_root_path>/diff/<image_id>
  255. for _, p := range paths {
  256. if err := idtools.MkdirAllAndChown(path.Join(a.rootPath(), p, id), 0755, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil {
  257. return err
  258. }
  259. }
  260. return nil
  261. }
  262. // Remove will unmount and remove the given id.
  263. func (a *Driver) Remove(id string) error {
  264. a.locker.Lock(id)
  265. defer a.locker.Unlock(id)
  266. a.pathCacheLock.Lock()
  267. mountpoint, exists := a.pathCache[id]
  268. a.pathCacheLock.Unlock()
  269. if !exists {
  270. mountpoint = a.getMountpoint(id)
  271. }
  272. logger := logrus.WithFields(logrus.Fields{
  273. "module": "graphdriver",
  274. "driver": "aufs",
  275. "layer": id,
  276. })
  277. var retries int
  278. for {
  279. mounted, err := a.mounted(mountpoint)
  280. if err != nil {
  281. if os.IsNotExist(err) {
  282. break
  283. }
  284. return err
  285. }
  286. if !mounted {
  287. break
  288. }
  289. err = a.unmount(mountpoint)
  290. if err == nil {
  291. break
  292. }
  293. if err != unix.EBUSY {
  294. return errors.Wrapf(err, "aufs: unmount error: %s", mountpoint)
  295. }
  296. if retries >= 5 {
  297. return errors.Wrapf(err, "aufs: unmount error after retries: %s", mountpoint)
  298. }
  299. // If unmount returns EBUSY, it could be a transient error. Sleep and retry.
  300. retries++
  301. logger.Warnf("unmount failed due to EBUSY: retry count: %d", retries)
  302. time.Sleep(100 * time.Millisecond)
  303. }
  304. // Remove the layers file for the id
  305. if err := os.Remove(path.Join(a.rootPath(), "layers", id)); err != nil && !os.IsNotExist(err) {
  306. return errors.Wrapf(err, "error removing layers dir for %s", id)
  307. }
  308. if err := atomicRemove(a.getDiffPath(id)); err != nil {
  309. return errors.Wrapf(err, "could not remove diff path for id %s", id)
  310. }
  311. // Atomically remove each directory in turn by first moving it out of the
  312. // way (so that docker doesn't find it anymore) before doing removal of
  313. // the whole tree.
  314. if err := atomicRemove(mountpoint); err != nil {
  315. if errors.Cause(err) == unix.EBUSY {
  316. logger.WithField("dir", mountpoint).WithError(err).Warn("error performing atomic remove due to EBUSY")
  317. }
  318. return errors.Wrapf(err, "could not remove mountpoint for id %s", id)
  319. }
  320. a.pathCacheLock.Lock()
  321. delete(a.pathCache, id)
  322. a.pathCacheLock.Unlock()
  323. return nil
  324. }
  325. func atomicRemove(source string) error {
  326. target := source + "-removing"
  327. err := os.Rename(source, target)
  328. switch {
  329. case err == nil, os.IsNotExist(err):
  330. case os.IsExist(err):
  331. // Got error saying the target dir already exists, maybe the source doesn't exist due to a previous (failed) remove
  332. if _, e := os.Stat(source); !os.IsNotExist(e) {
  333. return errors.Wrapf(err, "target rename dir '%s' exists but should not, this needs to be manually cleaned up")
  334. }
  335. default:
  336. return errors.Wrapf(err, "error preparing atomic delete")
  337. }
  338. return system.EnsureRemoveAll(target)
  339. }
  340. // Get returns the rootfs path for the id.
  341. // This will mount the dir at its given path
  342. func (a *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
  343. a.locker.Lock(id)
  344. defer a.locker.Unlock(id)
  345. parents, err := a.getParentLayerPaths(id)
  346. if err != nil && !os.IsNotExist(err) {
  347. return nil, err
  348. }
  349. a.pathCacheLock.Lock()
  350. m, exists := a.pathCache[id]
  351. a.pathCacheLock.Unlock()
  352. if !exists {
  353. m = a.getDiffPath(id)
  354. if len(parents) > 0 {
  355. m = a.getMountpoint(id)
  356. }
  357. }
  358. if count := a.ctr.Increment(m); count > 1 {
  359. return containerfs.NewLocalContainerFS(m), nil
  360. }
  361. // If a dir does not have a parent ( no layers )do not try to mount
  362. // just return the diff path to the data
  363. if len(parents) > 0 {
  364. if err := a.mount(id, m, mountLabel, parents); err != nil {
  365. return nil, err
  366. }
  367. }
  368. a.pathCacheLock.Lock()
  369. a.pathCache[id] = m
  370. a.pathCacheLock.Unlock()
  371. return containerfs.NewLocalContainerFS(m), nil
  372. }
  373. // Put unmounts and updates list of active mounts.
  374. func (a *Driver) Put(id string) error {
  375. a.locker.Lock(id)
  376. defer a.locker.Unlock(id)
  377. a.pathCacheLock.Lock()
  378. m, exists := a.pathCache[id]
  379. if !exists {
  380. m = a.getMountpoint(id)
  381. a.pathCache[id] = m
  382. }
  383. a.pathCacheLock.Unlock()
  384. if count := a.ctr.Decrement(m); count > 0 {
  385. return nil
  386. }
  387. err := a.unmount(m)
  388. if err != nil {
  389. logrus.Debugf("Failed to unmount %s aufs: %v", id, err)
  390. }
  391. return err
  392. }
  393. // isParent returns if the passed in parent is the direct parent of the passed in layer
  394. func (a *Driver) isParent(id, parent string) bool {
  395. parents, _ := getParentIDs(a.rootPath(), id)
  396. if parent == "" && len(parents) > 0 {
  397. return false
  398. }
  399. return !(len(parents) > 0 && parent != parents[0])
  400. }
  401. // Diff produces an archive of the changes between the specified
  402. // layer and its parent layer which may be "".
  403. func (a *Driver) Diff(id, parent string) (io.ReadCloser, error) {
  404. if !a.isParent(id, parent) {
  405. return a.naiveDiff.Diff(id, parent)
  406. }
  407. // AUFS doesn't need the parent layer to produce a diff.
  408. return archive.TarWithOptions(path.Join(a.rootPath(), "diff", id), &archive.TarOptions{
  409. Compression: archive.Uncompressed,
  410. ExcludePatterns: []string{archive.WhiteoutMetaPrefix + "*", "!" + archive.WhiteoutOpaqueDir},
  411. UIDMaps: a.uidMaps,
  412. GIDMaps: a.gidMaps,
  413. })
  414. }
  415. type fileGetNilCloser struct {
  416. storage.FileGetter
  417. }
  418. func (f fileGetNilCloser) Close() error {
  419. return nil
  420. }
  421. // DiffGetter returns a FileGetCloser that can read files from the directory that
  422. // contains files for the layer differences. Used for direct access for tar-split.
  423. func (a *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
  424. p := path.Join(a.rootPath(), "diff", id)
  425. return fileGetNilCloser{storage.NewPathFileGetter(p)}, nil
  426. }
  427. func (a *Driver) applyDiff(id string, diff io.Reader) error {
  428. return chrootarchive.UntarUncompressed(diff, path.Join(a.rootPath(), "diff", id), &archive.TarOptions{
  429. UIDMaps: a.uidMaps,
  430. GIDMaps: a.gidMaps,
  431. })
  432. }
  433. // DiffSize calculates the changes between the specified id
  434. // and its parent and returns the size in bytes of the changes
  435. // relative to its base filesystem directory.
  436. func (a *Driver) DiffSize(id, parent string) (size int64, err error) {
  437. if !a.isParent(id, parent) {
  438. return a.naiveDiff.DiffSize(id, parent)
  439. }
  440. // AUFS doesn't need the parent layer to calculate the diff size.
  441. return directory.Size(path.Join(a.rootPath(), "diff", id))
  442. }
  443. // ApplyDiff extracts the changeset from the given diff into the
  444. // layer with the specified id and parent, returning the size of the
  445. // new layer in bytes.
  446. func (a *Driver) ApplyDiff(id, parent string, diff io.Reader) (size int64, err error) {
  447. if !a.isParent(id, parent) {
  448. return a.naiveDiff.ApplyDiff(id, parent, diff)
  449. }
  450. // AUFS doesn't need the parent id to apply the diff if it is the direct parent.
  451. if err = a.applyDiff(id, diff); err != nil {
  452. return
  453. }
  454. return a.DiffSize(id, parent)
  455. }
  456. // Changes produces a list of changes between the specified layer
  457. // and its parent layer. If parent is "", then all changes will be ADD changes.
  458. func (a *Driver) Changes(id, parent string) ([]archive.Change, error) {
  459. if !a.isParent(id, parent) {
  460. return a.naiveDiff.Changes(id, parent)
  461. }
  462. // AUFS doesn't have snapshots, so we need to get changes from all parent
  463. // layers.
  464. layers, err := a.getParentLayerPaths(id)
  465. if err != nil {
  466. return nil, err
  467. }
  468. return archive.Changes(layers, path.Join(a.rootPath(), "diff", id))
  469. }
  470. func (a *Driver) getParentLayerPaths(id string) ([]string, error) {
  471. parentIds, err := getParentIDs(a.rootPath(), id)
  472. if err != nil {
  473. return nil, err
  474. }
  475. layers := make([]string, len(parentIds))
  476. // Get the diff paths for all the parent ids
  477. for i, p := range parentIds {
  478. layers[i] = path.Join(a.rootPath(), "diff", p)
  479. }
  480. return layers, nil
  481. }
  482. func (a *Driver) mount(id string, target string, mountLabel string, layers []string) error {
  483. a.Lock()
  484. defer a.Unlock()
  485. // If the id is mounted or we get an error return
  486. if mounted, err := a.mounted(target); err != nil || mounted {
  487. return err
  488. }
  489. rw := a.getDiffPath(id)
  490. if err := a.aufsMount(layers, rw, target, mountLabel); err != nil {
  491. return fmt.Errorf("error creating aufs mount to %s: %v", target, err)
  492. }
  493. return nil
  494. }
  495. func (a *Driver) unmount(mountPath string) error {
  496. a.Lock()
  497. defer a.Unlock()
  498. if mounted, err := a.mounted(mountPath); err != nil || !mounted {
  499. return err
  500. }
  501. return Unmount(mountPath)
  502. }
  503. func (a *Driver) mounted(mountpoint string) (bool, error) {
  504. return graphdriver.Mounted(graphdriver.FsMagicAufs, mountpoint)
  505. }
  506. // Cleanup aufs and unmount all mountpoints
  507. func (a *Driver) Cleanup() error {
  508. var dirs []string
  509. if err := filepath.Walk(a.mntPath(), func(path string, info os.FileInfo, err error) error {
  510. if err != nil {
  511. return err
  512. }
  513. if !info.IsDir() {
  514. return nil
  515. }
  516. dirs = append(dirs, path)
  517. return nil
  518. }); err != nil {
  519. return err
  520. }
  521. for _, m := range dirs {
  522. if err := a.unmount(m); err != nil {
  523. logrus.Debugf("aufs error unmounting %s: %s", m, err)
  524. }
  525. }
  526. return mountpk.Unmount(a.root)
  527. }
  528. func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err error) {
  529. defer func() {
  530. if err != nil {
  531. Unmount(target)
  532. }
  533. }()
  534. // Mount options are clipped to page size(4096 bytes). If there are more
  535. // layers then these are remounted individually using append.
  536. offset := 54
  537. if useDirperm() {
  538. offset += len(",dirperm1")
  539. }
  540. b := make([]byte, unix.Getpagesize()-len(mountLabel)-offset) // room for xino & mountLabel
  541. bp := copy(b, fmt.Sprintf("br:%s=rw", rw))
  542. index := 0
  543. for ; index < len(ro); index++ {
  544. layer := fmt.Sprintf(":%s=ro+wh", ro[index])
  545. if bp+len(layer) > len(b) {
  546. break
  547. }
  548. bp += copy(b[bp:], layer)
  549. }
  550. opts := "dio,xino=/dev/shm/aufs.xino"
  551. if useDirperm() {
  552. opts += ",dirperm1"
  553. }
  554. data := label.FormatMountLabel(fmt.Sprintf("%s,%s", string(b[:bp]), opts), mountLabel)
  555. if err = mount("none", target, "aufs", 0, data); err != nil {
  556. return
  557. }
  558. for ; index < len(ro); index++ {
  559. layer := fmt.Sprintf(":%s=ro+wh", ro[index])
  560. data := label.FormatMountLabel(fmt.Sprintf("append%s", layer), mountLabel)
  561. if err = mount("none", target, "aufs", unix.MS_REMOUNT, data); err != nil {
  562. return
  563. }
  564. }
  565. return
  566. }
  567. // useDirperm checks dirperm1 mount option can be used with the current
  568. // version of aufs.
  569. func useDirperm() bool {
  570. enableDirpermLock.Do(func() {
  571. base, err := ioutil.TempDir("", "docker-aufs-base")
  572. if err != nil {
  573. logrus.Errorf("error checking dirperm1: %v", err)
  574. return
  575. }
  576. defer os.RemoveAll(base)
  577. union, err := ioutil.TempDir("", "docker-aufs-union")
  578. if err != nil {
  579. logrus.Errorf("error checking dirperm1: %v", err)
  580. return
  581. }
  582. defer os.RemoveAll(union)
  583. opts := fmt.Sprintf("br:%s,dirperm1,xino=/dev/shm/aufs.xino", base)
  584. if err := mount("none", union, "aufs", 0, opts); err != nil {
  585. return
  586. }
  587. enableDirperm = true
  588. if err := Unmount(union); err != nil {
  589. logrus.Errorf("error checking dirperm1: failed to unmount %v", err)
  590. }
  591. })
  592. return enableDirperm
  593. }