[systemd-commits] 5 commits - src/core src/shared TODO

Kay Sievers kay at kemper.freedesktop.org
Sun Nov 4 17:02:32 PST 2012


 TODO                   |   24 +++++++++++++----------
 src/core/kmod-setup.c  |   31 ++++++++++++++++++------------
 src/core/mount-setup.c |   50 +++++++++++++++++++++++++++++++++----------------
 src/shared/util.c      |    4 +++
 src/shared/util.h      |    2 +
 5 files changed, 73 insertions(+), 38 deletions(-)

New commits:
commit 6aa220e019f9dffd96590b06b68f937985204109
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Nov 4 17:03:48 2012 +0100

    mount-setup: try mounting 'efivarfs' only if the system bootet with EFI

diff --git a/TODO b/TODO
index 3b0d872..e2014c2 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,4 @@
 Bugfixes:
-* mount efivars only if /sys/firmware/efi/ exists
-  (add *condition callback to API mounts array and check for directory)
-
 * check systemd-tmpfiles for selinux context hookup for mknod(), symlink() and similar
 
 * swap units that are activated by one name but shown in the kernel under another are semi-broken
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 9894c7f..98614d0 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -46,14 +46,20 @@
 #define TTY_GID 5
 #endif
 
+typedef enum MountMode {
+        MNT_NONE  =        0,
+        MNT_FATAL =        1 <<  0,
+        MNT_IN_CONTAINER = 1 <<  1,
+} MountMode;
+
 typedef struct MountPoint {
         const char *what;
         const char *where;
         const char *type;
         const char *options;
         unsigned long flags;
-        bool fatal;
-        bool in_container;
+        bool (*condition_fn)(void);
+        MountMode mode;
 } MountPoint;
 
 /* The first three entries we might need before SELinux is up. The
@@ -62,16 +68,26 @@ typedef struct MountPoint {
 #define N_EARLY_MOUNT 4
 
 static const MountPoint mount_table[] = {
-        { "proc",     "/proc",                  "proc",     NULL,                MS_NOSUID|MS_NOEXEC|MS_NODEV,                true,  true  },
-        { "sysfs",    "/sys",                   "sysfs",    NULL,                MS_NOSUID|MS_NOEXEC|MS_NODEV,                true,  true  },
-        { "devtmpfs", "/dev",                   "devtmpfs", "mode=755",          MS_NOSUID|MS_STRICTATIME,                    true,  true  },
-        { "securityfs", "/sys/kernel/security", "securityfs", NULL,              MS_NOSUID|MS_NOEXEC|MS_NODEV,                false, false },
-        { "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL,             MS_NOSUID|MS_NOEXEC|MS_NODEV,                false, false },
-        { "tmpfs",    "/dev/shm",               "tmpfs",    "mode=1777",         MS_NOSUID|MS_NODEV|MS_STRICTATIME,           true,  true  },
-        { "devpts",   "/dev/pts",               "devpts",   "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC,          false, true  },
-        { "tmpfs",    "/run",                   "tmpfs",    "mode=755",          MS_NOSUID|MS_NODEV|MS_STRICTATIME,           true,  true  },
-        { "tmpfs",    "/sys/fs/cgroup",         "tmpfs",    "mode=755",          MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, false, true  },
-        { "cgroup",   "/sys/fs/cgroup/systemd", "cgroup",   "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV,                false, true  },
+        { "proc",       "/proc",                     "proc",       NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
+          NULL,       MNT_FATAL|MNT_IN_CONTAINER },
+        { "sysfs",      "/sys",                      "sysfs",      NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
+          NULL,       MNT_FATAL|MNT_IN_CONTAINER },
+        { "devtmpfs",   "/dev",                      "devtmpfs",   "mode=755", MS_NOSUID|MS_STRICTATIME,
+          NULL,       MNT_FATAL|MNT_IN_CONTAINER },
+        { "securityfs", "/sys/kernel/security",      "securityfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
+          NULL,       MNT_NONE },
+        { "efivarfs",   "/sys/firmware/efi/efivars", "efivarfs",   NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
+          is_efiboot, MNT_NONE },
+        { "tmpfs",      "/dev/shm",                  "tmpfs",      "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME,
+          NULL,       MNT_FATAL|MNT_IN_CONTAINER },
+        { "devpts",     "/dev/pts",                  "devpts",     "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC,
+          NULL,       MNT_IN_CONTAINER },
+        { "tmpfs",      "/run",                      "tmpfs",      "mode=755", MS_NOSUID|MS_NODEV|MS_STRICTATIME,
+          NULL,       MNT_FATAL|MNT_IN_CONTAINER },
+        { "tmpfs",      "/sys/fs/cgroup",            "tmpfs",      "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
+          NULL,       MNT_IN_CONTAINER },
+        { "cgroup",     "/sys/fs/cgroup/systemd",    "cgroup",     "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV,
+          NULL,       MNT_IN_CONTAINER },
 };
 
 /* These are API file systems that might be mounted by other software,
@@ -119,6 +135,9 @@ static int mount_one(const MountPoint *p, bool relabel) {
 
         assert(p);
 
+        if (p->condition_fn && !p->condition_fn())
+                return 0;
+
         /* Relabel first, just in case */
         if (relabel)
                 label_fix(p->where, true, true);
@@ -131,7 +150,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
                 return 0;
 
         /* Skip securityfs in a container */
-        if (!p->in_container && detect_container(NULL) > 0)
+        if (!(p->mode & MNT_IN_CONTAINER) && detect_container(NULL) > 0)
                 return 0;
 
         /* The access mode here doesn't really matter too much, since
@@ -149,8 +168,8 @@ static int mount_one(const MountPoint *p, bool relabel) {
                   p->type,
                   p->flags,
                   p->options) < 0) {
-                log_full(p->fatal ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %s", p->where, strerror(errno));
-                return p->fatal ? -errno : 0;
+                log_full((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %s", p->where, strerror(errno));
+                return (p->mode & MNT_FATAL) ? -errno : 0;
         }
 
         /* Relabel again, since we now mounted something fresh here */
@@ -289,7 +308,6 @@ int mount_cgroup_controllers(char ***join_controllers) {
                 p.type = "cgroup";
                 p.options = options;
                 p.flags = MS_NOSUID|MS_NOEXEC|MS_NODEV;
-                p.fatal = false;
 
                 r = mount_one(&p, true);
                 free(controller);

commit 3dfb265083347cb5700dc38f7cc0f479f378e6e9
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Nov 4 16:55:23 2012 +0100

    kmod-setup: mounting efivarfs, *after* we tried to mount it, is pointless
    
    The mount() system call, which we issue before loading modules, will trigger
    a modprobe by the kernel and block until it returns. Trying to load it again
    later, will have exactly the same result as the first time.

diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 383a6b2..20ab232 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -39,7 +39,6 @@ typedef struct Kmodule {
 static const KModule kmod_table[] = {
         { "autofs4",  "/sys/class/misc/autofs",    NULL } ,
         { "ipv6",     "/sys/module/ipv6",          NULL },
-        { "efivarfs", "/sys/firmware/efi/efivars", NULL },
         { "unix",     "/proc/net/unix",            NULL } ,
 };
 

commit 1022373284b7562431fb0a6dba45db8af089a0e3
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Nov 4 16:54:19 2012 +0100

    kmod-setup: add conditional module loading callback

diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index ce8a8e7..383a6b2 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -30,11 +30,17 @@
 
 #include "kmod-setup.h"
 
-static const char * const kmod_table[] = {
-        "autofs4",  "/sys/class/misc/autofs",
-        "ipv6",     "/sys/module/ipv6",
-        "efivarfs", "/sys/firmware/efi/efivars",
-        "unix",     "/proc/net/unix"
+typedef struct Kmodule {
+        const char *name;
+        const char *directory;
+        bool (*condition_fn)(void);
+} KModule;
+
+static const KModule kmod_table[] = {
+        { "autofs4",  "/sys/class/misc/autofs",    NULL } ,
+        { "ipv6",     "/sys/module/ipv6",          NULL },
+        { "efivarfs", "/sys/firmware/efi/efivars", NULL },
+        { "unix",     "/proc/net/unix",            NULL } ,
 };
 
 #pragma GCC diagnostic push
@@ -42,7 +48,8 @@ static const char * const kmod_table[] = {
 static void systemd_kmod_log(void *data, int priority, const char *file, int line,
                              const char *fn, const char *format, va_list args)
 {
-        log_metav(priority, file, line, fn, format, args);
+        /* library logging is enabled at debug only */
+        log_metav(LOG_DEBUG, file, line, fn, format, args);
 }
 #pragma GCC diagnostic pop
 
@@ -53,13 +60,15 @@ int kmod_setup(void) {
         int err;
 
         for (i = 0; i < ELEMENTSOF(kmod_table); i += 2) {
+                if (kmod_table[i].condition_fn && !kmod_table[i].condition_fn())
+                        continue;
 
-                if (access(kmod_table[i+1], F_OK) >= 0)
+                if (access(kmod_table[i].directory, F_OK) >= 0)
                         continue;
 
                 log_debug("Your kernel apparently lacks built-in %s support. Might be a good idea to compile it in. "
                           "We'll now try to work around this by loading the module...",
-                          kmod_table[i]);
+                          kmod_table[i].name);
 
                 if (!ctx) {
                         ctx = kmod_new(NULL, NULL);
@@ -69,13 +78,12 @@ int kmod_setup(void) {
                         }
 
                         kmod_set_log_fn(ctx, systemd_kmod_log, NULL);
-
                         kmod_load_resources(ctx);
                 }
 
-                err = kmod_module_new_from_name(ctx, kmod_table[i], &mod);
+                err = kmod_module_new_from_name(ctx, kmod_table[i].name, &mod);
                 if (err < 0) {
-                        log_error("Failed to load module '%s'", kmod_table[i]);
+                        log_error("Failed to lookup module '%s'", kmod_table[i].name);
                         continue;
                 }
 
@@ -85,7 +93,7 @@ int kmod_setup(void) {
                 else if (err == KMOD_PROBE_APPLY_BLACKLIST)
                         log_info("Module '%s' is blacklisted", kmod_module_get_name(mod));
                 else
-                        log_error("Failed to insert '%s'", kmod_module_get_name(mod));
+                        log_error("Failed to insert module '%s'", kmod_module_get_name(mod));
 
                 kmod_module_unref(mod);
         }

commit c1e5704657315b436c0409e8172c1fcb76adccad
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Nov 4 16:06:27 2012 +0100

    shared: add is_efiboot()

diff --git a/src/shared/util.c b/src/shared/util.c
index 2a8afae..9983695 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -77,6 +77,10 @@ char **saved_argv = NULL;
 static volatile unsigned cached_columns = 0;
 static volatile unsigned cached_lines = 0;
 
+bool is_efiboot(void) {
+        return access("/sys/firmware/efi", F_OK) >= 0;
+}
+
 size_t page_size(void) {
         static __thread size_t pgsz = 0;
         long r;
diff --git a/src/shared/util.h b/src/shared/util.h
index e387b12..99972cc 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -90,6 +90,8 @@ union dirent_storage {
 #define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
 #define ANSI_HIGHLIGHT_OFF "\x1B[0m"
 
+bool is_efiboot(void);
+
 usec_t now(clockid_t clock);
 
 dual_timestamp* dual_timestamp_get(dual_timestamp *ts);

commit d2e83c23f5f0cdd3b6ec05c5c40209708721e704
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Nov 4 15:47:08 2012 +0100

    TODO: update RTC, DST stuff

diff --git a/TODO b/TODO
index 3dd7290..3b0d872 100644
--- a/TODO
+++ b/TODO
@@ -22,14 +22,21 @@ F18:
 
 Features:
 
-* introduce ntp.service (or suchlike) as symlink that is used to arbitrate between various NTP implementations
-
-* timer units should get the ability to trigger:
-    a) when CLOCK_REALTIME makes jumps (TFD_TIMER_CANCEL_ON_SET)
-    b) when DST jumps takes place (glibc's zoneinfo "mess")
-  We want to be able to schedule an event when the system time changes by user
-  request, or DST change takes effect, to update the rtc-in-localtime and sys_tz
-  of the kernel when needed.
+* introduce ntp.service (or suchlike) as symlink that is used to arbitrate between various
+  NTP implementations
+
+* timer units should get the ability to trigger when:
+    - CLOCK_REALTIME makes jumps (TFD_TIMER_CANCEL_ON_SET)
+    - DST changes
+
+* update the kernel's TZ (sys_tz) when DST changes
+
+* sync down the system time to the RTC when:
+    - CLOCK_REALTIME makes jumps (the user explicitely requested a time set)
+    - DST changes && ntp is active && RTC-in-localtime (never do it without ntp)
+  This takes care of syncing ntpdate updates to the RTC, and DST updates for localtime
+  mode, it will never touch the RTC if the no reliale time source is active or the
+  user did not request anything like it.
 
 * When we begin with system shutdown all kind of suspend/hibernation should be prohibited until shutdown/reboot
 



More information about the systemd-commits mailing list