summaryrefslogtreecommitdiff
path: root/quotasys.c
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2003-10-12 12:52:26 +0000
committerjkar8572 <jkar8572>2003-10-12 12:52:26 +0000
commit0f69948c4fa23ca6e2b8b64ea7d23a05d3eac237 (patch)
tree605044927b044c09244537cf43781c135d5f462b /quotasys.c
parent200e51d314cac8ba6952c8fbd233d9b7666b90f9 (diff)
Changed kernel interface detection once more - now it should really work :). (Jan Kara, Johan Ekenberg)
Diffstat (limited to 'quotasys.c')
-rw-r--r--quotasys.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/quotasys.c b/quotasys.c
index a26d8ab..63cafce 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
+#include <sys/sysctl.h>
#include "pot.h"
#include "bylabel.h"
@@ -564,10 +565,18 @@ int devcmp_handles(struct quota_handle *a, struct quota_handle *b)
int kernel_iface, kernel_formats; /* Formats supported by kernel */
+#ifndef FS_DQSTATS
+#define FS_DQSTATS 16
+#endif
+#ifndef FS_DQ_SYNCS
+#define FS_DQ_SYNCS 8
+#endif
+
void init_kernel_interface(void)
{
struct stat st;
struct sigaction sig, oldsig;
+ int ctlname[] = {CTL_FS, FS_DQSTATS, FS_DQ_SYNCS};
/* This signal handling is needed because old kernels send us SIGSEGV as they try to resolve the device */
sig.sa_handler = SIG_IGN;
@@ -584,46 +593,40 @@ void init_kernel_interface(void)
else
if (!quotactl(QCMD(Q_XGETQSTAT, 0), NULL, 0, NULL) || (errno != EINVAL && errno != ENOSYS))
kernel_formats |= (1 << QF_XFS);
- if (!stat("/proc/sys/fs/quota", &st)) {
+ if (!sysctl(ctlname, sizeof(ctlname)/sizeof(int), NULL, NULL, NULL, 0)) {
kernel_iface = IFACE_GENERIC;
kernel_formats |= (1 << QF_VFSOLD) | (1 << QF_VFSV0);
}
else {
- if (!quotactl(QCMD(Q_GETQUOTA, USRQUOTA), NULL, 0, NULL) || (errno != EINVAL && errno != ENOSYS)) {
- kernel_iface = IFACE_GENERIC;
- kernel_formats |= (1 << QF_VFSOLD) | (1 << QF_VFSV0);
- }
- else {
- struct v2_dqstats v2_stats;
+ struct v2_dqstats v2_stats;
- if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
+ if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
+ kernel_formats |= (1 << QF_VFSV0);
+ 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) */
+ int err_stat = 0;
+ int err_quota = 0;
+ char tmp[1024]; /* Just temporary buffer */
+
+ if (quotactl(QCMD(Q_V1_GETSTATS, 0), NULL, 0, tmp))
+ err_stat = errno;
+ if (quotactl(QCMD(Q_V1_GETQUOTA, 0), "/dev/null", 0, tmp))
+ err_quota = errno;
+
+ /* On a RedHat 2.4.2-2 we expect 0, EINVAL
+ * On a 2.4.x we expect 0, ENOENT
+ * On a 2.4.x-ac we wont get here */
+ if (err_stat == 0 && err_quota == EINVAL) {
kernel_formats |= (1 << QF_VFSV0);
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) */
- int err_stat = 0;
- int err_quota = 0;
- char tmp[1024]; /* Just temporary buffer */
-
- if (quotactl(QCMD(Q_V1_GETSTATS, 0), NULL, 0, tmp))
- err_stat = errno;
- if (quotactl(QCMD(Q_V1_GETQUOTA, 0), "/dev/null", 0, tmp))
- err_quota = errno;
-
- /* On a RedHat 2.4.2-2 we expect 0, EINVAL
- * On a 2.4.x we expect 0, ENOENT
- * On a 2.4.x-ac we wont get here */
- if (err_stat == 0 && err_quota == EINVAL) {
- kernel_formats |= (1 << QF_VFSV0);
- kernel_iface = IFACE_VFSV0;
- }
- else {
- kernel_formats |= (1 << QF_VFSOLD);
- kernel_iface = IFACE_VFSOLD;
- }
+ else {
+ kernel_formats |= (1 << QF_VFSOLD);
+ kernel_iface = IFACE_VFSOLD;
}
}
}