]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: rewrite -f
authorKarel Zak <kzak@redhat.com>
Wed, 21 Dec 2011 14:38:59 +0000 (15:38 +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 d4a97a3903e2ab3d562ad975369895dd64f53573..0d8bd858d0fdc4058d190aa2c456f70ccfc6fcd8 100644 (file)
@@ -1038,6 +1038,7 @@ int main(int argc, char **argv)
                        encryption = optarg;
                        break;
                case 'f':
+                       act = A_FIND_FREE;
                        find = 1;
                        break;
                case 'h':
@@ -1087,6 +1088,12 @@ int main(int argc, char **argv)
        case A_DELETE_ALL:
                res = delete_all_loops(&lc);
                break;
+       case A_FIND_FREE:
+               if (loopcxt_find_unused(&lc))
+                       warn(_("find unused loop device failed"));
+               else
+                       printf("%s\n", loopcxt_get_device(&lc));
+               break;
        case A_SHOW:
                res = show_all_loops(&lc, file, offset, flags);
                break;