/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2015 Kern Sibbald
- Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2017 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
return 0;
}
-void add_mtab_item(void *user_ctx, struct stat *st, const char *fstype,
- const char *mountpoint, const char *mntopts,
- const char *fsname)
+static void add_mtab_item(void *user_ctx, struct stat *st, const char *fstype,
+ const char *mountpoint, const char *mntopts,
+ const char *fsname)
{
rblist *mtab_list = (rblist *)user_ctx;
mtab_item *item, *ritem;
ff_pkt->last_fstype = st.f_type;
bstrncpy(ff_pkt->last_fstypename, item->fstype, sizeof(ff_pkt->last_fstypename));
bstrncpy(fs, ff_pkt->last_fstypename, fslen);
- return true;
+ return true;
}
/*
* Values obtained from statfs(2), testing and
case 0x858458f6: fstype = "tmpfs"; break; /* RAMFS_MAGIC */
case 0x01021994: fstype = "tmpfs"; break; /* TMPFS_MAGIC */
#endif
-
+
default:
Dmsg2(10, "Unknown file system type \"0x%x\" for \"%s\".\n", st.f_type,
fname);
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/mtab.h>
bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
{
/* Tru64 */
#include <sys/stat.h>
#include <sys/mount.h>
-
+
bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
{
char *fname = ff_pkt->fname;
/* Read mtab entries */
bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx)
{
-#ifdef HAVE_GETMNTENT
+/* Debian stretch GNU/KFreeBSD has both getmntinfo and getmntent, but
+ only the first seems to work, so ordering is important here */
+#ifdef HAVE_GETMNTINFO
+ struct stat st;
+#if defined(ST_NOWAIT)
+ int flags = ST_NOWAIT;
+#elif defined(MNT_NOWAIT)
+ int flags = MNT_NOWAIT;
+#else
+ int flags = 0;
+#endif
+#if defined(HAVE_NETBSD_OS)
+ struct statvfs *mntinfo;
+#else
+ struct statfs *mntinfo;
+#endif
+ int nument;
+
+ P(mutex);
+ if ((nument = getmntinfo(&mntinfo, flags)) > 0) {
+ while (nument-- > 0) {
+ if (is_rootfs(mntinfo->f_fstypename)) {
+ continue;
+ }
+ if (stat(mntinfo->f_mntonname, &st) < 0) {
+ continue;
+ }
+ mtab_handler(user_ctx, &st, mntinfo->f_mntfromname,
+ mntinfo->f_mntonname, mntinfo->f_fstypename, NULL);
+ mntinfo++;
+ }
+ }
+ V(mutex);
+/* HAVE_GETMNTINFO */
+#elif defined(HAVE_GETMNTENT)
FILE *mntfp;
struct stat st;
#endif
#endif /* HAVE_GETMNTENT */
-
-#ifdef HAVE_GETMNTINFO
- struct stat st;
-#if defined(ST_NOWAIT)
- int flags = ST_NOWAIT;
-#elif defined(MNT_NOWAIT)
- int flags = MNT_NOWAIT;
-#else
- int flags = 0;
-#endif
-#if defined(HAVE_NETBSD_OS)
- struct statvfs *mntinfo;
-#else
- struct statfs *mntinfo;
-#endif
- int nument;
-
- P(mutex);
- if ((nument = getmntinfo(&mntinfo, flags)) > 0) {
- while (nument-- > 0) {
- if (is_rootfs(mntinfo->f_fstypename)) {
- continue;
- }
- if (stat(mntinfo->f_mntonname, &st) < 0) {
- continue;
- }
- mtab_handler(user_ctx, &st, mntinfo->f_mntfromname,
- mntinfo->f_mntonname, mntinfo->f_fstypename, NULL);
- mntinfo++;
- }
- }
- V(mutex);
-#endif /* HAVE_GETMNTINFO */
return true;
}
-
+
#ifdef TEST_PROGRAM
int main(int argc, char **argv)
{