[parted-devel] [PATCH] Dont try to stat stuff that we know does not exist.
Joel Granados Moreno
jgranado at redhat.com
Mon Feb 23 15:20:59 UTC 2009
* libparted/arch/linux.c (_mount_table_search): When we look for stuff in
/proc/mounts, /proc/swaps and /etc/mtab, there is a possibility to
receive none path elements. Like "none", "tmpfs" or
"//servername/path". We are making a system call for each of these
strings when it can be easily avoided. This is most noticeable in
situations that heavily use libparted, like the fedora installer.
---
libparted/arch/linux.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4a8c9e7..24b51d0 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2124,6 +2124,12 @@ _mount_table_search (const char* file_name, dev_t dev)
return 0;
while (fgets (line, 512, file)) {
junk = sscanf (line, "%s", part_name);
+
+ /* We don't care about none paths nor servernames. */
+ if (part_name[0] != '/' ||
+ (part_name[0] == '/' && part_name[1] == '/'))
+ continue;
+
if (stat (part_name, &part_stat) == 0) {
if (part_stat.st_rdev == dev) {
fclose (file);
--
1.6.0.6
More information about the parted-devel
mailing list