summaryrefslogtreecommitdiffstats
path: root/deskutils/cairo-dock-plugins/files/patch-shortcuts
blob: 597e7782fcb398240bcfce909ffe8684f8d931d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--- shortcuts/src/applet-disk-usage.c.orig  2009-09-27 19:14:51.000000000 +0300
+++ shortcuts/src/applet-disk-usage.c   2010-02-03 22:25:09.000000000 +0200
@@ -18,10 +18,18 @@
 */
 
 #include <string.h>
-#include <mntent.h>
 #include <sys/types.h>
-#include <sys/statfs.h>
+#if defined(__FreeBSD__)
+#ifdef HAVE_MNTENT_H
 #include <mntent.h>
+#endif
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#else
+#include <mntent.h>
+#include <sys/statfs.h>
+#endif
 
 #include <cairo-dock.h>
 
@@ -178,18 +186,50 @@
 void cd_shortcuts_get_fs_info (const gchar *cDiskURI, GString *sInfo)
 {
    const gchar *cMountPath = (strncmp (cDiskURI, "file://", 7) == 0 ? cDiskURI + 7 : cDiskURI);
+#if defined(__FreeBSD__)
+   struct statfs *me;
+// FILE *mtab;
+#else
    struct mntent *me;
    FILE *mtab = setmntent ("/etc/mtab", "r");
+#endif
    char *search_path;
    int match;
    char *slash;
 
+#if defined(__FreeBSD__)
+    int i;
+         int count = getfsstat(me, NULL, MNT_WAIT);
+//         int count = getfsstat(me, NULL, MNT_NOWAIT);
+    if (count>0)
+    {
+     for (i=0; i<count; i++)
+     {
+      if (me->f_mntonname && strcmp (me->f_mntonname, cMountPath) == 0)
+      {
+       g_string_append_printf (sInfo, "Mount point : %s\nFile system : %s\nDevice : %s\nMount options : %s",
+                   me->f_mntonname,
+                   me->f_mntfromname,
+                   me->f_fstypename,
+                   me->f_charspare);
+//     if (me->mnt_freq != 0)
+//      g_string_append_printf (sInfo, "\nBackup frequency : %d days", me->mnt_freq);
+       break ;
+      }
+     }
+    }
+    else
+    {
+     cd_warning ("error getfsstat...");
+     return ;
+    }
+#else
    if (mtab == NULL)
    {
        cd_warning ("couldn't open /etc/mtab");
        return ;
    }
-   
+
    gchar *cFsInfo = NULL;
    while ((me = getmntent (mtab)) != NULL)
    {
@@ -205,6 +245,7 @@
            break ;
        }
    }
-   
+
    endmntent (mtab);
+#endif
 }