Klaus Demo nginx / 1be7419
ngx_fs_bsize() Igor Sysoev 13 years ago
11 changed file(s) with 115 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
11 # Copyright (C) Igor Sysoev
22
33
4 ngx_include="unistd.h"; . auto/include
5 ngx_include="inttypes.h"; . auto/include
6 ngx_include="limits.h"; . auto/include
7 ngx_include="sys/filio.h"; . auto/include
8 ngx_include="crypt.h"; . auto/include
4 ngx_include="unistd.h"; . auto/include
5 ngx_include="inttypes.h"; . auto/include
6 ngx_include="limits.h"; . auto/include
7 ngx_include="sys/filio.h"; . auto/include
8 ngx_include="sys/mount.h"; . auto/include
9 ngx_include="sys/statvfs.h"; . auto/include
10 ngx_include="crypt.h"; . auto/include
204204 ngx_feature_libs=
205205 ngx_feature_test="directio(0, DIRECTIO_ON);"
206206 . auto/feature
207
208
209 ngx_feature="statfs()"
210 ngx_feature_name="NGX_HAVE_STATFS"
211 ngx_feature_run=no
212 ngx_feature_incs="$NGX_INCLUDE_SYS_MOUNT_H
213 $NGX_INCLUDE_SYS_VFS_H"
214 ngx_feature_path=
215 ngx_feature_libs=
216 ngx_feature_test="struct statfs fs;
217 statfs(NULL, &fs);"
218 . auto/feature
219
220
221 ngx_feature="statvfs()"
222 ngx_feature_name="NGX_HAVE_STATVFS"
223 ngx_feature_run=no
224 ngx_feature_incs="#include <sys/types.h>
225 #include <sys/statvfs.h>"
226 ngx_feature_path=
227 ngx_feature_libs=
228 ngx_feature_test="struct statvfs fs;
229 statvfs(NULL, &fs);"
230 . auto/feature
123123 . auto/feature
124124
125125
126 ngx_include="sys/vfs.h"; . auto/include
127
128
126129 CC_AUX_FLAGS=$cc_aux_flags
415415 }
416416
417417 #endif
418
419
420 #if (NGX_HAVE_STATFS)
421
422 size_t
423 ngx_fs_bsize(u_char *name)
424 {
425 struct statfs fs;
426
427 if (statfs((char *) name, &fs) == -1) {
428 return 512;
429 }
430
431 if ((fs.f_bsize % 512) != 0) {
432 return 512;
433 }
434
435 return (size_t) fs.f_bsize;
436 }
437
438 #elif (NGX_HAVE_STATVFS)
439
440 size_t
441 ngx_fs_bsize(u_char *name)
442 {
443 struct statvfs fs;
444
445 if (statvfs((char *) name, &fs) == -1) {
446 return 512;
447 }
448
449 if ((fs.f_frsize % 512) != 0) {
450 return 512;
451 }
452
453 return (size_t) fs.f_frsize;
454 }
455
456 #else
457
458 size_t
459 ngx_fs_bsize(u_char *name)
460 {
461 return 512;
462 }
463
464 #endif
273273 #endif
274274
275275
276 size_t ngx_fs_bsize(u_char *name);
277
278
276279 #endif /* _NGX_FILES_H_INCLUDED_ */
2121 #include <grp.h>
2222 #include <dirent.h>
2323 #include <glob.h>
24 #include <sys/mount.h> /* statfs() */
2425
2526 #include <sys/filio.h> /* FIONBIO */
2627 #include <sys/uio.h>
2727 #include <grp.h>
2828 #include <dirent.h>
2929 #include <glob.h>
30 #include <sys/vfs.h> /* statfs() */
3031
3132 #include <sys/uio.h>
3233 #include <sys/stat.h>
4343 #include <grp.h>
4444 #include <dirent.h>
4545 #include <glob.h>
46 #if (NGX_HAVE_SYS_MOUNT_H)
47 #include <sys/mount.h> /* statfs() */
48 #endif
49 #if (NGX_HAVE_SYS_STATVFS_H)
50 #include <sys/statvfs.h> /* statvfs() */
51 #endif
4652
4753 #if (NGX_HAVE_SYS_FILIO_H)
4854 #include <sys/filio.h> /* FIONBIO */
2727 #include <grp.h>
2828 #include <dirent.h>
2929 #include <glob.h>
30 #include <sys/statvfs.h> /* statvfs() */
3031
3132 #include <sys/filio.h> /* FIONBIO */
3233 #include <sys/uio.h>
503503 return 0;
504504 }
505505
506
506507 ngx_int_t
507508 ngx_directio_off(ngx_fd_t fd)
508509 {
509510 return 0;
510511 }
512
513
514 size_t
515 ngx_fs_bsize(u_char *name)
516 {
517 u_char root[4];
518 u_long sc, bs, nfree, ncl;
519
520 if (name[2] == ':') {
521 ngx_cpystrn(root, name, 4);
522 name = root;
523 }
524
525 if (GetDiskFreeSpace((const char *) name, &sc, &bs, &nfree, &ncl) == 0) {
526 return 512;
527 }
528
529 return sc * bs;
530 }
242242 ngx_int_t ngx_directio_off(ngx_fd_t fd);
243243 #define ngx_directio_off_n "ngx_directio_off_n"
244244
245 size_t ngx_fs_bsize(u_char *name);
246
245247
246248 #endif /* _NGX_FILES_H_INCLUDED_ */