65
66
int flag; /* scanning options */
66
67
FILE *proc; /* /proc/partitions */
67
int ncur; /* current possition */
68
int ncur; /* current position */
68
69
int *minors; /* ary of minor numbers (when scan whole /dev) */
69
70
int nminors; /* number of items in *minors */
70
71
char name[128]; /* device name */
285
286
cmpnum(const void *p1, const void *p2)
287
return (* (int *) p1) > (* (int *) p2);
288
return (*(int *) p1 > *(int *) p2) - (*(int *) p1 < *(int *) p2);
291
292
* The classic scandir() is more expensive and less portable.
292
* We needn't full loop device names -- minor numers (loop<N>)
293
* We needn't full loop device names -- minor numbers (loop<N>)
1009
1010
#include <stdarg.h>
1013
fprintf(f, _("\nUsage:\n"
1014
" %1$s loop_device give info\n"
1015
" %1$s -a | --all list all used\n"
1016
" %1$s -d | --detach <loopdev> [<loopdev> ...] delete\n"
1017
" %1$s -f | --find find unused\n"
1018
" %1$s -c | --set-capacity <loopdev> resize\n"
1019
" %1$s -j | --associated <file> [-o <num>] list all associated with <file>\n"
1020
" %1$s [ options ] {-f|--find|loopdev} <file> setup\n"),
1023
fprintf(f, _("\nOptions:\n"
1024
" -e | --encryption <type> enable data encryption with specified <name/num>\n"
1025
" -h | --help this help\n"
1026
" -o | --offset <num> start at offset <num> into file\n"
1027
" --sizelimit <num> loop limited to only <num> bytes of the file\n"
1028
" -p | --pass-fd <num> read passphrase from file descriptor <num>\n"
1029
" -r | --read-only setup read-only loop device\n"
1030
" --show print device name (with -f <file>)\n"
1031
" -v | --verbose verbose mode\n\n"));
1033
exit(f == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
1015
fputs(_("\nUsage:\n"), out);
1017
_(" %1$s loop_device give info\n"
1018
" %1$s -a | --all list all used\n"
1019
" %1$s -d | --detach <loopdev> [<loopdev> ...] delete\n"
1020
" %1$s -f | --find find unused\n"
1021
" %1$s -c | --set-capacity <loopdev> resize\n"
1022
" %1$s -j | --associated <file> [-o <num>] list all associated with <file>\n"
1023
" %1$s [options] {-f|--find|loopdev} <file> setup\n"),
1026
fputs(_("\nOptions:\n"), out);
1027
fputs(_(" -e, --encryption <type> enable data encryption with specified <name/num>\n"
1028
" -h, --help this help\n"
1029
" -o, --offset <num> start at offset <num> into file\n"
1030
" --sizelimit <num> loop limited to only <num> bytes of the file\n"
1031
" -p, --pass-fd <num> read passphrase from file descriptor <num>\n"
1032
" -r, --read-only setup read-only loop device\n"
1033
" --show print device name (with -f <file>)\n"
1034
" -v, --verbose verbose mode\n\n"), out);
1036
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
1044
1047
uintmax_t off = 0, slimit = 0;
1045
struct option longopts[] = {
1049
static const struct option longopts[] = {
1046
1050
{ "all", 0, 0, 'a' },
1047
1051
{ "set-capacity", 0, 0, 'c' },
1048
1052
{ "detach", 0, 0, 'd' },