The function fs_device_number() in libxcmd allows the caller to optionally "search" in /dev for a given device path in order to look up the dev_t that represents that device path. If set, all that function does is prepend "/dev/" to the path to see if that produces a device path that works. So it appears this might have been to support providing just the basename of a device as a shorthand for its full path. In practice, the paths passed to this function with "search" set are those used in the mount options for a mounted XFS filesystem for the optional log and real-time device paths. When such paths are used in the XFS mount path, they will have been subject to a AT_FDCWD path lookup, so unless the process mounting the filesystem was sitting in /dev no relative path would ever be specified as just the basename. Even though the "mounting with CWD=/dev" is a conceivable scenario, I think it is not likely enough to warrant the special handling to cover that case in fs_device_number(). So delete the code that retries with a "/dev" prepended, eliminate the "search" argument that enables it, and fix the callers accordingly. Signed-off-by: Alex Elder <aelder@xxxxxxx> --- libxcmd/paths.c | 33 +++++++-------------------------- 1 files changed, 7 insertions(+), 26 deletions(-) diff --git a/libxcmd/paths.c b/libxcmd/paths.c index 5aa343b..f1cd6c7 100644 --- a/libxcmd/paths.c +++ b/libxcmd/paths.c @@ -76,33 +76,14 @@ fs_table_lookup( static char * fs_device_number( char *name, - dev_t *devnum, - int search) + dev_t *devnum) { struct stat64 sbuf; - int len; - - if (stat64(name, &sbuf) < 0) { - if (!search) - return NULL; - len = strlen(name) + 1; - name = realloc(name, len + 5); /* "/dev/ */ - if (!name) { - fprintf(stderr, _("%s: warning - out of memory\n"), - progname); - return NULL; - } - memmove(name + 5, name, len); - strncpy(name, "/dev/", 5); - if (stat64(name, &sbuf) < 0) { - fprintf(stderr, - _("%s: warning - cannot find %s: %s\n"), - progname, name, strerror(errno)); - free(name); - return NULL; - } - } + + if (stat64(name, &sbuf) < 0) + return NULL; *devnum = sbuf.st_dev; + return name; } @@ -122,11 +103,11 @@ fs_table_insert( return EINVAL; datadev = logdev = rtdev = 0; - if (!fs_device_number(dir, &datadev, 0)) + if (!fs_device_number(dir, &datadev)) return errno; - if (fslog && (fslog = fs_device_number(fslog, &logdev, 1)) == NULL) + if (fslog && !fs_device_number(fslog, &logdev)) return errno; - if (fsrt && (fsrt = fs_device_number(fsrt, &rtdev, 1)) == NULL) + if (fsrt && !fs_device_number(fsrt, &rtdev)) return errno; tmp_fs_table = realloc(fs_table, sizeof(fs_path_t) * (fs_count + 1)); -- 1.7.6.2 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs