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.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index c94456522..11bd66ebf 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -27,33 +27,27 @@
27int 27int
28losetup_main (int argc, char **argv) 28losetup_main (int argc, char **argv)
29{ 29{
30 int delete = 0;
31 int offset = 0; 30 int offset = 0;
32 int opt;
33 31
34 while ((opt = getopt (argc, argv, "do:")) != -1) 32 /* This will need a "while(getopt()!=-1)" loop when we can have more than
35 switch (opt) 33 one option, but for now we can't. */
36 { 34 switch(getopt(argc,argv, "do:")) {
37 case 'd': 35 case 'd':
38 delete = 1; 36 /* detach takes exactly one argument */
39 break; 37 if(optind+1==argc)
40 38 return del_loop(argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE;
41 case 'o': 39 break;
42 offset = bb_xparse_number (optarg, NULL); 40
43 break; 41 case 'o':
44 42 offset = bb_xparse_number (optarg, NULL);
45 default: 43 /* Fall through to do the losetup */
46 bb_show_usage(); 44 case -1:
47 } 45 /* losetup takes two argument:, loop_device and file */
48 46 if(optind+2==argc)
49 if ((delete && (offset || optind + 1 != argc)) 47 return set_loop(&argv[optind], argv[optind + 1], offset)<0
50 || (!delete && optind + 2 != argc)) 48 ? EXIT_FAILURE : EXIT_SUCCESS;
51 bb_show_usage(); 49 break;
52 50 }
53 opt = 0; 51 bb_show_usage();
54 if (delete) 52 return EXIT_FAILURE;
55 return del_loop (argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE;
56 else
57 return set_loop (argv[optind], argv[optind + 1], offset, &opt)
58 ? EXIT_FAILURE : EXIT_SUCCESS;
59} 53}