Bacula(R) - The Network Backup Solution
Copyright (C) 2000-2015 Kern Sibbald
- Copyright (C) 2004-2014 Free Software Foundation Europe e.V.
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;
*/
#if defined(HAVE_DARWIN_OS) \
|| defined(HAVE_FREEBSD_OS ) \
+ || defined(HAVE_KFREEBSD_OS ) \
|| defined(HAVE_OPENBSD_OS)
#include <sys/param.h>
if (statfs(fname, &st) == 0) {
mtab_item *item, search_item;
- if (ff_pkt->last_fstypename && ff_pkt->last_fstype == (uint64_t)st.f_type) {
+ if (*ff_pkt->last_fstypename && ff_pkt->last_fstype == (uint64_t)st.f_type) {
bstrncpy(fs, ff_pkt->last_fstypename, fslen);
return true;
}
item = (mtab_item *)ff_pkt->mtab_list->search((void *)&search_item, compare_mtab_items);
if (item) {
ff_pkt->last_fstype = st.f_type;
- bstrncpy(ff_pkt->last_fstypename, item->fstype, sizeof(ff_pkt->last_fstype));
+ 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 0x7275: fstype = "romfs"; break; /* QNX4_SUPER_MAGIC */
case 0x012ff7b6: fstype = "sysv2"; break;
case 0x012ff7b5: fstype = "sysv4"; break;
- case 0x01021994: fstype = "tempfs"; break;
+ case 0x01021994: fstype = "tmpfs"; break;
case 0x15013346: fstype = "udf"; break;
case 0x00011954: fstype = "ufs"; break;
case 0xa501FCF5: fstype = "vxfs"; break;
case 0x012FF7B4: fstype = "xenix"; break;
case 0x012FD16D: fstype = "xiafs"; break;
-
+ case 0x9123683e: fstype = "btrfs"; break;
#if 0 /* These need confirmation */
case 0x6B414653: fstype = "afs"; break; /* AFS_FS_MAGIC */
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);
/* 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)
{