Revert linux-legacy topic branch.

These changes were made when some development was still occuring
under RHEL4.  Since then the needed fopendir() and atopen() APIs
have become commonly available under Linux.  Since I have no
intention of supporting systems as old as RHEL4 we can safely
drop the topic branch.
This commit is contained in:
Brian Behlendorf 2010-05-18 12:10:13 -07:00
parent 50f5b891f1
commit a056f3de6d
1 changed files with 14 additions and 9 deletions

View File

@ -791,7 +791,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
int i; int i;
DIR *dirp = NULL; DIR *dirp = NULL;
struct dirent64 *dp; struct dirent64 *dp;
char path[MAXPATHLEN], path2[MAXPATHLEN]; char path[MAXPATHLEN];
char *end; char *end;
size_t pathleft; size_t pathleft;
struct stat64 statbuf; struct stat64 statbuf;
@ -818,6 +818,7 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
*/ */
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
char *rdsk; char *rdsk;
int dfd;
/* use realpath to normalize the path */ /* use realpath to normalize the path */
if (realpath(argv[i], path) == 0) { if (realpath(argv[i], path) == 0) {
@ -841,7 +842,8 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
else else
rdsk = path; rdsk = path;
if ((dirp = opendir(rdsk)) == NULL) { if ((dfd = open64(rdsk, O_RDONLY)) < 0 ||
(dirp = fdopendir(dfd)) == NULL) {
zfs_error_aux(hdl, strerror(errno)); zfs_error_aux(hdl, strerror(errno));
(void) zfs_error_fmt(hdl, EZFS_BADPATH, (void) zfs_error_fmt(hdl, EZFS_BADPATH,
dgettext(TEXT_DOMAIN, "cannot open '%s'"), dgettext(TEXT_DOMAIN, "cannot open '%s'"),
@ -858,19 +860,20 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
(name[1] == 0 || (name[1] == '.' && name[2] == 0))) (name[1] == 0 || (name[1] == '.' && name[2] == 0)))
continue; continue;
snprintf(path2, sizeof (path2), "%s%s", rdsk, name); if ((fd = openat64(dfd, name, O_RDONLY)) < 0)
continue;
/* /*
* Ignore failed stats. We only want regular * Ignore failed stats. We only want regular
* files, character devs and block devs. * files, character devs and block devs.
*/ */
if (stat64(path2, &statbuf) != 0 || if (fstat64(fd, &statbuf) != 0 ||
(!S_ISREG(statbuf.st_mode) && (!S_ISREG(statbuf.st_mode) &&
!S_ISBLK(statbuf.st_mode))) !S_ISCHR(statbuf.st_mode) &&
continue; !S_ISBLK(statbuf.st_mode))) {
(void) close(fd);
if ((fd = open64(path2, O_RDONLY)) < 0)
continue; continue;
}
if ((zpool_read_label(fd, &config)) != 0) { if ((zpool_read_label(fd, &config)) != 0) {
(void) close(fd); (void) close(fd);
@ -903,7 +906,9 @@ zpool_find_import_impl(libzfs_handle_t *hdl, int argc, char **argv,
config = NULL; config = NULL;
continue; continue;
} }
if (add_config(hdl, &pools, path2, config) != 0) /* use the non-raw path for the config */
(void) strlcpy(end, name, pathleft);
if (add_config(hdl, &pools, path, config) != 0)
goto error; goto error;
} }
} }