From edb68d0ca36c54fa5996bfd917eb236780f0ff80 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 1 Aug 2008 12:18:03 +0200 Subject: losetup: looplist_* refactoring, remove scandir() This patch replaces scandir-based implementation with readdir(). The readdir(3) is less expensive and more portable (to non-glibc environment). The patch also replaces sysfs-based solution with simpler /proc/partitions parsing. The /proc/partitions includes all used loop devices on all systems (include 2.4). This solution seems faster than scandir(/sys/block/) too. Summary, the losetup (with this patch) uses three methods to found a loop device: a) parse /proc/partitions to found already used loop devices (for loserup -a) b) stat(2) for all loop[0-7] devices (default number of loop devices). This is classic method from util-linux <= 2.13. This method is good enough for standard Linux machines with default number of loop devices. c) scan all /dev or /dev/loop/ for loop devices. This is useful for crazy people who need more than 8 loop devices. Signed-off-by: Karel Zak --- include/pathnames.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/pathnames.h') diff --git a/include/pathnames.h b/include/pathnames.h index e171d9369..ad35bf91e 100644 --- a/include/pathnames.h +++ b/include/pathnames.h @@ -73,6 +73,7 @@ #define _PATH_PROC_SWAPS "/proc/swaps" #define _PATH_PROC_FILESYSTEMS "/proc/filesystems" #define _PATH_PROC_MOUNTS "/proc/mounts" +#define _PATH_PROC_PARTITIONS "/proc/partitions" #ifndef _PATH_MOUNTED # ifdef MOUNTED /* deprecated */ -- cgit v1.2.3-55-g7522