Changes for OSF/1 getmntinfo_r()
CVS patchset: 1708 CVS date: 1997/06/19 22:18:02
This commit is contained in:
parent
5b52e39899
commit
dda52c18d6
|
@ -93,4 +93,7 @@
|
|||
/* Define as one if you have "struct mnttab" (only sco?) */
|
||||
#define HAVE_STRUCT_MNTTAB 0
|
||||
|
||||
/* Define as one if you have getmntinfo_r() (only osf?) */
|
||||
#define HAVE_GETMNTINFO_R 0
|
||||
|
||||
#endif
|
||||
|
|
|
@ -277,8 +277,10 @@ fi
|
|||
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")
|
||||
|
|
45
lib/fs.c
45
lib/fs.c
|
@ -108,19 +108,30 @@ static int getFilesystemList(void) {
|
|||
}
|
||||
#else
|
||||
static int getFilesystemList(void) {
|
||||
our_mntent item, * itemptr;
|
||||
FILE * mtab;
|
||||
int numAlloced = 10;
|
||||
int num = 0;
|
||||
struct stat sb;
|
||||
int i;
|
||||
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
|
||||
|
||||
mtab = fopen(MOUNTED, "r");
|
||||
if (!mtab) {
|
||||
rpmError(RPMERR_MTAB, _("failed to open %s: %s"), MOUNTED,
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
#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));
|
||||
|
||||
|
@ -130,13 +141,18 @@ static int getFilesystemList(void) {
|
|||
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++)
|
||||
|
@ -153,10 +169,15 @@ static int getFilesystemList(void) {
|
|||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define COMMENTCHAR '#'
|
||||
#endif
|
||||
|
||||
#if HAVE_STRUCT_MNTTAB {
|
||||
#if HAVE_STRUCT_MNTTAB
|
||||
our_mntent * getmntent(FILE *filep) {
|
||||
static struct mnttab entry;
|
||||
static our_mntent item = { entry.mt_filsys };
|
||||
|
|
|
@ -62,7 +62,10 @@ extern void *myrealloc(void *, size_t);
|
|||
#define lchown chown
|
||||
#endif
|
||||
|
||||
#if HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
|
||||
#if HAVE_GETMNTINFO_R || HAVE_MNTCTL
|
||||
# define GETMNTENT_ONE 0
|
||||
# define GETMNTENT_TWO 0
|
||||
#elif HAVE_MNTENT_H || !(HAVE_GETMNTENT) || HAVE_STRUCT_MNTTAB
|
||||
# if HAVE_MNTENT_H || HAVE_STRUCT_MNTTAB
|
||||
# include <mntent.h>
|
||||
# define our_mntent struct mntent
|
||||
|
|
Loading…
Reference in New Issue