chiark / gitweb /
Get rid of some more unused defines and dirs
[elogind.git] / src / shared / mkdir.c
index fabd9e215ec3cc7779836b65a9f9cee213e0c896..7ee4546988b353aef2f1fb4f95dcda635e49bdf1 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <assert.h>
 #include <string.h>
 #include <string.h>
-#include <unistd.h>
 #include <errno.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
 
 
-#include "label.h"
 #include "util.h"
 #include "path-util.h"
 #include "mkdir.h"
 #include "util.h"
 #include "path-util.h"
 #include "mkdir.h"
@@ -44,12 +39,10 @@ int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkd
         if ((st.st_mode & 0007) > (mode & 0007) ||
             (st.st_mode & 0070) > (mode & 0070) ||
             (st.st_mode & 0700) > (mode & 0700) ||
         if ((st.st_mode & 0007) > (mode & 0007) ||
             (st.st_mode & 0070) > (mode & 0070) ||
             (st.st_mode & 0700) > (mode & 0700) ||
-            (uid != (uid_t) -1 && st.st_uid != uid) ||
-            (gid != (gid_t) -1 && st.st_gid != gid) ||
-            !S_ISDIR(st.st_mode)) {
-                errno = EEXIST;
-                return -errno;
-        }
+            (uid != UID_INVALID && st.st_uid != uid) ||
+            (gid != GID_INVALID && st.st_gid != gid) ||
+            !S_ISDIR(st.st_mode))
+                return -EEXIST;
 
         return 0;
 }
 
         return 0;
 }
@@ -58,20 +51,6 @@ int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
         return mkdir_safe_internal(path, mode, uid, gid, mkdir);
 }
 
         return mkdir_safe_internal(path, mode, uid, gid, mkdir);
 }
 
-int is_dir(const char* path, bool follow) {
-        struct stat st;
-
-        if (follow) {
-                if (stat(path, &st) < 0)
-                        return -errno;
-        } else {
-                if (lstat(path, &st) < 0)
-                        return -errno;
-        }
-
-        return S_ISDIR(st.st_mode);
-}
-
 int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir) {
         const char *p, *e;
         int r;
 int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir) {
         const char *p, *e;
         int r;