]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - disk-utils/partx.c
fstrim shouldn't run inside a container
[thirdparty/util-linux.git] / disk-utils / partx.c
index 3ccd1afadc0e49c3c57124c37f44dd1576cbe59b..949278eb79854bb00588268115efde477903ca4a 100644 (file)
@@ -177,14 +177,15 @@ static int get_partno_from_device(char *partition, dev_t devno)
        assert(partition);
 
        if (devno) {
-               struct sysfs_cxt cxt;
+               struct path_cxt *pc;
                int rc;
 
-               if (sysfs_init(&cxt, devno, NULL))
+               pc = ul_new_sysfs_path(devno, NULL, NULL);
+               if (!pc)
                        goto err;
 
-               rc = sysfs_read_int(&cxt, "partition", &partno);
-               sysfs_deinit(&cxt);
+               rc = ul_path_read_s32(pc, &partno, "partition");
+               ul_unref_path(pc);
 
                if (rc == 0)
                        return partno;
@@ -831,7 +832,7 @@ int main(int argc, char **argv)
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
 
        while ((c = getopt_long(argc, argv,
                                "abdglrsuvn:t:o:PS:hV", long_opts, NULL)) != -1) {
@@ -900,8 +901,7 @@ int main(int argc, char **argv)
                case 'h':
                        usage();
                case 'V':
-                       printf(UTIL_LINUX_VERSION);
-                       return EXIT_SUCCESS;
+                       print_version(EXIT_SUCCESS);
                default:
                        errtryhelp(EXIT_FAILURE);
                }
@@ -1054,7 +1054,9 @@ int main(int argc, char **argv)
                        default:
                                abort();
                        }
-               }
+               } else
+                       rc = 1;
+
                blkid_free_probe(pr);
        }