summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2001-09-26 12:26:11 +0000
committerjkar8572 <jkar8572>2001-09-26 12:26:11 +0000
commit570ff1d772f4b2d0a73025c547e46e82ceb79eaa (patch)
tree56f536fb06c9557096635c05e00dfc8d9649ead1
parent48448ca24e00e530e59d774bfdb3c2a76616330c (diff)
downloadlinuxquota-570ff1d772f4b2d0a73025c547e46e82ceb79eaa.tar.gz
Fixed detection of RH 7.1 kernel not to make problems on older kernels.
Utilities now use shared locks when opening files read-only. Changed naming of Q_GETSTATS as they would be no longer in kernel.
-rw-r--r--configure.in9
-rw-r--r--dqblk_v2.h1
-rw-r--r--quota.h13
-rw-r--r--quotacheck.c6
-rw-r--r--quotaio.c2
-rw-r--r--quotaio.h13
-rw-r--r--quotaio_v2.h13
-rw-r--r--quotastats.c18
-rw-r--r--quotasys.c33
-rw-r--r--rquota_svc.c4
-rw-r--r--setquota.c6
11 files changed, 79 insertions, 39 deletions
diff --git a/configure.in b/configure.in
index e98e3aa..2af1c95 100644
--- a/configure.in
+++ b/configure.in
@@ -34,6 +34,15 @@ if test "x$with_ext2direct" != "xno"; then
EXT2LIBS=""
else
with_ext2direct="yes"
+ AC_MSG_CHECKING([for ext2_ino_t])
+ have_ext2_ino_t="no"
+ AC_EGREP_HEADER(ext2_ino_t, ext2fs/ext2fs.h, have_ext2_ino_t="yes")
+ if test "x$have_ext2_ino_t" != "xyes"; then
+ AC_MSG_RESULT([not found])
+ else
+ AC_MSG_RESULT([found])
+ CFLAGS="-DHAVE_EXT2_INO_T $CFLAGS"
+ fi
fi
fi
if test "x$with_ext2direct" = "xyes"; then
diff --git a/dqblk_v2.h b/dqblk_v2.h
index 56aaf5f..2a8c2b7 100644
--- a/dqblk_v2.h
+++ b/dqblk_v2.h
@@ -13,6 +13,7 @@
#define Q_V2_SETQUOTA 0x0E00 /* Set limits and usage */
#define Q_V2_GETINFO 0x0900 /* Get information about quota */
#define Q_V2_SETINFO 0x0A00 /* Set information about quota */
+#define Q_V2_GETSTATS 0x1100 /* get collected stats (before proc was used) */
/* Structure for format specific information */
struct v2_mem_dqinfo {
diff --git a/quota.h b/quota.h
index a1299d5..c772a8c 100644
--- a/quota.h
+++ b/quota.h
@@ -49,19 +49,6 @@ typedef u_int64_t qsize_t; /* Type in which we store size limitations */
#define Q_QUOTAON 0x0100 /* enable quotas */
#define Q_QUOTAOFF 0x0200 /* disable quotas */
#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
-#define Q_GETSTATS 0x1100 /* get collected stats */
-
-struct dqstats {
- u_int32_t lookups;
- u_int32_t drops;
- u_int32_t reads;
- u_int32_t writes;
- u_int32_t cache_hits;
- u_int32_t allocated_dquots;
- u_int32_t free_dquots;
- u_int32_t syncs;
- u_int32_t version;
-};
/* Ioctl for getting quota size */
#include <sys/ioctl.h>
diff --git a/quotacheck.c b/quotacheck.c
index 08d62c6..47adef0 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -8,7 +8,7 @@
* New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR
*/
-#ident "$Id: quotacheck.c,v 1.19 2001/09/21 12:45:22 jkar8572 Exp $"
+#ident "$Id: quotacheck.c,v 1.20 2001/09/26 12:26:11 jkar8572 Exp $"
#include <dirent.h>
#include <stdio.h>
@@ -41,6 +41,10 @@
#include "quotacheck.h"
#include "quotaops.h"
+#ifndef HAVE_EXT2_INO_T
+typedef ino_t ext2_ino_t;
+#endif
+
#define LINKSHASHSIZE 16384 /* Size of hashtable for hardlinked inodes */
#define DQUOTHASHSIZE 32768 /* Size of hashtable for dquots from file */
diff --git a/quotaio.c b/quotaio.c
index 6c0f90e..bbcbf32 100644
--- a/quotaio.c
+++ b/quotaio.c
@@ -119,7 +119,7 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
qfname, strerror(errno));
goto out_handle;
}
- flock(fd, LOCK_EX);
+ flock(fd, QIO_RO(h) ? LOCK_SH : LOCK_EX);
/* Init handle */
h->qh_fd = fd;
diff --git a/quotaio.h b/quotaio.h
index 16c6f4a..e6bee75 100644
--- a/quotaio.h
+++ b/quotaio.h
@@ -88,6 +88,19 @@ struct quota_handle {
struct util_dqinfo qh_info; /* Generic quotafile info */
};
+/* Statistics gathered from kernel */
+struct util_dqstats {
+ u_int32_t lookups;
+ u_int32_t drops;
+ u_int32_t reads;
+ u_int32_t writes;
+ u_int32_t cache_hits;
+ u_int32_t allocated_dquots;
+ u_int32_t free_dquots;
+ u_int32_t syncs;
+ u_int32_t version;
+};
+
/* Utility quota block */
struct util_dqblk {
qsize_t dqb_ihardlimit;
diff --git a/quotaio_v2.h b/quotaio_v2.h
index 2657343..2482156 100644
--- a/quotaio_v2.h
+++ b/quotaio_v2.h
@@ -85,4 +85,17 @@ struct v2_kern_dqinfo {
unsigned int dqi_free_entry;
};
+/* Structure with gathered statistics from kernel */
+struct v2_dqstats {
+ u_int32_t lookups;
+ u_int32_t drops;
+ u_int32_t reads;
+ u_int32_t writes;
+ u_int32_t cache_hits;
+ u_int32_t allocated_dquots;
+ u_int32_t free_dquots;
+ u_int32_t syncs;
+ u_int32_t version;
+};
+
#endif
diff --git a/quotastats.c b/quotastats.c
index 3922ceb..9d177bd 100644
--- a/quotastats.c
+++ b/quotastats.c
@@ -10,7 +10,7 @@
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
- * Version: $Id: quotastats.c,v 1.4 2001/09/10 10:34:16 jkar8572 Exp $
+ * Version: $Id: quotastats.c,v 1.5 2001/09/26 12:26:11 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,14 +28,18 @@
#include "common.h"
#include "quota.h"
#include "quotasys.h"
+#include "quotaio.h"
#include "quotaio_v1.h"
#include "dqblk_v1.h"
+#include "quotaio_v2.h"
+#include "dqblk_v2.h"
char *progname;
-static inline int get_stats(struct dqstats *dqstats)
+static inline int get_stats(struct util_dqstats *dqstats)
{
struct v1_dqstats old_dqstats;
+ struct v2_dqstats v0_dqstats;
FILE *f;
int ret = -1;
@@ -55,7 +59,11 @@ static inline int get_stats(struct dqstats *dqstats)
goto out;
}
}
- else if (quotactl(QCMD(Q_GETSTATS, 0), NULL, 0, (caddr_t)dqstats) < 0) {
+ else if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (caddr_t)&v0_dqstats) >= 0) {
+ /* Structures are currently the same */
+ memcpy(dqstats, &v0_dqstats, sizeof(v0_dqstats));
+ }
+ else {
if (errno != EINVAL) {
errstr(_("Error while getting quota statistics from kernel: %s\n"), strerror(errno));
goto out;
@@ -74,7 +82,7 @@ out:
return ret;
}
-static inline int print_stats(struct dqstats *dqstats)
+static inline int print_stats(struct util_dqstats *dqstats)
{
if (!dqstats->version)
printf(_("Kernel quota version: old\n"));
@@ -95,7 +103,7 @@ static inline int print_stats(struct dqstats *dqstats)
int main(int argc, char **argv)
{
- struct dqstats dqstats;
+ struct util_dqstats dqstats;
gettexton();
progname = basename(argv[0]);
diff --git a/quotasys.c b/quotasys.c
index d74ca30..2147f52 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -25,6 +25,7 @@
#include "dqblk_v1.h"
#include "dqblk_v2.h"
#include "dqblk_xfs.h"
+#include "quotaio_v2.h"
#define min(x,y) (((x) < (y)) ? (x) : (y))
#define CORRECT_FSTYPE(type) \
@@ -464,7 +465,8 @@ int devcmp_handles(struct quota_handle *a, struct quota_handle *b)
int kern_quota_format(void)
{
- struct dqstats stats;
+ struct util_dqstats stats;
+ struct v2_dqstats v2_stats;
FILE *f;
int ret = 0;
struct stat st;
@@ -478,20 +480,23 @@ int kern_quota_format(void)
}
fclose(f);
}
- else if (quotactl(QCMD(Q_GETSTATS, 0), NULL, 0, (void *)&stats) < 0) {
+ else if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) {
+ stats.version = v2_stats.version; /* Copy the version */
+ }
+ else {
if (errno == ENOSYS || errno == ENOTSUP) /* Quota not compiled? */
return QF_ERROR;
if (errno == EINVAL || errno == EFAULT || errno == EPERM) { /* Old quota compiled? */
/* RedHat 7.1 (2.4.2-2) newquota check
- * Q_GETSTATS in it's old place, Q_GETQUOTA in the new place
+ * 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, (void *)&stats))
+ if (quotactl(QCMD(Q_V1_GETSTATS, 0), NULL, 0, tmp))
err_stat = errno;
- if (quotactl(QCMD(Q_V1_GETQUOTA, 0), "", 0, tmp))
+ 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
@@ -610,8 +615,8 @@ static int cache_mnt_table(void)
FILE *mntf;
struct mntent *mnt;
struct stat st;
- int allocated = 0, i;
- dev_t dev;
+ int allocated = 0, i = 0;
+ dev_t dev = 0;
char mntpointbuf[PATH_MAX];
if (!(mntf = setmntent(_PATH_MOUNTED, "r"))) {
@@ -652,16 +657,20 @@ static int cache_mnt_table(void)
dev = st.st_rdev;
for (i = 0; i < mnt_entries_cnt && mnt_entries[i].me_dev != dev; i++);
}
- else { /* Cope with network filesystems */
- dev = 0;
- for (i = 0; i < mnt_entries_cnt && strcmp(mnt_entries[i].me_devname, devname); i++);
- }
- if (i == mnt_entries_cnt) { /* New mounted device? */
+ /* Cope with network filesystems or new mountpoint */
+ if (!strcmp(mnt->mnt_type, MNTTYPE_NFS) || i == mnt_entries_cnt) {
if (stat(mnt->mnt_dir, &st) < 0) { /* Can't stat mountpoint? We have better ignore it... */
errstr(_("Can't stat() mountpoint %s: %s\n"), mnt->mnt_dir, strerror(errno));
free((char *)devname);
continue;
}
+ if (!strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
+ /* For network filesystems we must get device from root */
+ dev = st.st_dev;
+ for (i = 0; i < mnt_entries_cnt && mnt_entries[i].me_dev != dev; i++);
+ }
+ }
+ if (i == mnt_entries_cnt) { /* New mounted device? */
if (allocated == mnt_entries_cnt) {
allocated += ALLOC_ENTRIES_NUM;
mnt_entries = srealloc(mnt_entries, allocated * sizeof(struct mount_entry));
diff --git a/rquota_svc.c b/rquota_svc.c
index 431a1dc..59a2ed0 100644
--- a/rquota_svc.c
+++ b/rquota_svc.c
@@ -12,7 +12,7 @@
* changes for new utilities by Jan Kara <jack@suse.cz>
* patches by Jani Jaakkola <jjaakkol@cs.helsinki.fi>
*
- * Version: $Id: rquota_svc.c,v 1.8 2001/09/21 12:45:22 jkar8572 Exp $
+ * Version: $Id: rquota_svc.c,v 1.9 2001/09/26 12:26:11 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -101,7 +101,7 @@ static void parse_options(int argc, char **argv)
* good_client checks if an quota client should be allowed to
* execute the requested rpc call.
*/
-int good_client(struct sockaddr_in *addr, rpcproc_t rq_proc)
+int good_client(struct sockaddr_in *addr, ulong rq_proc)
{
#ifdef HOSTS_ACCESS
struct hostent *h;
diff --git a/setquota.c b/setquota.c
index e9c5ea3..a570bb9 100644
--- a/setquota.c
+++ b/setquota.c
@@ -89,10 +89,6 @@ static void parse_options(int argcnt, char **argstr)
char *opts = "igp:uVF:ta";
#endif
-#ifdef RPC_SETQUOTA
- flags |= FL_RPC;
-#endif
-
while ((ret = getopt(argcnt, argstr, opts)) != -1) {
switch (ret) {
case '?':
@@ -109,7 +105,7 @@ static void parse_options(int argcnt, char **argstr)
protoname = optarg;
break;
case 'r':
- flags &= ~FL_RPC;
+ flags |= FL_RPC;
break;
case 'a':
flags |= FL_ALL;