[systemd-commits] 4 commits - TODO man/systemd.service.xml src/core src/cryptsetup src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Mon May 21 08:24:33 PDT 2012


 TODO                                  |    8 +-----
 man/systemd.service.xml               |    9 ++++++
 src/core/hostname-setup.c             |   25 +++++--------------
 src/core/load-fragment-gperf.gperf.m4 |    1 
 src/core/mount.c                      |    3 +-
 src/cryptsetup/cryptsetup-generator.c |   44 ++++++++++++++++++----------------
 src/shared/util.c                     |   10 ++++++-
 src/shared/util.h                     |    1 
 8 files changed, 55 insertions(+), 46 deletions(-)

New commits:
commit 36140842612803d71fe771ce03f3dee7732284f0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 21 17:24:26 2012 +0200

    service: make the fsck pass no configurable

diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index 11f98c3..d5633dc 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -835,6 +835,15 @@
                                 <option>none</option>.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><varname>FsckPassNo=</varname></term>
+
+                                <listitem><para>If this is an file
+                                system checking service specify the
+                                pass number. This should not be used
+                                for normal services.</para></listitem>
+                        </varlistentry>
+
                 </variablelist>
         </refsect1>
 
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 5be4dad..681f2e9 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -200,6 +200,7 @@ Mount.What,                      config_parse_string,                0,
 Mount.Where,                     config_parse_path,                  0,                             offsetof(Mount, where)
 Mount.Options,                   config_parse_string,                0,                             offsetof(Mount, parameters_fragment.options)
 Mount.Type,                      config_parse_string,                0,                             offsetof(Mount, parameters_fragment.fstype)
+Mount.FsckPassNo,                config_parse_int,                   0,                             offsetof(Mount, parameters_fragment.passno)
 Mount.TimeoutSec,                config_parse_usec,                  0,                             offsetof(Mount, timeout_usec)
 Mount.DirectoryMode,             config_parse_mode,                  0,                             offsetof(Mount, directory_mode)
 EXEC_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl

commit f7f21d33db5dfe88dc8175c61dada44013347729
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 21 17:22:36 2012 +0200

    cryptsetup: a few simplifications

diff --git a/TODO b/TODO
index fce136d..f2a844e 100644
--- a/TODO
+++ b/TODO
@@ -23,6 +23,8 @@ Bugfixes:
 
 Features:
 
+* readahead: when bumping /sys readahead variable save mtime and compare later to detect changes
+
 * in rescue mode don't pull in sockets
 
 * Document boot options such as forcefsck
diff --git a/src/core/mount.c b/src/core/mount.c
index aa81cc6..0c62e88 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1647,7 +1647,8 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
                         goto clean_up;
                 }
 
-                if (asprintf(&o, "%s,%s", options, options2) < 0) {
+                o = join(options, ",", options2, NULL);
+                if (!o) {
                         r = -ENOMEM;
                         goto finish;
                 }
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 4d10373..edc2899 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -76,31 +76,36 @@ static int create_disk(
         noauto = has_option(options, "noauto");
         nofail = has_option(options, "nofail");
 
-        if (!(n = unit_name_build_escape("cryptsetup", name, ".service"))) {
+        n = unit_name_build_escape("cryptsetup", name, ".service");
+        if (!n) {
                 r = -ENOMEM;
                 log_error("Failed to allocate unit name.");
                 goto fail;
         }
 
-        if (asprintf(&p, "%s/%s", arg_dest, n) < 0) {
+        p = join(arg_dest, "/", n, NULL);
+        if (!p) {
                 r = -ENOMEM;
                 log_error("Failed to allocate unit file name.");
                 goto fail;
         }
 
-        if (!(u = fstab_node_to_udev_node(device))) {
+        u = fstab_node_to_udev_node(device);
+        if (!u) {
                 r = -ENOMEM;
                 log_error("Failed to allocate device node.");
                 goto fail;
         }
 
-        if (!(d = unit_name_from_path(u, ".device"))) {
+        d = unit_name_from_path(u, ".device");
+        if (!d) {
                 r = -ENOMEM;
                 log_error("Failed to allocate device name.");
                 goto fail;
         }
 
-        if (!(f = fopen(p, "wxe"))) {
+        f = fopen(p, "wxe");
+        if (!f) {
                 r = -errno;
                 log_error("Failed to create unit file: %m");
                 goto fail;
@@ -164,13 +169,13 @@ static int create_disk(
 
         if (!noauto) {
 
-                if (asprintf(&to, "%s/%s.wants/%s", arg_dest, d, n) < 0) {
+                to = join(arg_dest, "/", d, ".wants/", n, NULL);
+                if (!to) {
                         r = -ENOMEM;
                         goto fail;
                 }
 
                 mkdir_parents(to, 0755);
-
                 if (symlink(from, to) < 0) {
                         log_error("Failed to create symlink '%s' to '%s': %m", from, to);
                         r = -errno;
@@ -178,38 +183,35 @@ static int create_disk(
                 }
 
                 free(to);
-                to = NULL;
 
                 if (!nofail)
-                        asprintf(&to, "%s/cryptsetup.target.requires/%s", arg_dest, n);
+                        to = join(arg_dest, "/cryptsetup.target.requires/", n, NULL);
                 else
-                        asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, n);
-
+                        to = join(arg_dest, "/cryptsetup.target.wants/", n, NULL);
                 if (!to) {
                         r = -ENOMEM;
                         goto fail;
                 }
 
                 mkdir_parents(to, 0755);
-
                 if (symlink(from, to) < 0) {
                         log_error("Failed to create symlink '%s' to '%s': %m", from, to);
                         r = -errno;
                         goto fail;
                 }
-        }
 
-        free(to);
-        to = NULL;
+                free(to);
+                to = NULL;
+        }
 
         e = unit_name_escape(name);
-        if (asprintf(&to, "%s/dev-mapper-%s.device.requires/%s", arg_dest, e, n) < 0) {
+        to = join(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
+        if (!to) {
                 r = -ENOMEM;
                 goto fail;
         }
 
         mkdir_parents(to, 0755);
-
         if (symlink(from, to) < 0) {
                 log_error("Failed to create symlink '%s' to '%s': %m", from, to);
                 r = -errno;
@@ -252,7 +254,8 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        if (!(f = fopen("/etc/crypttab", "re"))) {
+        f = fopen("/etc/crypttab", "re");
+        if (!f) {
 
                 if (errno == ENOENT)
                         r = EXIT_SUCCESS;
@@ -269,7 +272,7 @@ int main(int argc, char *argv[]) {
                 char *name = NULL, *device = NULL, *password = NULL, *options = NULL;
                 int k;
 
-                if (!(fgets(line, sizeof(line), f)))
+                if (!fgets(line, sizeof(line), f))
                         break;
 
                 n++;
@@ -278,7 +281,8 @@ int main(int argc, char *argv[]) {
                 if (*l == '#' || *l == 0)
                         continue;
 
-                if ((k = sscanf(l, "%ms %ms %ms %ms", &name, &device, &password, &options)) < 2 || k > 4) {
+                k = sscanf(l, "%ms %ms %ms %ms", &name, &device, &password, &options);
+                if (k < 2 || k > 4) {
                         log_error("Failed to parse /etc/crypttab:%u, ignoring.", n);
                         r = EXIT_FAILURE;
                         goto next;

commit 344de60901f0e3ce0d2f112b7be97fc6d0e2f071
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 21 17:19:58 2012 +0200

    hostname-setup: also consider (Å„one) an unset hostname

diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index 03b5f47..e3ea5fe 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -151,31 +151,20 @@ int hostname_setup(void) {
 
         r = read_hostname(&b);
         if (r < 0) {
+                hn = NULL;
+
                 if (r == -ENOENT)
                         enoent = true;
                 else
                         log_warning("Failed to read configured hostname: %s", strerror(-r));
-
-                hn = NULL;
         } else
                 hn = b;
 
-        if (!hn) {
-                /* Don't override the hostname if it is unset and not
-                 * explicitly configured */
-
-                char *old_hostname = NULL;
-
-                old_hostname = gethostname_malloc();
-                if (old_hostname) {
-                        bool already_set;
-
-                        already_set = old_hostname[0] != 0;
-                        free(old_hostname);
-
-                        if (already_set)
-                                goto finish;
-                }
+        if (isempty(hn)) {
+                /* Don't override the hostname if it is already set
+                 * and not explicitly configured */
+                if (hostname_is_set())
+                        goto finish;
 
                 if (enoent)
                         log_info("No hostname configured.");
diff --git a/src/shared/util.c b/src/shared/util.c
index ae0ce32..0234f3b 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2949,12 +2949,20 @@ char* gethostname_malloc(void) {
 
         assert_se(uname(&u) >= 0);
 
-        if (u.nodename[0])
+        if (!isempty(u.nodename) && !streq(u.nodename, "(none)"))
                 return strdup(u.nodename);
 
         return strdup(u.sysname);
 }
 
+bool hostname_is_set(void) {
+        struct utsname u;
+
+        assert_se(uname(&u) >= 0);
+
+        return !isempty(u.nodename) && !streq(u.nodename, "(none)");
+}
+
 char* getlogname_malloc(void) {
         uid_t uid;
         long bufsize;
diff --git a/src/shared/util.h b/src/shared/util.h
index 3dce047..e727ee7 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -337,6 +337,7 @@ void rename_process(const char name[8]);
 void sigset_add_many(sigset_t *ss, ...);
 
 char* gethostname_malloc(void);
+bool hostname_is_set(void);
 char* getlogname_malloc(void);
 
 int getttyname_malloc(int fd, char **r);

commit 97f25a02ee3fd6934eec6341373bb22de09e1ce2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon May 21 15:34:33 2012 +0200

    update TODO

diff --git a/TODO b/TODO
index 1f60911..fce136d 100644
--- a/TODO
+++ b/TODO
@@ -27,10 +27,6 @@ Features:
 
 * Document boot options such as forcefsck
 
-* beef up links between systemctl output and man pages. i.e. add a new unit
-  file setting that links to man and other sources of documentation, and hook
-  all systemd internal units accordingly.
-
 * (attempt to) make Debianites happy:
         - implement .d/ auto includes for unit files
         - add syntax to reset ExecStart= lists (and similar)
@@ -96,8 +92,6 @@ Features:
 
 * journald: allow forwarding of log data to specific TTY instead of console
 
-* add RequiredBy to [Install]
-
 * udev: move to LGPL
 
 * udev systemd unify:



More information about the systemd-commits mailing list