Unverified Commit 8078b707 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

getconf: Use statvfs(2) and statfs(2) on Linux

This allows us to have a correct, variable NAME_MAX (and others).
parent e0f20dfa
......@@ -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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment