| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | $NetBSD: patch-panel-plugin_devices.c,v 1.2 2017/06/20 22:35:59 youri Exp $ | | 1 | $NetBSD: patch-panel-plugin_devices.c,v 1.3 2017/06/24 14:20:40 youri Exp $ |
2 | | | 2 | |
3 | Fix NetBSD build. | | 3 | Fix NetBSD build. |
4 | Add SunOS support. | | 4 | Add SunOS support. |
5 | | | 5 | |
6 | --- panel-plugin/devices.c.orig 2017-01-28 15:03:36.000000000 +0000 | | 6 | --- panel-plugin/devices.c.orig 2017-01-28 15:03:36.000000000 +0000 |
7 | +++ panel-plugin/devices.c | | 7 | +++ panel-plugin/devices.c |
8 | @@ -25,7 +25,12 @@ Foundation, Inc., 675 Mass Ave, Cambridg | | 8 | @@ -25,7 +25,12 @@ Foundation, Inc., 675 Mass Ave, Cambridg |
9 | #include <config.h> | | 9 | #include <config.h> |
10 | #endif | | 10 | #endif |
11 | | | 11 | |
12 | +#ifdef __sun | | 12 | +#ifdef __sun |
13 | +#include <stdio.h> | | 13 | +#include <stdio.h> |
14 | +#include <sys/vfstab.h> | | 14 | +#include <sys/vfstab.h> |
| @@ -40,43 +40,52 @@ Add SunOS support. | | | @@ -40,43 +40,52 @@ Add SunOS support. |
40 | +#endif | | 40 | +#endif |
41 | + | | 41 | + |
42 | #include <libxfce4panel/xfce-panel-plugin.h> | | 42 | #include <libxfce4panel/xfce-panel-plugin.h> |
43 | #include <libxfce4util/libxfce4util.h> | | 43 | #include <libxfce4util/libxfce4util.h> |
44 | #include <libxfce4ui/libxfce4ui.h> | | 44 | #include <libxfce4ui/libxfce4ui.h> |
45 | @@ -57,7 +71,6 @@ t_mount_info * mount_info_new_from_stat | | 45 | @@ -57,7 +71,6 @@ t_mount_info * mount_info_new_from_stat |
46 | | | 46 | |
47 | #define MTAB "/etc/mtab" | | 47 | #define MTAB "/etc/mtab" |
48 | | | 48 | |
49 | - | | 49 | - |
50 | /** | | 50 | /** |
51 | * Return a string containing a size expressed in KB, MB or GB and the unit | | 51 | * Return a string containing a size expressed in KB, MB or GB and the unit |
52 | * it is expressed in. | | 52 | * it is expressed in. |
53 | @@ -468,7 +481,15 @@ disks_new (gboolean include_NFSs, gboole | | 53 | @@ -268,6 +281,8 @@ disk_mount (t_disk *pdisk, char *on_moun |
| | | 54 | } |
| | | 55 | else |
| | | 56 | cmd = g_strconcat ("eject -t ", pdisk->device, NULL); |
| | | 57 | +#elif __NetBSD__ |
| | | 58 | + cmd = g_strconcat ("eject cd", NULL); |
| | | 59 | #else |
| | | 60 | cmd = g_strconcat ("eject -t ", pdisk->device, NULL); |
| | | 61 | #endif |
| | | 62 | @@ -468,7 +483,15 @@ disks_new (gboolean include_NFSs, gboole |
54 | { | | 63 | { |
55 | GPtrArray * pdisks; /* to be returned */ | | 64 | GPtrArray * pdisks; /* to be returned */ |
56 | t_disk * pdisk; | | 65 | t_disk * pdisk; |
57 | +#ifdef __sun | | 66 | +#ifdef __sun |
58 | + struct vfstab *pfstab; | | 67 | + struct vfstab *pfstab; |
59 | + FILE *fd = NULL; | | 68 | + FILE *fd = NULL; |
60 | + fd = fopen(VFSTAB, "r"); | | 69 | + fd = fopen(VFSTAB, "r"); |
61 | + if (fd == NULL) | | 70 | + if (fd == NULL) |
62 | + return NULL; | | 71 | + return NULL; |
63 | +#else | | 72 | +#else |
64 | struct fstab *pfstab; | | 73 | struct fstab *pfstab; |
65 | +#endif | | 74 | +#endif |
66 | gboolean has_valid_mount_device; | | 75 | gboolean has_valid_mount_device; |
67 | | | 76 | |
68 | pdisks = g_ptr_array_new(); | | 77 | pdisks = g_ptr_array_new(); |
69 | @@ -501,23 +522,46 @@ disks_new (gboolean include_NFSs, gboole | | 78 | @@ -501,23 +524,46 @@ disks_new (gboolean include_NFSs, gboole |
70 | } | | 79 | } |
71 | | | 80 | |
72 | | | 81 | |
73 | +#ifdef __sun | | 82 | +#ifdef __sun |
74 | + for (getvfsent(fd, pfstab); pfstab!=NULL; getvfsent(fd, pfstab)) | | 83 | + for (getvfsent(fd, pfstab); pfstab!=NULL; getvfsent(fd, pfstab)) |
75 | +#else | | 84 | +#else |
76 | for (pfstab = getfsent(); pfstab!=NULL; pfstab = getfsent()) | | 85 | for (pfstab = getfsent(); pfstab!=NULL; pfstab = getfsent()) |
77 | +#endif | | 86 | +#endif |
78 | { | | 87 | { |
79 | has_valid_mount_device = | | 88 | has_valid_mount_device = |
80 | +#ifdef __sun | | 89 | +#ifdef __sun |
81 | + g_str_has_prefix(pfstab->vfs_special, "/dev/") || g_str_has_prefix(pfstab->vfs_special, "UUID=") || g_str_has_prefix(pfstab->vfs_special, "LABEL="); | | 90 | + g_str_has_prefix(pfstab->vfs_special, "/dev/") || g_str_has_prefix(pfstab->vfs_special, "UUID=") || g_str_has_prefix(pfstab->vfs_special, "LABEL="); |
82 | +#else | | 91 | +#else |
| @@ -103,186 +112,186 @@ Add SunOS support. | | | @@ -103,186 +112,186 @@ Add SunOS support. |
103 | + if ( has_valid_mount_device && | | 112 | + if ( has_valid_mount_device && |
104 | + g_str_has_prefix(pfstab->vfs_mountp, "/") ) { | | 113 | + g_str_has_prefix(pfstab->vfs_mountp, "/") ) { |
105 | + pdisk = disk_new (pfstab->vfs_special, pfstab->vfs_mountp, length); | | 114 | + pdisk = disk_new (pfstab->vfs_special, pfstab->vfs_mountp, length); |
106 | + pdisk->dc = disk_classify (pfstab->vfs_special, pfstab->vfs_mountp); | | 115 | + pdisk->dc = disk_classify (pfstab->vfs_special, pfstab->vfs_mountp); |
107 | +#else | | 116 | +#else |
108 | if ( has_valid_mount_device && | | 117 | if ( has_valid_mount_device && |
109 | g_str_has_prefix(pfstab->fs_file, "/") ) { | | 118 | g_str_has_prefix(pfstab->fs_file, "/") ) { |
110 | pdisk = disk_new (pfstab->fs_spec, pfstab->fs_file, length); | | 119 | pdisk = disk_new (pfstab->fs_spec, pfstab->fs_file, length); |
111 | pdisk->dc = disk_classify (pfstab->fs_spec, pfstab->fs_file); | | 120 | pdisk->dc = disk_classify (pfstab->fs_spec, pfstab->fs_file); |
112 | +#endif | | 121 | +#endif |
113 | if (!device_or_mountpoint_exists(pdisks, pdisk)) | | 122 | if (!device_or_mountpoint_exists(pdisks, pdisk)) |
114 | g_ptr_array_add (pdisks , pdisk); | | 123 | g_ptr_array_add (pdisks , pdisk); |
115 | | | 124 | |
116 | @@ -525,6 +569,9 @@ disks_new (gboolean include_NFSs, gboole | | 125 | @@ -525,6 +571,9 @@ disks_new (gboolean include_NFSs, gboole |
117 | | | 126 | |
118 | } /* end for */ | | 127 | } /* end for */ |
119 | | | 128 | |
120 | +#ifdef __sun | | 129 | +#ifdef __sun |
121 | + fclose(fd); | | 130 | + fclose(fd); |
122 | +#endif | | 131 | +#endif |
123 | endfsent(); /* close file */ | | 132 | endfsent(); /* close file */ |
124 | | | 133 | |
125 | return pdisks; | | 134 | return pdisks; |
126 | @@ -746,7 +793,11 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 135 | @@ -746,7 +795,11 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
127 | | | 136 | |
128 | #ifdef HAVE_GETMNTENT | | 137 | #ifdef HAVE_GETMNTENT |
129 | FILE * fmtab = NULL; /* file /etc/mtab */ | | 138 | FILE * fmtab = NULL; /* file /etc/mtab */ |
130 | +#ifdef __sun | | 139 | +#ifdef __sun |
131 | + struct mnttab * pmntent = NULL; | | 140 | + struct mnttab * pmntent = NULL; |
132 | +#else | | 141 | +#else |
133 | struct mntent * pmntent = NULL; /* struct for mnt info */ | | 142 | struct mntent * pmntent = NULL; /* struct for mnt info */ |
134 | +#endif | | 143 | +#endif |
135 | #elif defined (HAVE_GETMNTINFO) | | 144 | #elif defined (HAVE_GETMNTINFO) |
136 | int i, nb_mounted_fs = 0; | | 145 | int i, nb_mounted_fs = 0; |
137 | #endif | | 146 | #endif |
138 | @@ -766,7 +817,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 147 | @@ -766,7 +819,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
139 | pstatfs = g_new0 (struct statfs, 1); | | 148 | pstatfs = g_new0 (struct statfs, 1); |
140 | | | 149 | |
141 | /* open file */ | | 150 | /* open file */ |
142 | +#ifdef __sun | | 151 | +#ifdef __sun |
143 | + fmtab = fopen(MTAB, "r"); | | 152 | + fmtab = fopen(MTAB, "r"); |
144 | + if (fmtab == NULL) | | 153 | + if (fmtab == NULL) |
145 | + return; | | 154 | + return; |
146 | +#else | | 155 | +#else |
147 | fmtab = setmntent (MTAB, "r"); /* mtab file */ | | 156 | fmtab = setmntent (MTAB, "r"); /* mtab file */ |
148 | +#endif | | 157 | +#endif |
149 | #elif defined (HAVE_GETMNTINFO) | | 158 | #elif defined (HAVE_GETMNTINFO) |
150 | /* get mounted fs */ | | 159 | /* get mounted fs */ |
151 | nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT); | | 160 | nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT); |
152 | @@ -774,11 +831,19 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 161 | @@ -774,11 +833,19 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
153 | | | 162 | |
154 | /* start looking for mounted devices */ | | 163 | /* start looking for mounted devices */ |
155 | #ifdef HAVE_GETMNTENT | | 164 | #ifdef HAVE_GETMNTENT |
156 | +#ifdef __sun | | 165 | +#ifdef __sun |
157 | + for (getmntent(fmtab, pmntent); pmntent!=NULL; getmntent(fmtab, pmntent)) { | | 166 | + for (getmntent(fmtab, pmntent); pmntent!=NULL; getmntent(fmtab, pmntent)) { |
158 | +#else | | 167 | +#else |
159 | for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) { | | 168 | for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) { |
160 | +#endif | | 169 | +#endif |
161 | | | 170 | |
162 | DBG (" have entry: %s on %s", pmntent->mnt_fsname, pmntent->mnt_dir ); | | 171 | DBG (" have entry: %s on %s", pmntent->mnt_fsname, pmntent->mnt_dir ); |
163 | | | 172 | |
164 | +#ifdef __sun | | 173 | +#ifdef __sun |
165 | + statfs (pmntent->mnt_mountp, pstatfs); | | 174 | + statfs (pmntent->mnt_mountp, pstatfs); |
166 | +#else | | 175 | +#else |
167 | statfs (pmntent->mnt_dir, pstatfs); | | 176 | statfs (pmntent->mnt_dir, pstatfs); |
168 | +#endif | | 177 | +#endif |
169 | #elif defined (HAVE_GETMNTINFO) | | 178 | #elif defined (HAVE_GETMNTINFO) |
170 | for (i = 0; i < nb_mounted_fs ; i++) { | | 179 | for (i = 0; i < nb_mounted_fs ; i++) { |
171 | DBG (" have entry: %s on %s : type %s", pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname, pstatfs[i].f_fstypename ); | | 180 | DBG (" have entry: %s on %s : type %s", pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname, pstatfs[i].f_fstypename ); |
172 | @@ -789,13 +854,21 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 181 | @@ -789,13 +856,21 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
173 | /* get pointer on disk from pdisks */ | | 182 | /* get pointer on disk from pdisks */ |
174 | /* CHANGED to reflect change in disk_search */ | | 183 | /* CHANGED to reflect change in disk_search */ |
175 | #ifdef HAVE_GETMNTENT | | 184 | #ifdef HAVE_GETMNTENT |
176 | +#ifdef __sun | | 185 | +#ifdef __sun |
177 | + pdisk = disks_search (pdisks, pmntent->mnt_mountp); | | 186 | + pdisk = disks_search (pdisks, pmntent->mnt_mountp); |
178 | +#else | | 187 | +#else |
179 | pdisk = disks_search (pdisks, pmntent->mnt_dir); | | 188 | pdisk = disks_search (pdisks, pmntent->mnt_dir); |
180 | +#endif | | 189 | +#endif |
181 | #elif defined (HAVE_GETMNTINFO) | | 190 | #elif defined (HAVE_GETMNTINFO) |
182 | pdisk = disks_search (pdisks, pstatfs[i].f_mntonname); | | 191 | pdisk = disks_search (pdisks, pstatfs[i].f_mntonname); |
183 | #endif | | 192 | #endif |
184 | if (excluded_FSs!=NULL) | | 193 | if (excluded_FSs!=NULL) |
185 | #ifdef HAVE_GETMNTENT | | 194 | #ifdef HAVE_GETMNTENT |
186 | +#ifdef __sun | | 195 | +#ifdef __sun |
187 | + exclude = exclude_filesystem (excluded_FSs, pmntent->mnt_mountp, pmntent->mnt_special); | | 196 | + exclude = exclude_filesystem (excluded_FSs, pmntent->mnt_mountp, pmntent->mnt_special); |
188 | +#else | | 197 | +#else |
189 | exclude = exclude_filesystem (excluded_FSs, pmntent->mnt_dir, pmntent->mnt_fsname); | | 198 | exclude = exclude_filesystem (excluded_FSs, pmntent->mnt_dir, pmntent->mnt_fsname); |
190 | +#endif | | 199 | +#endif |
191 | #elif defined (HAVE_GETMNTINFO) | | 200 | #elif defined (HAVE_GETMNTINFO) |
192 | exclude = exclude_filesystem (excluded_FSs, pstatfs[i].f_mntonname, pstatfs[i].f_mntfromname); | | 201 | exclude = exclude_filesystem (excluded_FSs, pstatfs[i].f_mntonname, pstatfs[i].f_mntfromname); |
193 | #endif | | 202 | #endif |
194 | @@ -806,6 +879,18 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 203 | @@ -806,6 +881,18 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
195 | /* test for mnt_dir==none or neither block device nor NFS or system device */ | | 204 | /* test for mnt_dir==none or neither block device nor NFS or system device */ |
196 | if ( exclude || | | 205 | if ( exclude || |
197 | #ifdef HAVE_GETMNTENT | | 206 | #ifdef HAVE_GETMNTENT |
198 | +#ifdef __sun | | 207 | +#ifdef __sun |
199 | + g_ascii_strcasecmp(pmntent->mnt_mountp, "none") == 0 || | | 208 | + g_ascii_strcasecmp(pmntent->mnt_mountp, "none") == 0 || |
200 | + g_str_has_prefix(pmntent->mnt_special, "gvfs-fuse-daemon") || | | 209 | + g_str_has_prefix(pmntent->mnt_special, "gvfs-fuse-daemon") || |
201 | + !(g_str_has_prefix(pmntent->mnt_special, "/dev/") || | | 210 | + !(g_str_has_prefix(pmntent->mnt_special, "/dev/") || |
202 | + g_str_has_prefix(pmntent->mnt_fstype, "fuse") || | | 211 | + g_str_has_prefix(pmntent->mnt_fstype, "fuse") || |
203 | + g_str_has_prefix(pmntent->mnt_fstype, "nfs") || | | 212 | + g_str_has_prefix(pmntent->mnt_fstype, "nfs") || |
204 | + g_str_has_prefix(pmntent->mnt_fstype, "smbfs") || | | 213 | + g_str_has_prefix(pmntent->mnt_fstype, "smbfs") || |
205 | + g_str_has_prefix(pmntent->mnt_fstype, "cifs") || | | 214 | + g_str_has_prefix(pmntent->mnt_fstype, "cifs") || |
206 | + g_str_has_prefix(pmntent->mnt_fstype, "shfs") | | 215 | + g_str_has_prefix(pmntent->mnt_fstype, "shfs") |
207 | + ) || | | 216 | + ) || |
208 | + g_str_has_prefix(pmntent->mnt_mountp, "/sys/") | | 217 | + g_str_has_prefix(pmntent->mnt_mountp, "/sys/") |
209 | +#else | | 218 | +#else |
210 | g_ascii_strcasecmp(pmntent->mnt_dir, "none") == 0 || | | 219 | g_ascii_strcasecmp(pmntent->mnt_dir, "none") == 0 || |
211 | g_str_has_prefix(pmntent->mnt_fsname, "gvfs-fuse-daemon") || | | 220 | g_str_has_prefix(pmntent->mnt_fsname, "gvfs-fuse-daemon") || |
212 | !(g_str_has_prefix(pmntent->mnt_fsname, "/dev/") || | | 221 | !(g_str_has_prefix(pmntent->mnt_fsname, "/dev/") || |
213 | @@ -816,6 +901,7 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 222 | @@ -816,6 +903,7 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
214 | g_str_has_prefix(pmntent->mnt_type, "shfs") | | 223 | g_str_has_prefix(pmntent->mnt_type, "shfs") |
215 | ) || | | 224 | ) || |
216 | g_str_has_prefix(pmntent->mnt_dir, "/sys/") | | 225 | g_str_has_prefix(pmntent->mnt_dir, "/sys/") |
217 | +#endif | | 226 | +#endif |
218 | #elif defined (HAVE_GETMNTINFO) | | 227 | #elif defined (HAVE_GETMNTINFO) |
219 | /* TODO: add support for more fs types on BSD */ | | 228 | /* TODO: add support for more fs types on BSD */ |
220 | g_ascii_strcasecmp(pstatfs[i].f_mntonname, "none") == 0 || | | 229 | g_ascii_strcasecmp(pstatfs[i].f_mntonname, "none") == 0 || |
221 | @@ -828,8 +914,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 230 | @@ -828,8 +916,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
222 | | | 231 | |
223 | /* else have valid entry reflecting block device or NFS */ | | 232 | /* else have valid entry reflecting block device or NFS */ |
224 | #ifdef HAVE_GETMNTENT | | 233 | #ifdef HAVE_GETMNTENT |
225 | +#ifdef __sun | | 234 | +#ifdef __sun |
226 | + pdisk = disk_new (pmntent->mnt_special, pmntent->mnt_mountp, length); | | 235 | + pdisk = disk_new (pmntent->mnt_special, pmntent->mnt_mountp, length); |
227 | + pdisk->dc = disk_classify (pmntent->mnt_special, pmntent->mnt_mountp); | | 236 | + pdisk->dc = disk_classify (pmntent->mnt_special, pmntent->mnt_mountp); |
228 | +#else | | 237 | +#else |
229 | pdisk = disk_new (pmntent->mnt_fsname, pmntent->mnt_dir, length); | | 238 | pdisk = disk_new (pmntent->mnt_fsname, pmntent->mnt_dir, length); |
230 | pdisk->dc = disk_classify (pmntent->mnt_fsname, pmntent->mnt_dir); | | 239 | pdisk->dc = disk_classify (pmntent->mnt_fsname, pmntent->mnt_dir); |
231 | +#endif | | 240 | +#endif |
232 | #elif defined (HAVE_GETMNTINFO) | | 241 | #elif defined (HAVE_GETMNTINFO) |
233 | pdisk = disk_new (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname, length); | | 242 | pdisk = disk_new (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname, length); |
234 | pdisk->dc = disk_classify (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname); | | 243 | pdisk->dc = disk_classify (pstatfs[i].f_mntfromname, pstatfs[i].f_mntonname); |
235 | @@ -839,8 +930,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr | | 244 | @@ -839,8 +932,13 @@ disks_refresh(GPtrArray * pdisks, GPtrAr |
236 | | | 245 | |
237 | /* create new t_mount_info */ | | 246 | /* create new t_mount_info */ |
238 | #ifdef HAVE_GETMNTENT | | 247 | #ifdef HAVE_GETMNTENT |
239 | +#ifdef __sun | | 248 | +#ifdef __sun |
240 | + mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_fstype, | | 249 | + mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_fstype, |
241 | + pmntent->mnt_mountp); | | 250 | + pmntent->mnt_mountp); |
242 | +#else | | 251 | +#else |
243 | mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_type, | | 252 | mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_type, |
244 | pmntent->mnt_dir); | | 253 | pmntent->mnt_dir); |
245 | +#endif | | 254 | +#endif |
246 | #elif defined (HAVE_GETMNTINFO) | | 255 | #elif defined (HAVE_GETMNTINFO) |
247 | mount_info = mount_info_new_from_stat (&pstatfs[i], pstatfs[i].f_fstypename, | | 256 | mount_info = mount_info_new_from_stat (&pstatfs[i], pstatfs[i].f_fstypename, |
248 | pstatfs[i].f_mntonname); | | 257 | pstatfs[i].f_mntonname); |
249 | @@ -896,7 +992,11 @@ disk_check_mounted (const char *disk) | | 258 | @@ -896,7 +994,11 @@ disk_check_mounted (const char *disk) |
250 | { | | 259 | { |
251 | #ifdef HAVE_GETMNTENT | | 260 | #ifdef HAVE_GETMNTENT |
252 | FILE *fmtab = NULL; /* file /etc/mtab */ | | 261 | FILE *fmtab = NULL; /* file /etc/mtab */ |
253 | +#ifdef __sun | | 262 | +#ifdef __sun |
254 | + struct mnttab *pmntent = NULL; | | 263 | + struct mnttab *pmntent = NULL; |
255 | +#else | | 264 | +#else |
256 | struct mntent *pmntent = NULL; /* struct for mnt info */ | | 265 | struct mntent *pmntent = NULL; /* struct for mnt info */ |
257 | +#endif | | 266 | +#endif |
258 | #elif defined (HAVE_GETMNTINFO) | | 267 | #elif defined (HAVE_GETMNTINFO) |
259 | struct statfs * pstatfs = NULL; | | 268 | struct statfs * pstatfs = NULL; |
260 | int i, nb_mounted_fs = 0; | | 269 | int i, nb_mounted_fs = 0; |
261 | @@ -905,7 +1005,13 @@ disk_check_mounted (const char *disk) | | 270 | @@ -905,7 +1007,13 @@ disk_check_mounted (const char *disk) |
262 | | | 271 | |
263 | #ifdef HAVE_GETMNTENT | | 272 | #ifdef HAVE_GETMNTENT |
264 | /* open file */ | | 273 | /* open file */ |
265 | +#ifdef __sun | | 274 | +#ifdef __sun |
266 | + fmtab = fopen(MTAB, "r"); | | 275 | + fmtab = fopen(MTAB, "r"); |
267 | + if (fmtab == NULL) | | 276 | + if (fmtab == NULL) |
268 | + return; | | 277 | + return; |
269 | +#else | | 278 | +#else |
270 | fmtab = setmntent (MTAB, "r"); /* mtab file */ | | 279 | fmtab = setmntent (MTAB, "r"); /* mtab file */ |
271 | +#endif | | 280 | +#endif |
272 | #elif defined (HAVE_GETMNTINFO) | | 281 | #elif defined (HAVE_GETMNTINFO) |
273 | /* get mounted fs */ | | 282 | /* get mounted fs */ |
274 | nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT); | | 283 | nb_mounted_fs = getmntinfo(&pstatfs,MNT_WAIT); |
275 | @@ -913,14 +1019,23 @@ disk_check_mounted (const char *disk) | | 284 | @@ -913,14 +1021,23 @@ disk_check_mounted (const char *disk) |
276 | | | 285 | |
277 | /* start looking for mounted devices */ | | 286 | /* start looking for mounted devices */ |
278 | #ifdef HAVE_GETMNTENT | | 287 | #ifdef HAVE_GETMNTENT |
279 | +#ifdef __sun | | 288 | +#ifdef __sun |
280 | + for (getmntent(fmtab, pmntent); pmntent!=NULL; getmntent(fmtab, pmntent)) | | 289 | + for (getmntent(fmtab, pmntent); pmntent!=NULL; getmntent(fmtab, pmntent)) |
281 | +#else | | 290 | +#else |
282 | for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) | | 291 | for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) |
283 | +#endif | | 292 | +#endif |
284 | #elif defined (HAVE_GETMNTINFO) | | 293 | #elif defined (HAVE_GETMNTINFO) |
285 | for (i = 0; i < nb_mounted_fs ; i++) | | 294 | for (i = 0; i < nb_mounted_fs ; i++) |
286 | #endif | | 295 | #endif |
287 | { | | 296 | { |
288 | #ifdef HAVE_GETMNTENT | | 297 | #ifdef HAVE_GETMNTENT |