From 0b193a787194549bbf22ff6f5db7a52f41da69ef Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 29 Sep 2006 21:47:11 +0000 Subject: losetup: use /dev/loopN or /dev/loop/N according to CONFIG_FEATURE_DEVFS=n/y --- include/libbb.h | 2 ++ util-linux/losetup.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 05927f1de..67cf4939c 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -442,6 +442,7 @@ extern int bb_default_error_retval; #endif # define VC_FORMAT "/dev/vc/%d" # define LOOP_FORMAT "/dev/loop/%d" +# define LOOP_NAME "/dev/loop/" # define FB_0 "/dev/fb/0" #else # define CURRENT_VC "/dev/tty0" @@ -461,6 +462,7 @@ extern int bb_default_error_retval; #endif # define VC_FORMAT "/dev/tty%d" # define LOOP_FORMAT "/dev/loop%d" +# define LOOP_NAME "/dev/loop" # define FB_0 "/dev/fb0" #endif diff --git a/util-linux/losetup.c b/util-linux/losetup.c index 6b9a810f2..54a160119 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c @@ -48,11 +48,11 @@ int losetup_main(int argc, char **argv) printf("%s: %s\n", argv[0], s); if (ENABLE_FEATURE_CLEAN_UP) free(s); } else { - char dev[11] = "/dev/loop0"; + char dev[sizeof(LOOP_NAME"0")] = LOOP_NAME"0"; char c; for (c = '0'; c <= '9'; ++c) { char *s; - dev[9] = c; + dev[sizeof(LOOP_NAME"0")-2] = c; s = query_loop(dev); if (s) { printf("%s: %s\n", dev, s); -- cgit v1.2.3