chiark / gitweb /
cgroup: optionally mount a specific cgroup controllers together, and add cpu+cpuacct...
[elogind.git] / src / util.c
index ecfe450dcac5dd3c8bf33497ec8759b7f2d80cb8..65d4b143dc97cbdae365fe6199ac5eb32be4b576 100644 (file)
@@ -2895,19 +2895,25 @@ ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
         return n;
 }
 
-int path_is_mount_point(const char *t) {
+int path_is_mount_point(const char *t, bool allow_symlink) {
         struct stat a, b;
         char *parent;
         int r;
 
-        if (lstat(t, &a) < 0) {
+        if (allow_symlink)
+                r = stat(t, &a);
+        else
+                r = lstat(t, &a);
+
+        if (r < 0) {
                 if (errno == ENOENT)
                         return 0;
 
                 return -errno;
         }
 
-        if ((r = parent_of_path(t, &parent)) < 0)
+        r = parent_of_path(t, &parent);
+        if (r < 0)
                 return r;
 
         r = lstat(parent, &b);
@@ -3475,7 +3481,7 @@ int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky
                 if (honour_sticky && file_is_sticky(path) > 0)
                         return r;
 
-                if (rmdir(path) < 0) {
+                if (rmdir(path) < 0 && errno != ENOENT) {
                         if (r == 0)
                                 r = -errno;
                 }