00001 /* 00002 Get block size 00003 AUP2, Sec. 3.2.3 (not in book) 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 #include "defs.h" 00022 00023 #if _XOPEN_SOURCE >= 4 00024 #include <sys/statvfs.h> 00025 #define STATVFS_NAME statvfs 00026 00027 #elif defined(BSD_DERIVED) 00028 #include <sys/param.h> 00029 #include <sys/mount.h> 00030 #define STATVFS_NAME statfs 00031 00032 #else 00033 #error "Need statvfs or nonstandard substitute" 00034 #endif 00035 00036 unsigned long getblksize(const char *path) 00037 { 00038 struct STATVFS_NAME buf; 00039 00040 if (path == NULL) 00041 path = "."; 00042 ec_neg1( STATVFS_NAME(path, &buf) ) 00043 return buf.f_bsize; 00044 00045 EC_CLEANUP_BGN 00046 return 0; 00047 EC_CLEANUP_END 00048 }