summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdiskmgt/common/partition.c
diff options
context:
space:
mode:
authorcasper <none@none>2005-11-09 11:19:56 -0800
committercasper <none@none>2005-11-09 11:19:56 -0800
commit4bc0a2ef2b7ba50a7a717e7ddbf31472ad28e358 (patch)
tree8076ef765d7019096fce872c8359a5345dee3160 /usr/src/lib/libdiskmgt/common/partition.c
parent205d86ae4bc9e661871ff365f59324d8c9b0108a (diff)
downloadillumos-joyent-4bc0a2ef2b7ba50a7a717e7ddbf31472ad28e358.tar.gz
6346636 expunge readdir_r uses from Solaris
6346809 S_IFxxx is not a bitmask but our programmers don't know
Diffstat (limited to 'usr/src/lib/libdiskmgt/common/partition.c')
-rw-r--r--usr/src/lib/libdiskmgt/common/partition.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/usr/src/lib/libdiskmgt/common/partition.c b/usr/src/lib/libdiskmgt/common/partition.c
index 32141fc8ac..49fa757330 100644
--- a/usr/src/lib/libdiskmgt/common/partition.c
+++ b/usr/src/lib/libdiskmgt/common/partition.c
@@ -626,21 +626,18 @@ 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 */
@@ -649,17 +646,7 @@ 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) ||
@@ -674,10 +661,9 @@ 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);
}
@@ -689,11 +675,12 @@ 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);
}