chiark / gitweb /
treewide: use log_*_errno whenever %m is in the format string
[elogind.git] / src / fstab-generator / fstab-generator.c
index 14e664236ed24c01a99a931d058cf225d3fbf30d..1c85a729b82093392dbf85608b704de24a558488 100644 (file)
@@ -111,7 +111,7 @@ static int add_swap(
                 if (errno == EEXIST)
                         log_error("Failed to create swap unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
                 else
-                        log_error("Failed to create unit file %s: %m", unit);
+                        log_error_errno(errno, "Failed to create unit file %s: %m", unit);
                 return -errno;
         }
 
@@ -133,10 +133,8 @@ static int add_swap(
                 fprintf(f, "Options=%s\n", me->mnt_opts);
 
         r = fflush_and_check(f);
-        if (r < 0) {
-                log_error("Failed to write unit file %s: %s", unit, strerror(-r));
-                return r;
-        }
+        if (r < 0)
+                return log_error_errno(r, "Failed to write unit file %s: %m", unit);
 
         /* use what as where, to have a nicer error message */
         r = generator_write_timeouts(arg_dest, what, what, me->mnt_opts, NULL);
@@ -151,7 +149,7 @@ static int add_swap(
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(unit, lnk) < 0) {
-                        log_error("Failed to create symlink %s: %m", lnk);
+                        log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
                         return -errno;
                 }
         }
@@ -231,7 +229,7 @@ static int add_mount(
                 if (errno == EEXIST)
                         log_error("Failed to create mount unit file %s, as it already exists. Duplicate entry in /etc/fstab?", unit);
                 else
-                        log_error("Failed to create unit file %s: %m", unit);
+                        log_error_errno(errno, "Failed to create unit file %s: %m", unit);
                 return -errno;
         }
 
@@ -271,7 +269,7 @@ static int add_mount(
 
         fflush(f);
         if (ferror(f)) {
-                log_error("Failed to write unit file %s: %m", unit);
+                log_error_errno(errno, "Failed to write unit file %s: %m", unit);
                 return -errno;
         }
 
@@ -282,7 +280,7 @@ static int add_mount(
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(unit, lnk) < 0) {
-                        log_error("Failed to create symlink %s: %m", lnk);
+                        log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
                         return -errno;
                 }
         }
@@ -299,7 +297,7 @@ static int add_mount(
                 fclose(f);
                 f = fopen(automount_unit, "wxe");
                 if (!f) {
-                        log_error("Failed to create unit file %s: %m", automount_unit);
+                        log_error_errno(errno, "Failed to create unit file %s: %m", automount_unit);
                         return -errno;
                 }
 
@@ -322,7 +320,7 @@ static int add_mount(
 
                 fflush(f);
                 if (ferror(f)) {
-                        log_error("Failed to write unit file %s: %m", automount_unit);
+                        log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
                         return -errno;
                 }
 
@@ -333,7 +331,7 @@ static int add_mount(
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(automount_unit, lnk) < 0) {
-                        log_error("Failed to create symlink %s: %m", lnk);
+                        log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
                         return -errno;
                 }
         }
@@ -353,7 +351,7 @@ static int parse_fstab(bool initrd) {
                 if (errno == ENOENT)
                         return 0;
 
-                log_error("Failed to open %s: %m", fstab_path);
+                log_error_errno(errno, "Failed to open %s: %m", fstab_path);
                 return -errno;
         }
 
@@ -600,7 +598,7 @@ int main(int argc, char *argv[]) {
 
         r = parse_proc_cmdline(parse_proc_cmdline_item);
         if (r < 0)
-                log_warning("Failed to parse kernel command line, ignoring: %s", strerror(-r));
+                log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
 
         /* Always honour root= and usr= in the kernel command line if we are in an initrd */
         if (in_initrd()) {