]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/findmnt-verify.c
lscpu: add --bytes
[thirdparty/util-linux.git] / misc-utils / findmnt-verify.c
index a096ddec5c894ac68c8a26046b8f2ca6bfdc94be..1cc62def97f295412f22aad3a52c58659dea3874 100644 (file)
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <libmount.h>
 #include <blkid.h>
 #include <sys/utsname.h>
@@ -127,14 +126,13 @@ done:
 static int verify_target(struct verify_context *vfy)
 {
        const char *tgt = mnt_fs_get_target(vfy->fs);
-       const char *cn = tgt;
        struct stat sb;
 
        if (!tgt)
                return verify_err(vfy, _("undefined target (fs_file)"));
 
        if (!(flags & FL_NOCACHE)) {
-               cn = mnt_resolve_target(tgt, cache);
+               const char *cn = mnt_resolve_target(tgt, cache);
                if (!cn)
                        return -ENOMEM;
                if (strcmp(cn, tgt) != 0)
@@ -181,7 +179,7 @@ static int verify_source(struct verify_context *vfy)
        const char *src = mnt_fs_get_srcpath(vfy->fs);
        char *t = NULL, *v = NULL;
        struct stat sb;
-       int isbind;
+       int isbind, rc = 0;
 
        /* source is NAME=value tag */
        if (!src) {
@@ -196,9 +194,10 @@ static int verify_source(struct verify_context *vfy)
 
        /* blkid is able to parse it, but libmount does not see it as a tag --
         * it means unsupported tag */
-       } else if (blkid_parse_tag_string(src, &t, &v) == 0 && stat(src, &sb) != 0)
-               return verify_err(vfy, _("unsupported source tag: %s"), src);
-
+       } else if (blkid_parse_tag_string(src, &t, &v) == 0 && stat(src, &sb) != 0) {
+               rc = verify_err(vfy, _("unsupported source tag: %s"), src);
+               goto done;
+       }
        isbind = mnt_fs_get_option(vfy->fs, "bind", NULL, NULL) == 0;
 
        /* source is path */
@@ -218,7 +217,7 @@ static int verify_source(struct verify_context *vfy)
 done:
        free(t);
        free(v);
-       return 0;
+       return rc;
 }
 
 static int verify_options(struct verify_context *vfy)
@@ -328,14 +327,15 @@ static int read_proc_filesystems(struct verify_context *vfy)
 
                rc = add_filesystem(vfy, cp);
                if (rc)
-                       return rc;
+                       break;
        }
        fclose(f);
-       return 0;
+       return rc;
 }
 
 static int read_kernel_filesystems(struct verify_context *vfy)
 {
+       int rc = 0;
 #ifdef __linux__
        struct utsname uts;
        FILE *f;
@@ -351,7 +351,6 @@ static int read_kernel_filesystems(struct verify_context *vfy)
 
        while (!feof(f)) {
                char *p, *name;
-               int rc;
 
                if (!fgets(buf, sizeof(buf), f))
                        break;
@@ -377,11 +376,11 @@ static int read_kernel_filesystems(struct verify_context *vfy)
 
                rc = add_filesystem(vfy, name);
                if (rc)
-                       return rc;
+                       break;
        }
        fclose(f);
 #endif /* __linux__ */
-       return 0;
+       return rc;
 }
 
 static int verify_fstype(struct verify_context *vfy)
@@ -411,7 +410,7 @@ static int verify_fstype(struct verify_context *vfy)
                        isswap = 1;
 
                if (!isswap && !isauto && !none && !is_supported_filesystem(vfy, type))
-                       verify_warn(vfy, _("%s seems unspported by the current kernel"), type);
+                       verify_warn(vfy, _("%s seems unsupported by the current kernel"), type);
        }
        realtype = mnt_get_fstype(src, &ambi, cache);
 
@@ -428,7 +427,7 @@ static int verify_fstype(struct verify_context *vfy)
                        return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
 
                if (!isswap && !is_supported_filesystem(vfy, realtype))
-                       return verify_err(vfy, _("on-disk %s seems unspported by the current kernel"), realtype);
+                       return verify_err(vfy, _("on-disk %s seems unsupported by the current kernel"), realtype);
 
                verify_ok(vfy, _("FS type is %s"), realtype);
        }
@@ -472,7 +471,7 @@ static int verify_filesystem(struct verify_context *vfy)
 int verify_table(struct libmnt_table *tb)
 {
        struct verify_context vfy = { .nerrors = 0 };
-       struct libmnt_iter *itr = NULL;
+       struct libmnt_iter *itr;
        int rc = 0;             /* overall return code (alloc errors, etc.) */
        int check_order = is_listall_mode();
        static int has_read_fs = 0;