]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: print info about one device
authorKarel Zak <kzak@redhat.com>
Thu, 22 Dec 2011 10:02:58 +0000 (11:02 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 22 Dec 2011 11:19:38 +0000 (12:19 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/losetup.c

index ab45dff1d16c6d89a8df0a47b4977a7de803fe0f..af4d1b0988d5ad0fadbe7ecb72ecd09e6bb25cec 100644 (file)
@@ -32,6 +32,7 @@ enum {
        A_DELETE,               /* delete given device(s) */
        A_DELETE_ALL,           /* delete all devices */
        A_SHOW,                 /* list devices */
+       A_SHOW_ONE,             /* print info about one device */
        A_FIND_FREE,            /* find first unused */
        A_SET_CAPACITY,         /* set device capacity */
 };
@@ -329,6 +330,13 @@ int main(int argc, char **argv)
                act = A_CREATE;
                file = argv[optind++];
        }
+       if (!act && optind + 1 == argc) {
+               /*
+                * losetup <device>
+                */
+               act = A_SHOW_ONE;
+               loopcxt_set_device(&lc, argv[optind++]);
+       }
        if (!act) {
                /*
                 * losetup <loopdev> <backing_file>
@@ -421,6 +429,11 @@ int main(int argc, char **argv)
        case A_SHOW:
                res = show_all_loops(&lc, file, offset, flags);
                break;
+       case A_SHOW_ONE:
+               res = printf_loopdev(&lc);
+               if (res)
+                       warn(_("%s"), loopcxt_get_device(&lc));
+               break;
        case A_SET_CAPACITY:
                res = set_capacity(&lc);
                break;