]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/wipefs.c
login: add support for directories in MOTD_FILE=
[thirdparty/util-linux.git] / misc-utils / wipefs.c
index 13a720e85fbce8fa04878e8636bc4ba926002fb8..2a16d62229cef7f7f5ee6858ba8a3ce05e8a56cb 100644 (file)
@@ -307,7 +307,7 @@ static struct wipe_desc *get_desc_for_probe(struct wipe_control *ctl,
                                            loff_t *offset,
                                            size_t *len)
 {
-       const char *off, *type, *mag, *p, *usage = NULL;
+       const char *off, *type, *mag, *p, *use = NULL;
        struct wipe_desc *wp;
        int rc, ispt = 0;
 
@@ -328,7 +328,7 @@ static struct wipe_desc *get_desc_for_probe(struct wipe_control *ctl,
                        rc = blkid_probe_lookup_value(pr, "PTMAGIC", &mag, len);
                if (rc)
                        return NULL;
-               usage = N_("partition-table");
+               use = N_("partition-table");
                ispt = 1;
        } else
                return NULL;
@@ -357,8 +357,8 @@ static struct wipe_desc *get_desc_for_probe(struct wipe_control *ctl,
        if (!wp)
                return NULL;
 
-       if (usage || blkid_probe_lookup_value(pr, "USAGE", &usage, NULL) == 0)
-               wp->usage = xstrdup(usage);
+       if (use || blkid_probe_lookup_value(pr, "USAGE", &use, NULL) == 0)
+               wp->usage = xstrdup(use);
 
        wp->type = xstrdup(type);
        wp->on_disk = 1;
@@ -386,7 +386,7 @@ new_probe(const char *devname, int mode)
                return NULL;
 
        if (mode) {
-               int fd = open(devname, mode);
+               int fd = open(devname, mode | O_NONBLOCK);
                if (fd < 0)
                        goto error;
 
@@ -658,6 +658,9 @@ usage(void)
 
        printf(USAGE_HELP_OPTIONS(21));
 
+       fputs(USAGE_ARGUMENTS, stdout);
+       printf(USAGE_ARG_SIZE(_("<num>")));
+
        fputs(USAGE_COLUMNS, stdout);
        for (i = 0; i < ARRAY_SIZE(infos); i++)
                fprintf(stdout, " %8s  %s\n", infos[i].name, _(infos[i].help));
@@ -700,7 +703,7 @@ 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, "abfhiJnO:o:pqt:V", longopts, NULL)) != -1) {
 
@@ -716,9 +719,6 @@ main(int argc, char **argv)
                case 'f':
                        ctl.force = 1;
                        break;
-               case 'h':
-                       usage();
-                       break;
                case 'J':
                        ctl.json = 1;
                        break;
@@ -745,9 +745,11 @@ main(int argc, char **argv)
                case 't':
                        ctl.type_pattern = optarg;
                        break;
+
+               case 'h':
+                       usage();
                case 'V':
-                       printf(UTIL_LINUX_VERSION);
-                       return EXIT_SUCCESS;
+                       print_version(EXIT_SUCCESS);
                default:
                        errtryhelp(EXIT_FAILURE);
                }