diff options
author | Karel Zak | 2008-08-01 12:18:03 +0200 |
---|---|---|
committer | Karel Zak | 2008-08-04 13:54:27 +0200 |
commit | edb68d0ca36c54fa5996bfd917eb236780f0ff80 (patch) | |
tree | 3bdadcc76666480f4422b68c3ab880b4210cd18a /include/pathnames.h | |
parent | use getpagesize() (diff) | |
download | kernel-qcow2-util-linux-edb68d0ca36c54fa5996bfd917eb236780f0ff80.tar.gz kernel-qcow2-util-linux-edb68d0ca36c54fa5996bfd917eb236780f0ff80.tar.xz kernel-qcow2-util-linux-edb68d0ca36c54fa5996bfd917eb236780f0ff80.zip |
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 <kzak@redhat.com>
Diffstat (limited to 'include/pathnames.h')
-rw-r--r-- | include/pathnames.h | 1 |
1 files changed, 1 insertions, 0 deletions
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 */ |