Mercurial > dwindows
comparison compat.c @ 871:b15ad609365e
Solaris recommends using statvfs() instead of statfs()
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 04 Apr 2011 05:49:45 +0000 |
parents | 59c4fac42fb5 |
children | 13debcad9757 |
comparison
equal
deleted
inserted
replaced
870:59c4fac42fb5 | 871:b15ad609365e |
---|---|
13 #include <sys/mount.h> | 13 #include <sys/mount.h> |
14 #elif defined(__sun__) | 14 #elif defined(__sun__) |
15 #include <sys/mnttab.h> | 15 #include <sys/mnttab.h> |
16 #include <sys/param.h> | 16 #include <sys/param.h> |
17 #include <sys/mount.h> | 17 #include <sys/mount.h> |
18 #include <sys/statfs.h> | 18 #include <sys/statvfs.h> |
19 #else | 19 #else |
20 #include <mntent.h> | 20 #include <mntent.h> |
21 #include <sys/vfs.h> | 21 #include <sys/vfs.h> |
22 #endif | 22 #endif |
23 #endif | 23 #endif |
115 } | 115 } |
116 return 0; | 116 return 0; |
117 #elif defined(__sun__) | 117 #elif defined(__sun__) |
118 FILE *fp = fopen("/etc/mnttab", "r"); | 118 FILE *fp = fopen("/etc/mnttab", "r"); |
119 struct mnttab mnt; | 119 struct mnttab mnt; |
120 struct statfs sfs; | 120 struct statvfs sfs; |
121 int index = 1; | 121 int index = 1; |
122 | 122 |
123 if(fp) | 123 if(fp) |
124 { | 124 { |
125 while((getmntent(fp, &mnt) == 0)) | 125 while((getmntent(fp, &mnt) == 0)) |
128 { | 128 { |
129 long double size = 0; | 129 long double size = 0; |
130 | 130 |
131 if(mnt.mnt_mountp) | 131 if(mnt.mnt_mountp) |
132 { | 132 { |
133 if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0)) | 133 if(!statvfs(mnt.mnt_mountp, &sfs)) |
134 { | 134 { |
135 size = (long double)((double)sfs.f_bsize * (double)sfs.f_bfree); | 135 size = (long double)((double)sfs.f_bsize * (double)sfs.f_bavail); |
136 } | 136 } |
137 } | 137 } |
138 fclose(fp); | 138 fclose(fp); |
139 return size; | 139 return size; |
140 } | 140 } |
217 } | 217 } |
218 return 0; | 218 return 0; |
219 #elif defined(__sun__) | 219 #elif defined(__sun__) |
220 FILE *fp = fopen("/etc/mnttab", "r"); | 220 FILE *fp = fopen("/etc/mnttab", "r"); |
221 struct mnttab mnt; | 221 struct mnttab mnt; |
222 struct statfs sfs; | 222 struct statvfs sfs; |
223 int index = 1; | 223 int index = 1; |
224 | 224 |
225 if(fp) | 225 if(fp) |
226 { | 226 { |
227 while(getmntent(fp, &mnt) == 0) | 227 while(getmntent(fp, &mnt) == 0) |
230 { | 230 { |
231 long double size = 0; | 231 long double size = 0; |
232 | 232 |
233 if(mnt.mnt_mountp) | 233 if(mnt.mnt_mountp) |
234 { | 234 { |
235 if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0)) | 235 if(!statvfs(mnt.mnt_mountp, &sfs)) |
236 { | 236 { |
237 size = (long double)((double)sfs.f_bsize * (double)sfs.f_blocks); | 237 size = (long double)((double)sfs.f_bsize * (double)sfs.f_blocks); |
238 } | 238 } |
239 } | 239 } |
240 fclose(fp); | 240 fclose(fp); |
316 } | 316 } |
317 return 0; | 317 return 0; |
318 #elif defined(__sun__) | 318 #elif defined(__sun__) |
319 FILE *fp = fopen("/etc/mnttab", "r"); | 319 FILE *fp = fopen("/etc/mnttab", "r"); |
320 struct mnttab mnt; | 320 struct mnttab mnt; |
321 struct statfs sfs; | 321 struct statvfs sfs; |
322 int index = 1; | 322 int index = 1; |
323 | 323 |
324 if(fp) | 324 if(fp) |
325 { | 325 { |
326 while(getmntent(fp, &mnt) == 0) | 326 while(getmntent(fp, &mnt) == 0) |
328 if(index == drive) | 328 if(index == drive) |
329 { | 329 { |
330 fclose(fp); | 330 fclose(fp); |
331 if(mnt.mnt_mountp) | 331 if(mnt.mnt_mountp) |
332 { | 332 { |
333 if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0) && sfs.f_blocks) | 333 if(!statvfs(mnt.mnt_mountp, &sfs) && sfs.f_blocks) |
334 return 1; | 334 return 1; |
335 } | 335 } |
336 return 0; | 336 return 0; |
337 } | 337 } |
338 index++; | 338 index++; |