Quota
view release on metacpan or search on metacpan
{
#ifndef LINUX_API_VERSION
struct stat st;
if (stat("/proc/sys/fs/quota", &st) == 0) {
kernel_iface = IFACE_GENERIC;
}
else {
struct dqstats_v2 v2_stats;
struct sigaction sig;
struct sigaction oldsig;
/* This signal handling is needed because old kernels send us SIGSEGV as they try to resolve the device */
sig.sa_handler = SIG_IGN;
sig.sa_sigaction = NULL;
sig.sa_flags = 0;
sigemptyset(&sig.sa_mask);
if (sigaction(SIGSEGV, &sig, &oldsig) < 0) {
fprintf(stderr, "linuxapi.c warning: cannot set SEGV signal handler: %s\n", strerror(errno));
goto failure;
}
if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
kernel_iface = IFACE_VFSV0;
}
else if (errno != ENOSYS && errno != ENOTSUP) {
/* RedHat 7.1 (2.4.2-2) newquota check
* Q_V2_GETSTATS in it's old place, Q_GETQUOTA in the new place
* (they haven't moved Q_GETSTATS to its new value) */
if ((qf = fopen("/proc/fs/quota", "r"))) {
if (fscanf(qf, "Version %u", &vers_no) == 1) {
if ( (vers_no == (6*10000 + 5*100 + 0)) ||
(vers_no == (6*10000 + 5*100 + 1)) ) {
kernel_iface = IFACE_VFSV0;
}
}
fclose(qf);
}
}
if (sigaction(SIGSEGV, &oldsig, NULL) < 0) {
fprintf(stderr, "linuxapi.c warning: cannot reset signal handler: %s\n", strerror(errno));
goto failure;
}
}
failure:
if (kernel_iface == IFACE_UNSET)
kernel_iface = IFACE_VFSOLD;
#else /* defined LINUX_API_VERSION */
( run in 1.477 second using v1.01-cache-2.11-cpan-71847e10f99 )