]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
unit: move unit_warn_if_dir_nonempty() and friend to unit.c
authorLennart Poettering <lennart@poettering.net>
Mon, 11 May 2015 20:28:52 +0000 (22:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 May 2015 20:28:52 +0000 (22:28 +0200)
The call is only used by the mount and automount unit types, but that's
already enough to consider it generic unit functionality, hence move it
out of mount.c and into unit.c.

src/core/mount.c
src/core/mount.h
src/core/unit.c
src/core/unit.h

index 155cd2df1d45bba3105cf2acf8ff212586d9cc56..6501be96dbeb18dedfb6819ddda8c7a2e75d87d4 100644 (file)
@@ -812,52 +812,6 @@ fail:
                 mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
 }
 
-void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
-        int r;
-
-        assert(u);
-        assert(where);
-
-        r = dir_is_empty(where);
-        if (r > 0)
-                return;
-        if (r < 0) {
-                log_unit_warning_errno(u, r, "Failed to check directory %s: %m", where);
-                return;
-        }
-
-        log_struct(LOG_NOTICE,
-                   LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
-                   LOG_UNIT_ID(u),
-                   LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
-                   "WHERE=%s", where,
-                   NULL);
-}
-
-int unit_fail_if_symlink(Unit *u, const char* where) {
-        int r;
-
-        assert(u);
-        assert(where);
-
-        r = is_symlink(where);
-        if (r < 0) {
-                log_unit_debug_errno(u, r, "Failed to check symlink %s, ignoring: %m", where);
-                return 0;
-        }
-        if (r == 0)
-                return 0;
-
-        log_struct(LOG_ERR,
-                   LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
-                   LOG_UNIT_ID(u),
-                   LOG_UNIT_MESSAGE(u, "Mount on symlink %s not allowed.", where),
-                   "WHERE=%s", where,
-                   NULL);
-
-        return -ELOOP;
-}
-
 static void mount_enter_unmounting(Mount *m) {
         int r;
 
index 79cdc8dbfcad03166963d79132de95f4a09ad9d2..a01e6da194e2ab74a8c83737682f19885d307cb3 100644 (file)
@@ -128,6 +128,3 @@ MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
 
 const char* mount_result_to_string(MountResult i) _const_;
 MountResult mount_result_from_string(const char *s) _pure_;
-
-void unit_warn_if_dir_nonempty(Unit *u, const char* where);
-int unit_fail_if_symlink(Unit *u, const char* where);
index 25d0859bf3eb86136c3b95a6a27ae6f30e2df0c1..0a1278c2a1d83717ca28e6d4131b16a62c30aa3c 100644 (file)
@@ -3672,6 +3672,52 @@ bool unit_type_supported(UnitType t) {
         return unit_vtable[t]->supported();
 }
 
+void unit_warn_if_dir_nonempty(Unit *u, const char* where) {
+        int r;
+
+        assert(u);
+        assert(where);
+
+        r = dir_is_empty(where);
+        if (r > 0)
+                return;
+        if (r < 0) {
+                log_unit_warning_errno(u, r, "Failed to check directory %s: %m", where);
+                return;
+        }
+
+        log_struct(LOG_NOTICE,
+                   LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+                   LOG_UNIT_ID(u),
+                   LOG_UNIT_MESSAGE(u, "Directory %s to mount over is not empty, mounting anyway.", where),
+                   "WHERE=%s", where,
+                   NULL);
+}
+
+int unit_fail_if_symlink(Unit *u, const char* where) {
+        int r;
+
+        assert(u);
+        assert(where);
+
+        r = is_symlink(where);
+        if (r < 0) {
+                log_unit_debug_errno(u, r, "Failed to check symlink %s, ignoring: %m", where);
+                return 0;
+        }
+        if (r == 0)
+                return 0;
+
+        log_struct(LOG_ERR,
+                   LOG_MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
+                   LOG_UNIT_ID(u),
+                   LOG_UNIT_MESSAGE(u, "Mount on symlink %s not allowed.", where),
+                   "WHERE=%s", where,
+                   NULL);
+
+        return -ELOOP;
+}
+
 static const char* const unit_active_state_table[_UNIT_ACTIVE_STATE_MAX] = {
         [UNIT_ACTIVE] = "active",
         [UNIT_RELOADING] = "reloading",
index 094510ba5d5bed16178dd0019f2eab6b7fed4f88..62257c403e3dba7b004e76821abac890baf1d773 100644 (file)
@@ -607,6 +607,9 @@ static inline bool unit_supported(Unit *u) {
         return unit_type_supported(u->type);
 }
 
+void unit_warn_if_dir_nonempty(Unit *u, const char* where);
+int unit_fail_if_symlink(Unit *u, const char* where);
+
 const char *unit_active_state_to_string(UnitActiveState i) _const_;
 UnitActiveState unit_active_state_from_string(const char *s) _pure_;