summaryrefslogtreecommitdiff
path: root/getconf
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-03-15 11:23:16 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-03-15 11:23:16 -0500
commit8078b707f9d757622b028a4fd494d6f7e7e2a1ed (patch)
tree9ff483208afde21bf3df45cd3dfe0bdde8875a77 /getconf
parente0f20dfa909e626728e65cfb4d2e06f02c84aaa3 (diff)
downloadshimmy-0.6.tar.gz
shimmy-0.6.tar.bz2
shimmy-0.6.tar.xz
shimmy-0.6.zip
getconf: Use statvfs(2) and statfs(2) on Linuxv0.6
This allows us to have a correct, variable NAME_MAX (and others).
Diffstat (limited to 'getconf')
-rw-r--r--getconf/getconf.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/getconf/getconf.c b/getconf/getconf.c
index 9517925..5a9da22 100644
--- a/getconf/getconf.c
+++ b/getconf/getconf.c
@@ -6,6 +6,10 @@
*/
+#ifdef __linux__
+# include <sys/statvfs.h> /* statvfs */
+# include <sys/vfs.h> /* statfs */
+#endif
#include <errno.h> /* errno */
#include <limits.h> /* limit_vars */
#include <stdbool.h> /* bool type and true/false */
@@ -544,6 +548,45 @@ int do_path_var(char *environment, char *path_var, char *pathname)
errno = 0;
+#ifdef __linux__
+ switch(path_vars[var].value)
+ {
+ case _PC_REC_XFER_ALIGN:
+ case _PC_ALLOC_SIZE_MIN:
+ {
+ struct statvfs vfsres;
+ if(statvfs(pathname, &vfsres) == 0)
+ {
+ result = vfsres.f_frsize;
+ printf("%ld\n", result);
+ return 0;
+ }
+ break;
+ }
+ case _PC_REC_MIN_XFER_SIZE:
+ {
+ struct statvfs vfsres;
+ if(statvfs(pathname, &vfsres) == 0)
+ {
+ result = vfsres.f_bsize;
+ printf("%ld\n", result);
+ return 0;
+ }
+ break;
+ }
+ case _PC_NAME_MAX:
+ {
+ struct statfs fsres;
+ if(statfs(pathname, &fsres) == 0)
+ {
+ result = fsres.f_namelen;
+ printf("%ld\n", result);
+ return 0;
+ }
+ break;
+ }
+ }
+#endif
result = pathconf(pathname, path_vars[var].value);
if(errno != 0)
{