dnl Checks for library functions.
AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON), MISCOBJS="$MISCOBJS inet_aton.o")
AC_CHECK_FUNC(realpath, AC_DEFINE(HAVE_REALPATH), MISCOBJS="$MISCOBJS realpath.o")
-AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), MISCOBJS="$MISCOBJS getmntent.o")
-AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL))
+AC_CHECK_FUNC(getmntent, AC_DEFINE(HAVE_GETMNTENT), [
+ AC_CHECK_FUNC(mntctl, AC_DEFINE(HAVE_MNTCTL),[
+ AC_CHECK_FUNC(getmntinfo_r, AC_DEFINE(HAVE_GETMNTINFO_R),
+ MISCOBJS="$MISCOBJS getmntent.o") ])])
AC_CHECK_FUNC(strerror, [], MISCOBJS="$MISCOBJS strerror.o")
AC_CHECK_FUNC(strtol, [], MISCOBJS="$MISCOBJS strtol.o")
AC_CHECK_FUNC(strtoul, [], MISCOBJS="$MISCOBJS strtoul.o")
}
#else
static int getFilesystemList(void) {
- our_mntent item, * itemptr;
- FILE * mtab;
int numAlloced = 10;
int num = 0;
struct stat sb;
int i;
-
- mtab = fopen(MOUNTED, "r");
- if (!mtab) {
- rpmError(RPMERR_MTAB, _("failed to open %s: %s"), MOUNTED,
- strerror(errno));
- return 1;
- }
+ char * mntdir;
+ #if GETMNTENT_ONE || GETMNTENT_TWO
+ our_mntent item, * itemptr;
+ FILE * mtab;
+ #elif HAVE_GETMNTINFO_R
+ struct statfs * mounts = NULL;
+ int mntCount = 0, bufSize = 0, flags = MNT_NOWAIT;
+ int nextMount = 0;
+ #endif
+
+ #if GETMNTENT_ONE || GETMNTENT_TWO
+ mtab = fopen(MOUNTED, "r");
+ if (!mtab) {
+ rpmError(RPMERR_MTAB, _("failed to open %s: %s"), MOUNTED,
+ strerror(errno));
+ return 1;
+ }
+ #elif HAVE_GETMNTINFO_R
+ getmntinfo_r(&mounts, flags, &mntCount, &bufSize);
+ #endif
filesystems = malloc(sizeof(*filesystems) * (numAlloced + 1));
itemptr = getmntent(mtab);
if (!itemptr) break;
item = *itemptr;
+ mntdir = item.our_mntdir;
#elif GETMNTENT_TWO
/* Solaris, maybe others */
if (getmntent(mtab, &item)) break;
+ mntdir = item.our_mntdir;
+ #elif HAVE_GETMNTINFO_R
+ if (nextMount == mntCount) break;
+ mntdir = mounts[nextMount++].f_mntonname;
#endif
- if (stat(item.our_mntdir, &sb)) {
- rpmError(RPMERR_STAT, "failed to stat %s: %s", item.our_mntdir,
+ if (stat(mntdir, &sb)) {
+ rpmError(RPMERR_STAT, "failed to stat %s: %s", mntdir,
strerror(errno));
for (i = 0; i < num; i++)
}
filesystems[num].dev = sb.st_dev;
- filesystems[num++].mntPoint = strdup(item.our_mntdir);
+ filesystems[num++].mntPoint = strdup(mntdir);
}
- fclose(mtab);
+ #if GETMNTENT_ONE || GETMNTENT_TWO
+ fclose(mtab);
+ #elif HAVE_GETMNTINFO_R
+ free(mounts);
+ #endif
+
filesystems[num].mntPoint = NULL;
fsnames = malloc(sizeof(*fsnames) * (num + 1));