[parted-devel] [PATCH] Dont try to stat stuff that we know does not exist.

Joel Granados Moreno jgranado at redhat.com
Thu Feb 19 15:53:11 UTC 2009


    modified:   libparted/arch/linux.c:  When we look for stuff in
    /proc/mounts, /proc/swaps and /etc/mtab, there is a possibility to
    receive none path elements.  Like "none" or "tmpfs".  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 |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 4a8c9e7..a36017d 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2124,6 +2124,8 @@ _mount_table_search (const char* file_name, dev_t dev)
                 return 0;
         while (fgets (line, 512, file)) {
                 junk = sscanf (line, "%s", part_name);
+                if (part_name[0] != '/')
+                        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