The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4099

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Closes #4097.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From d682c03a7d19a689763fa366b2816d9b6b3e54f6 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 13 Dec 2017 16:34:48 +0100
Subject: [PATCH] shared/utils: deal with symlinks

Closes #4097.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 shared/util_linux.go | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/shared/util_linux.go b/shared/util_linux.go
index 78d782924..75b3a2678 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -336,6 +336,15 @@ func GetFileStat(p string) (uid int, gid int, major int, 
minor int,
 }
 
 func parseMountinfo(name string) int {
+       // In case someone uses symlinks we need to look for the actual
+       // mountpoint.
+       actualPath, err := filepath.EvalSymlinks(name)
+       if err != nil {
+               return -1
+       }
+
+       logger.Debugf("Path \"%s\" is pointing to \"%s\"", name, actualPath)
+
        f, err := os.Open("/proc/self/mountinfo")
        if err != nil {
                return -1
@@ -350,8 +359,7 @@ func parseMountinfo(name string) int {
                        return -1
                }
                cleanPath := filepath.Clean(tokens[4])
-               cleanName := filepath.Clean(name)
-               if cleanPath == cleanName {
+               if cleanPath == actualPath {
                        return 1
                }
        }
@@ -361,8 +369,9 @@ func parseMountinfo(name string) int {
 
 func IsMountPoint(name string) bool {
        ret := parseMountinfo(name)
-       if ret >= 0 {
-               return (ret == 1)
+       if ret == 1 {
+               logger.Debugf("Detected that \"%s\" is a mountpoint", name)
+               return true
        }
 
        stat, err := os.Stat(name)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to