2 * Mini losetup implementation for busybox
4 * Copyright (C) 2002 Matt Kraai.
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
14 int losetup_main (int argc, char **argv)
18 /* This will need a "while(getopt()!=-1)" loop when we can have more than
19 one option, but for now we can't. */
20 switch(getopt(argc,argv, "do:")) {
22 /* detach takes exactly one argument */
23 if(optind+1!=argc) bb_show_usage();
24 if(!del_loop(argv[optind])) return EXIT_SUCCESS;
26 bb_perror_msg_and_die("%s",argv[optind]);
29 offset = bb_xparse_number (optarg, NULL);
30 /* Fall through to do the losetup */
32 /* losetup takes two argument:, loop_device and file */
34 if(set_loop(&argv[optind], argv[optind + 1], offset)>=0)
39 char *s=query_loop(argv[optind]);
40 if (!s) goto die_failed;
41 printf("%s: %s\n",argv[optind],s);
42 if(ENABLE_FEATURE_CLEAN_UP) free(s);