]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/findlib/fstype.c
Tweak update copyright
[bacula/bacula] / bacula / src / findlib / fstype.c
index c2bc83d7d420a8a1789f9aa0a90962934ee1103d..4fc4f2669bcfd3ac2dedf8fcf4dbe6d273138a1c 100644 (file)
@@ -2,7 +2,6 @@
    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.
@@ -68,9 +67,9 @@ static int compare_mtab_items(void *item1, void *item2)
    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;
@@ -103,6 +102,7 @@ bool fstype_cmp(FF_PKT *ff_pkt, const char *fsname)
  */
 #if defined(HAVE_DARWIN_OS) \
    || defined(HAVE_FREEBSD_OS ) \
+   || defined(HAVE_KFREEBSD_OS ) \
    || defined(HAVE_OPENBSD_OS)
 
 #include <sys/param.h>
@@ -176,7 +176,7 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
 
    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; 
       }
@@ -188,9 +188,9 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       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
@@ -237,13 +237,13 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       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 */
@@ -272,7 +272,7 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
       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);
@@ -303,7 +303,7 @@ 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;
@@ -337,7 +337,41 @@ bool fstype(FF_PKT *ff_pkt, char *fs, int fslen)
 /* 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;
  
@@ -389,42 +423,9 @@ bool read_mtab(mtab_handler_t *mtab_handler, void *user_ctx)
 #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)
 {