aboutsummaryrefslogtreecommitdiff
path: root/util-linux/losetup.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/losetup.c')
-rw-r--r--util-linux/losetup.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 11bd66ebf..b2af63dc0 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -24,8 +24,7 @@
24 24
25#include "busybox.h" 25#include "busybox.h"
26 26
27int 27int losetup_main (int argc, char **argv)
28losetup_main (int argc, char **argv)
29{ 28{
30 int offset = 0; 29 int offset = 0;
31 30
@@ -34,18 +33,27 @@ losetup_main (int argc, char **argv)
34 switch(getopt(argc,argv, "do:")) { 33 switch(getopt(argc,argv, "do:")) {
35 case 'd': 34 case 'd':
36 /* detach takes exactly one argument */ 35 /* detach takes exactly one argument */
37 if(optind+1==argc) 36 if(optind+1==argc && !del_loop(argv[optind])) return EXIT_SUCCESS;
38 return del_loop(argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE; 37die_failed:
39 break; 38 bb_perror_msg_and_die("%s",argv[optind]);
40 39
41 case 'o': 40 case 'o':
42 offset = bb_xparse_number (optarg, NULL); 41 offset = bb_xparse_number (optarg, NULL);
43 /* Fall through to do the losetup */ 42 /* Fall through to do the losetup */
44 case -1: 43 case -1:
45 /* losetup takes two argument:, loop_device and file */ 44 /* losetup takes two argument:, loop_device and file */
46 if(optind+2==argc) 45 if(optind+2==argc) {
47 return set_loop(&argv[optind], argv[optind + 1], offset)<0 46 if(set_loop(&argv[optind], argv[optind + 1], offset)>=0)
48 ? EXIT_FAILURE : EXIT_SUCCESS; 47 return EXIT_SUCCESS;
48 else goto die_failed;
49 }
50 if(optind+1==argc) {
51 char *s=query_loop(argv[optind]);
52 if (!s) goto die_failed;
53 printf("%s: %s\n",argv[optind],s);
54 if(ENABLE_FEATURE_CLEAN_UP) free(s);
55 return EXIT_SUCCESS;
56 }
49 break; 57 break;
50 } 58 }
51 bb_show_usage(); 59 bb_show_usage();