From 4bc0a2ef2b7ba50a7a717e7ddbf31472ad28e358 Mon Sep 17 00:00:00 2001 From: casper Date: Wed, 9 Nov 2005 11:19:56 -0800 Subject: 6346636 expunge readdir_r uses from Solaris 6346809 S_IFxxx is not a bitmask but our programmers don't know --- usr/src/lib/libdiskmgt/common/drive.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'usr/src/lib/libdiskmgt/common/drive.c') diff --git a/usr/src/lib/libdiskmgt/common/drive.c b/usr/src/lib/libdiskmgt/common/drive.c index aed1db3b59..b3f32c70d6 100644 --- a/usr/src/lib/libdiskmgt/common/drive.c +++ b/usr/src/lib/libdiskmgt/common/drive.c @@ -658,21 +658,18 @@ drive_open_disk(disk_t *diskp, char *opath, int len) return (-1); } - if (buf.st_mode & S_IFCHR) { + if (S_ISCHR(buf.st_mode)) { /* opened, is device, so done */ if (opath != NULL) { (void) strlcpy(opath, rmmedia_devpath, len); } return (fd); - } else if (buf.st_mode & S_IFDIR) { + } else if (S_ISDIR(buf.st_mode)) { /* disk w/ slices so handle the directory */ DIR *dirp; struct dirent *dentp; int dfd; -#ifdef _LP64 - struct dirent *result; -#endif /* each device file in the dir represents a slice */ @@ -681,17 +678,7 @@ drive_open_disk(disk_t *diskp, char *opath, int len) return (-1); } - if ((dentp = (struct dirent *)malloc(sizeof (struct dirent) + - PATH_MAX + 1)) == NULL) { - /* out of memory */ - (void) close(fd); - return (-1); - } -#ifdef _LP64 - while (readdir_r(dirp, dentp, &result) != NULL) { -#else - while (readdir_r(dirp, dentp) != NULL) { -#endif + while ((dentp = readdir(dirp)) != NULL) { char slice_path[MAXPATHLEN]; if (libdiskmgt_str_eq(".", dentp->d_name) || @@ -706,10 +693,9 @@ drive_open_disk(disk_t *diskp, char *opath, int len) continue; } - if (fstat(dfd, &buf) == 0 && (buf.st_mode & S_IFCHR)) { + if (fstat(dfd, &buf) == 0 && S_ISCHR(buf.st_mode)) { /* opened, is device, so done */ - free(dentp); - (void) close(fd); + (void) closedir(dirp); if (opath != NULL) { (void) strlcpy(opath, slice_path, len); } @@ -721,11 +707,12 @@ drive_open_disk(disk_t *diskp, char *opath, int len) } /* did not find a device under the rmmedia_path */ - free(dentp); - (void) close(fd); + (void) closedir(dirp); + return (-1); } /* didn't find a device under volume management control */ + (void) close(fd); return (-1); } -- cgit v1.2.3