chiark / gitweb /
udev: hwdb - search parents for 'modalias' and data
[elogind.git] / src / fstab-generator / fstab-generator.c
index 89a4d13504fb67d32b66ff497fde58b541a74016..62053b7f353928a19fb38e92c8ba664817027021 100644 (file)
@@ -47,7 +47,7 @@ static int device_name(const char *path, char **unit) {
 
         p = unit_name_from_path(path, ".device");
         if (!p)
-                return -ENOMEM;
+                return log_oom();
 
         *unit = p;
         return 1;
@@ -98,22 +98,20 @@ static int add_swap(const char *what, struct mntent *me) {
 
         name = unit_name_from_path(what, ".swap");
         if (!name) {
-                log_error("Out of memory.");
-                r = -ENOMEM;
+                r = log_oom();
                 goto finish;
         }
 
         unit = strjoin(arg_dest, "/", name, NULL);
         if (!unit) {
-                log_error("Out of memory.");
-                r = -ENOMEM;
+                r = log_oom();
                 goto finish;
         }
 
         f = fopen(unit, "wxe");
         if (!f) {
                 r = -errno;
-                log_error("Failed to create unit file: %m");
+                log_error("Failed to create unit file %s: %m", unit);
                 goto finish;
         }
 
@@ -140,7 +138,7 @@ static int add_swap(const char *what, struct mntent *me) {
 
         fflush(f);
         if (ferror(f)) {
-                log_error("Failed to write unit file: %m");
+                log_error("Failed to write unit file %s: %m", unit);
                 r = -errno;
                 goto finish;
         }
@@ -148,37 +146,32 @@ static int add_swap(const char *what, struct mntent *me) {
         if (!noauto) {
                 lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
                 if (!lnk) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(unit, lnk) < 0) {
-                        log_error("Failed to create symlink: %m");
+                        log_error("Failed to create symlink %s: %m", lnk);
                         r = -errno;
                         goto finish;
                 }
 
                 r = device_name(what, &device);
-                if (r < 0) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                if (r < 0)
                         goto finish;
-                }
 
                 if (r > 0) {
                         free(lnk);
                         lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
                         if (!lnk) {
-                                log_error("Out of memory.");
-                                r = -ENOMEM;
+                                r = log_oom();
                                 goto finish;
                         }
 
                         mkdir_parents_label(lnk, 0755);
                         if (symlink(unit, lnk) < 0) {
-                                log_error("Failed to create symlink: %m");
+                                log_error("Failed to create symlink %s: %m", lnk);
                                 r = -errno;
                                 goto finish;
                         }
@@ -255,23 +248,21 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
         }
 
         name = unit_name_from_path(where, ".mount");
-        if (!name)  {
-                log_error("Out of memory.");
-                r = -ENOMEM;
+        if (!name) {
+                r = log_oom();
                 goto finish;
         }
 
         unit = strjoin(arg_dest, "/", name, NULL);
         if (!unit) {
-                log_error("Out of memory.");
-                r = -ENOMEM;
+                r = log_oom();
                 goto finish;
         }
 
         f = fopen(unit, "wxe");
         if (!f) {
                 r = -errno;
-                log_error("Failed to create unit file: %m");
+                log_error("Failed to create unit file %s: %m", unit);
                 goto finish;
         }
 
@@ -315,7 +306,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
 
         fflush(f);
         if (ferror(f)) {
-                log_error("Failed to write unit file: %m");
+                log_error("Failed to write unit file %s: %m", unit);
                 r = -errno;
                 goto finish;
         }
@@ -323,14 +314,13 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
         if (!noauto) {
                 lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
                 if (!lnk) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(unit, lnk) < 0) {
-                        log_error("Failed to create symlink: %m");
+                        log_error("Failed to create symlink %s: %m", lnk);
                         r = -errno;
                         goto finish;
                 }
@@ -339,24 +329,20 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
                     !path_equal(where, "/")) {
 
                         r = device_name(what, &device);
-                        if (r < 0) {
-                                log_error("Out of memory.");
-                                r = -ENOMEM;
+                        if (r < 0)
                                 goto finish;
-                        }
 
                         if (r > 0) {
                                 free(lnk);
                                 lnk = strjoin(arg_dest, "/", device, ".wants/", name, NULL);
                                 if (!lnk) {
-                                        log_error("Out of memory.");
-                                        r = -ENOMEM;
+                                        r = log_oom();
                                         goto finish;
                                 }
 
                                 mkdir_parents_label(lnk, 0755);
                                 if (symlink(unit, lnk) < 0) {
-                                        log_error("Failed to creat symlink: %m");
+                                        log_error("Failed to create symlink %s: %m", lnk);
                                         r = -errno;
                                         goto finish;
                                 }
@@ -367,15 +353,13 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
         if (automount && !path_equal(where, "/")) {
                 automount_name = unit_name_from_path(where, ".automount");
                 if (!name) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
                 automount_unit = strjoin(arg_dest, "/", automount_name, NULL);
                 if (!automount_unit) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
@@ -383,7 +367,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
                 f = fopen(automount_unit, "wxe");
                 if (!f) {
                         r = -errno;
-                        log_error("Failed to create unit file: %m");
+                        log_error("Failed to create unit file %s: %m", automount_unit);
                         goto finish;
                 }
 
@@ -402,7 +386,7 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
 
                 fflush(f);
                 if (ferror(f)) {
-                        log_error("Failed to write unit file: %m");
+                        log_error("Failed to write unit file %s: %m", automount_unit);
                         r = -errno;
                         goto finish;
                 }
@@ -410,14 +394,13 @@ static int add_mount(const char *what, const char *where, struct mntent *me) {
                 free(lnk);
                 lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
                 if (!lnk) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
                 mkdir_parents_label(lnk, 0755);
                 if (symlink(automount_unit, lnk) < 0) {
-                        log_error("Failed to create symlink: %m");
+                        log_error("Failed to create symlink %s: %m", lnk);
                         r = -errno;
                         goto finish;
                 }
@@ -459,16 +442,14 @@ static int parse_fstab(void) {
 
                 what = fstab_node_to_udev_node(me->mnt_fsname);
                 if (!what) {
-                        log_error("Out of memory.");
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }
 
                 where = strdup(me->mnt_dir);
                 if (!where) {
-                        log_error("Out of memory.");
+                        r = log_oom();
                         free(what);
-                        r = -ENOMEM;
                         goto finish;
                 }
 
@@ -513,7 +494,7 @@ static int parse_proc_cmdline(void) {
 
                 word = strndup(w, l);
                 if (!word) {
-                        r = -ENOMEM;
+                        r = log_oom();
                         goto finish;
                 }