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