summaryrefslogtreecommitdiff
path: root/sysutils/gworkspace/patches/patch-aa
blob: 1adb1f645eae14caae3e57261c21e90ecf9b3863 (plain)
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
85
86
87
88
89
90
91
92
93
$NetBSD: patch-aa,v 1.4 2005/05/02 06:35:55 rh Exp $

--- GWorkspace/Desktop/GWDesktopManager.m.orig	2005-04-01 09:43:39.000000000 +1000
+++ GWorkspace/Desktop/GWDesktopManager.m
@@ -31,6 +31,12 @@
 #include "GWorkspace.h"
 #include "GWViewersManager.h"
 #include "TShelf/TShelfWin.h"
+#include <sys/types.h>
+#include <sys/param.h>
+
+#if (defined(BSD) && BSD >= 199306)
+#include <sys/statvfs.h>
+#endif
 
 #define RESV_MARGIN 10
 
@@ -748,9 +754,31 @@ static GWDesktopManager *desktopManager 
   }
 
   if (removables == nil) {
+#if (defined(BSD) && BSD >= 199306)
+    removables = [NSArray arrayWithObjects: @"/mnt", nil];
+#else
     removables = [NSArray arrayWithObjects: @"/mnt/floppy", @"/mnt/cdrom", nil];
+#endif
   }
   
+#if (defined(BSD) && BSD >= 199306)
+  struct statvfs *mntbuf;
+  int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+
+  for (i = 0; i < mntsize; i++) {
+    if (strcmp(mntbuf[i].f_mntfromname, [fullPath cString]) == 0 ||
+        strcmp(mntbuf[i].f_mntonname,   [fullPath cString]) == 0) {
+      *removableFlag = [removables containsObject:
+                        [NSString stringWithCString: mntbuf[i].f_mntonname]];
+      *writableFlag = ( mntbuf[i].f_flag & MNT_RDONLY ) ? NO : YES;
+      *unmountableFlag = YES;
+      *fileSystemType = [NSString stringWithCString: mntbuf[i].f_fstypename];
+      *description = *fileSystemType;
+          
+      return YES;
+    }
+  }
+#else /* !BSD */
   mtab = [NSString stringWithContentsOfFile: mtabpath];
   mounts = [mtab componentsSeparatedByString: @"\n"];
 
@@ -782,6 +810,7 @@ static GWDesktopManager *desktopManager 
       }
     }
   }
+#endif
 
   return NO;
 }
@@ -801,11 +830,27 @@ static GWDesktopManager *desktopManager 
   }
 
   if (reserved == nil) {
+#if (defined(BSD) && BSD >= 199306)
+    reserved = [NSArray arrayWithObjects: @"procfs", @"kernfs", nil];
+#else
     reserved = [NSArray arrayWithObjects: @"proc", @"devpts", @"shm", 
                                     @"usbdevfs", @"devpts", 
                                     @"sysfs", @"tmpfs", nil];
+#endif
   }
 
+#if (defined(BSD) && BSD >= 199306)
+  names = [NSMutableArray array];
+  struct statvfs *mntbuf;
+  int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+
+  for (i = 0; i < mntsize; i++) {
+    if ([reserved containsObject: [NSString stringWithCString:
+                                  mntbuf[i].f_fstypename]] == NO) {
+      [names addObject: [NSString stringWithCString: mntbuf[i].f_mntonname]];
+    }
+  }
+#else
   mtab = [NSString stringWithContentsOfFile: mtabpath];
   mounts = [mtab componentsSeparatedByString: @"\n"];
   names = [NSMutableArray array];
@@ -825,6 +870,7 @@ static GWDesktopManager *desktopManager 
       }
     } 
   }
+#endif
 
   return names;
 }