@@ -122,8 +122,7 @@ fail:
static int load_plugins(void)
{
const char *fsdir = getenv("FSIMAGE_FSDIR");
- struct dirent *dp = NULL;
- struct dirent *dpp;
+ struct dirent *de;
DIR *dir = NULL;
char *tmp = NULL;
size_t name_max;
@@ -139,22 +138,17 @@ static int load_plugins(void)
if ((tmp = malloc(name_max + 1)) == NULL)
goto fail;
- if ((dp = malloc(sizeof (struct dirent) + name_max + 1)) == NULL)
- goto fail;
-
if ((dir = opendir(fsdir)) == NULL)
goto fail;
- bzero(dp, sizeof (struct dirent) + name_max + 1);
-
- while (readdir_r(dir, dp, &dpp) == 0 && dpp != NULL) {
- if (strcmp(dpp->d_name, ".") == 0)
+ while ((de = readdir(dir)) != NULL) {
+ if (strcmp(de->d_name, ".") == 0)
continue;
- if (strcmp(dpp->d_name, "..") == 0)
+ if (strcmp(de->d_name, "..") == 0)
continue;
(void) snprintf(tmp, name_max, "%s/%s/fsimage.so", fsdir,
- dpp->d_name);
+ de->d_name);
if (init_plugin(tmp) != 0)
goto fail;
@@ -167,7 +161,6 @@ fail:
if (dir != NULL)
(void) closedir(dir);
free(tmp);
- free(dp);
errno = err;
return (ret);
}