]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: libxcmd: ignore errors when initializing fs_table
authorAlex Elder <aelder@sgi.com>
Mon, 3 Oct 2011 12:49:20 +0000 (12:49 +0000)
committerAlex Elder <aelder@sgi.com>
Thu, 6 Oct 2011 20:19:32 +0000 (15:19 -0500)
When initializing fs_table, the full set of mounted filesystems and
the full set of defined projects are (or may be) examined.  If an
error ever occurs looking at one of these entries, the processing
loop just quits, skipping all remaining mounts or projects.

One mount or project being problematic is no reason to give
up entirely.  It may be that it is completely unrelated to
the mount point or project that the user wants to operate on.

So instead of quitting when an error occurs while adding
something to fs_table, proceed until all entries are added.

Meanwhile, the two affected functions are used for either
installing one entry in the table or for initializing the
table based on the full set of mounts or projects.  In
the former case, once the entry matching that was requested
has been found there is no need to continue searching for
other entries, so break out of the loop immediately in
that case.

It so happens that these two changes affect the exact
same portion of the code...

SGI PV 1017024

Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxcmd/paths.c

index 15b95bd445153b1ce7ff6d04dd4d233c0714d309..2a922990a949a84d655d5d59861992ac8b9a3d30 100644 (file)
@@ -293,16 +293,17 @@ fs_table_initialise_mounts(
                    ((strcmp(path, mnt->mnt_dir) != 0) &&
                     (strcmp(path, mnt->mnt_fsname) != 0)))
                        continue;
-               found = 1;
                if (fs_extract_mount_options(mnt, &fslog, &fsrt))
                        continue;
-               error = fs_table_insert(mnt->mnt_dir, 0, FS_MOUNT_POINT,
+               (void) fs_table_insert(mnt->mnt_dir, 0, FS_MOUNT_POINT,
                                        mnt->mnt_fsname, fslog, fsrt);
-               if (error)
+               if (path) {
+                       found = 1;
                        break;
+               }
        }
        endmntent(mtp);
-       if (!error && path && !found)
+       if (path && !found)
                error = ENXIO;
 
        return error;
@@ -332,15 +333,16 @@ fs_table_initialise_mounts(
                    ((strcmp(path, stats[i].f_mntonname) != 0) &&
                     (strcmp(path, stats[i].f_mntfromname) != 0)))
                        continue;
-               found = 1;
                /* TODO: external log and realtime device? */
-               error = fs_table_insert(stats[i].f_mntonname, 0,
+               (void) fs_table_insert(stats[i].f_mntonname, 0,
                                        FS_MOUNT_POINT, stats[i].f_mntfromname,
                                        NULL, NULL);
-               if (error)
+               if (path) {
+                       found = 1;
                        break;
+               }
        }
-       if (!error && path && !found)
+       if (path && !found)
                error = ENXIO;
 
        return error;
@@ -406,16 +408,17 @@ fs_table_initialise_projects(
                                        progname, path->pp_pathname, strerror(errno));
                        continue;
                }
-               found = 1;
-               error = fs_table_insert(path->pp_pathname, path->pp_prid,
+               (void) fs_table_insert(path->pp_pathname, path->pp_prid,
                                        FS_PROJECT_PATH, fs->fs_name,
                                        NULL, NULL);
-               if (error)
+               if (project) {
+                       found = 1;
                        break;
+               }
        }
        endprpathent();
 
-       if (!error && project && !found)
+       if (project && !found)
                error = ENOENT;
 
        return error;