]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
blkid: add --hint <name>=value
authorKarel Zak <kzak@redhat.com>
Tue, 3 Nov 2020 16:15:34 +0000 (17:15 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Nov 2020 16:15:34 +0000 (17:15 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c

index dba3bb7d7bbb1788cf01e8f0d0253e2de0a860c4..4f23f09f66481c6b1ecfb60a95745e110b1c8750 100644 (file)
@@ -659,7 +659,7 @@ int main(int argc, char **argv)
        blkid_cache cache = NULL;
        char **devices = NULL;
        char *search_type = NULL, *search_value = NULL;
-       char *read = NULL;
+       char *read = NULL, *hint = NULL;
        int fltr_usage = 0;
        char **fltr_type = NULL;
        int fltr_flag = BLKID_FLTR_ONLYIN;
@@ -681,6 +681,7 @@ int main(int argc, char **argv)
                { "label",            required_argument, NULL, 'L' },
                { "uuid",             required_argument, NULL, 'U' },
                { "probe",            no_argument,       NULL, 'p' },
+               { "hint",             required_argument, NULL, 'H' },
                { "info",             no_argument,       NULL, 'i' },
                { "size",             required_argument, NULL, 'S' },
                { "offset",           required_argument, NULL, 'O' },
@@ -705,7 +706,7 @@ int main(int argc, char **argv)
        strutils_set_exitcode(BLKID_EXIT_OTHER);
 
        while ((c = getopt_long (argc, argv,
-                           "c:DdghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
+                           "c:DdgH:hilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
 
                err_exclusive_options(c, NULL, excl, excl_st);
 
@@ -719,6 +720,9 @@ int main(int argc, char **argv)
                case 'D':
                        ctl.no_part_details = 1;
                        break;
+               case 'H':
+                       hint = optarg;
+                       break;
                case 'L':
                        ctl.eval = 1;
                        search_value = xstrdup(optarg);
@@ -869,6 +873,10 @@ int main(int argc, char **argv)
                pr = blkid_new_probe();
                if (!pr)
                        goto exit;
+               if (hint && blkid_probe_set_hint(pr, hint, 0) != 0) {
+                       warn(_("Failed to use probing hint: %s"), hint);
+                       goto exit;
+               }
 
                if (ctl.lowprobe_superblocks) {
                        blkid_probe_set_superblocks_flags(pr,