From 38b37dbcc5ccec3657f2c6e058d276d65bd201d6 Mon Sep 17 00:00:00 2001 From: jkar8572 Date: Sun, 16 Jun 2002 19:00:45 +0000 Subject: Fixed small bug in configure.in Some forgotten changes? --- Changelog | 4 ++++ Makefile.in | 6 +++++- configure.in | 4 +++- quot.h | 2 +- quotaio_xfs.h | 2 +- quotaon.c | 4 +++- quotastats.c | 54 ++++++++++++++++++++++++++++++------------------------ quotasys.c | 39 ++++++--------------------------------- quotasys.h | 1 - 9 files changed, 53 insertions(+), 63 deletions(-) diff --git a/Changelog b/Changelog index 43ff6b1..7a7b3b2 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,8 @@ Changes in quota-tools from 3.05 to 3.06 +* fixed caching of libwrap configure result (Jan Kara) +* fixed copying of quotafile name from mtab (?) +* warnquota.conf is now installed in config dir (Jan Kara) +* updated format detection to reflect changes in kernel interface in 2.5.18 (Jan Kara) * fixed scanning of non-mountpoint directories (Jan Kara) * fixed detection of XFS format (Jan Kara) * fixed printing of 'over softlimit sign' in quota(1) (Jan Kara) diff --git a/Makefile.in b/Makefile.in index cf285c5..29ac3a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ PROGS = quotacheck quotaon quota quot repquota warnquota quotastats xqmstats edquota setquota convertquota rpc.rquotad SOURCES = bylabel.c common.c convertquota.c edquota.c pot.c quot.c quota.c quotacheck.c quotacheck_v1.c quotacheck_v2.c quotaio.c quotaio_rpc.c quotaio_v1.c quotaio_v2.c quotaio_xfs.c quotaio_generic.c quotaon.c quotaon_xfs.c quotaops.c quotastats.c quotasys.c repquota.c rquota_client.c rquota_server.c rquota_svc.c setquota.c warnquota.c xqmstats.c -VERSIONDEF = -DQUOTA_VERSION=\"3.05\" +VERSIONDEF = -DQUOTA_VERSION=\"3.06\" CFLAGS = @CFLAGS@ @EXT2_DIRECT@ -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(VERSIONDEF) EXT2LIBS = @EXT2LIBS@ RPCSRC = rquota.h rquota_xdr.c rquota_clnt.c @@ -22,6 +22,7 @@ DEF_SUID_MODE = 4511 DEF_BIN_MODE = 555 DEF_SBIN_MODE = 555 DEF_MAN_MODE = 444 +DEF_CONF_MODE = 644 RPCGEN = rpcgen prefix = @prefix@ @@ -31,6 +32,7 @@ mandir = @mandir@ includedir = $(prefix)/include root_sbindir = /sbin locale_dir = $(prefix)/share/locale +sysconfdir = @sysconfdir@ RPCCLNTOBJS = rquota_xdr.o rquota_client.o rquota_clnt.o IOOBJS = quotaio.o quotaio_v1.o quotaio_v2.o quotaio_rpc.o quotaio_xfs.o quotaio_generic.o @@ -80,6 +82,8 @@ install: all inst_mo -$(INSTALL) -m $(DEF_SBIN_MODE) \ edquota repquota warnquota quotastats setquota quot xqmstats \ $(ROOTDIR)$(sbindir) + -mkdir -p $(ROOTDIR)$(sysconfdir) + -$(INSTALL) -m $(DEF_CONF_MODE) warnquota.conf $(ROOTDIR)$(sysconfdir) -mkdir -p $(ROOTDIR)$(mandir)/man1 -mkdir -p $(ROOTDIR)$(mandir)/man2 -mkdir -p $(ROOTDIR)$(mandir)/man3 diff --git a/configure.in b/configure.in index b08fe45..8e620ba 100644 --- a/configure.in +++ b/configure.in @@ -63,7 +63,7 @@ AC_CACHE_VAL(ac_cv_lib_wrap_main, #include struct request_info request; int deny_severity, allow_severity;],[hosts_access(&request);], - [ac_cv_lib_wrap_main=yes],[ac_cv_lib_wrap_main=no,LIBS="$saved_LIBS="]) + [ac_cv_lib_wrap_main=yes],[ac_cv_lib_wrap_main=no,LIBS="$saved_LIBS"]) ]) if test ${ac_cv_lib_wrap_main} = yes; then @@ -71,6 +71,8 @@ if test ${ac_cv_lib_wrap_main} = yes; then echo 'ERROR: could not find tcpd.h - missing TCP wrappers package' exit 1 ]) + dnl Do this in case value was cached... + LIBS="$LIBS -lwrap" HOSTS_ACCESS="-DHOSTS_ACCESS" AC_SUBST(HOSTS_ACCESS) fi diff --git a/quot.h b/quot.h index a77a3f1..4f3de0b 100644 --- a/quot.h +++ b/quot.h @@ -61,7 +61,7 @@ static int ndu[2]; /* * === Start XFS specific types and definitions === */ -#include +#include /* Structures returned from ioctl XFS_IOC_FSBULKSTAT */ typedef struct xfs_bstime { diff --git a/quotaio_xfs.h b/quotaio_xfs.h index e854452..95af803 100644 --- a/quotaio_xfs.h +++ b/quotaio_xfs.h @@ -32,7 +32,7 @@ #ifndef _QUOTAIO_XFS_H #define _QUOTAIO_XFS_H -#include +#include #define XQM_CMD(cmd) ( ('X'<<8)+(cmd) ) #define IS_XQM_CMD(cmd) ( ((int)(cmd)>>8) == 'X' ) diff --git a/quotaon.c b/quotaon.c index 0012431..3553e4c 100644 --- a/quotaon.c +++ b/quotaon.c @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quotaon.c,v 1.15 2002/05/03 07:05:46 jkar8572 Exp $" +#ident "$Id: quotaon.c,v 1.16 2002/06/16 19:00:46 jkar8572 Exp $" /* * Turn quota on/off for a filesystem. @@ -218,6 +218,8 @@ static int quotaonoff(char *quotadev, char *quotadir, char *quotafile, int type, errstr(_("using %s on %s [%s]: %s\n"), quotafile, quotadev, quotadir, strerror(errno)); if (errno == EINVAL) errstr(_("Maybe create new quota files with quotacheck(8)?\n")); + else if (errno == ESRCH) + errstr(_("Quota format not supported in kernel.\n")); return 1; } if (flags & STATEFLAG_VERBOSE) diff --git a/quotastats.c b/quotastats.c index b3f0d02..92ae9c7 100644 --- a/quotastats.c +++ b/quotastats.c @@ -10,7 +10,7 @@ * * Author: Marco van Wieringen * - * Version: $Id: quotastats.c,v 1.9 2002/03/27 16:21:26 jkar8572 Exp $ + * Version: $Id: quotastats.c,v 1.10 2002/06/16 19:00:46 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 @@ -37,32 +37,40 @@ char *progname; -static inline int get_stats(struct util_dqstats *dqstats) +static int get_proc_num(char *name) +{ + int ret; + char namebuf[PATH_MAX] = "/proc/sys/fs/quota/"; + FILE *f; + + sstrncat(namebuf, name, PATH_MAX); + if (!(f = fopen(namebuf, "r"))) { + errstr(_("Can't read stat file %s: %s\n"), namebuf, strerror(errno)); + return -1; + } + fscanf(f, "%d", &ret); + fclose(f); + return ret; +} + +static int get_stats(struct util_dqstats *dqstats) { struct v1_dqstats old_dqstats; struct v2_dqstats v0_dqstats; - char tmp[1024]; - FILE *f; int ret = -1; + struct stat st; signal(SIGSEGV, SIG_IGN); /* Ignore SIGSEGV due to bad quotactl() */ - if ((f = fopen(QSTAT_FILE, "r"))) { - if (fscanf(f, "Version %u\n", &dqstats->version) != 1) { - errstr(_("Can't parse quota version.\n")); - goto out; - } - if (dqstats->version > KERN_KNOWN_QUOTA_VERSION) { - errstr(_("Kernel quota version %u is too new.\n"), dqstats->version); - goto out; - } - if (dqstats->version >= 6*10000+5*100+1) - fgets(tmp, sizeof(tmp), f); /* Skip formats information */ - if (fscanf(f, "%u %u %u %u %u %u %u %u", &dqstats->lookups, &dqstats->drops, - &dqstats->reads, &dqstats->writes, &dqstats->cache_hits, - &dqstats->allocated_dquots, &dqstats->free_dquots, &dqstats->syncs) != 8) { - errstr(_("Can't parse quota statistics.\n")); - goto out; - } + if (!stat("/proc/sys/fs/quota", &st)) { + dqstats->version = 6*10000+5*100+1; + dqstats->lookups = get_proc_num("lookups"); + dqstats->drops = get_proc_num("drops"); + dqstats->reads = get_proc_num("reads"); + dqstats->writes = get_proc_num("writes"); + dqstats->cache_hits = get_proc_num("cache_hits"); + dqstats->allocated_dquots = get_proc_num("allocated_dquots"); + dqstats->free_dquots = get_proc_num("free_dquots"); + dqstats->syncs = get_proc_num("syncs"); } else if (quotactl(QCMD(Q_V1_GETSTATS, 0), NULL, 0, (caddr_t)&old_dqstats) >= 0) { /* Structures are currently the same */ @@ -84,8 +92,6 @@ static inline int get_stats(struct util_dqstats *dqstats) ret = 0; out: signal(SIGSEGV, SIG_DFL); - if (f) - fclose(f); return ret; } @@ -105,7 +111,7 @@ static inline int print_stats(struct util_dqstats *dqstats) printf(_("Number of free dquots: %ld\n"), (long)dqstats->free_dquots); printf(_("Number of in use dquot entries (user/group): %ld\n"), (long)(dqstats->allocated_dquots - dqstats->free_dquots)); - return (0); + return 0; } int main(int argc, char **argv) diff --git a/quotasys.c b/quotasys.c index b610297..109838c 100644 --- a/quotasys.c +++ b/quotasys.c @@ -403,7 +403,7 @@ int get_qf_name(struct mntent *mnt, int type, int fmt, int flags, char **filenam if (has_quota_file_definition) { if ((option = strchr(++pathname, ','))) - sstrncpy(qfullname, pathname, min((option - pathname), sizeof(qfullname))); + sstrncpy(qfullname, pathname, min((option - pathname + 1), sizeof(qfullname))); else sstrncpy(qfullname, pathname, sizeof(qfullname)); } @@ -510,38 +510,18 @@ int devcmp_handles(struct quota_handle *a, struct quota_handle *b) * Check kernel quota version */ -int kernel_formats, kernel_iface; /* Formats supported by kernel */ +int kernel_iface, kernel_formats; /* Formats supported by kernel */ void init_kernel_interface(void) { - FILE *f; - char buf[1024], *c; - int actfmt, version = -1; struct stat st; - + kernel_formats = 0; if (!stat("/proc/fs/xfs/stat", &st)) kernel_formats |= (1 << QF_XFS); - if ((f = fopen(QSTAT_FILE, "r"))) { - /* Parse statistics file */ - fgets(buf, sizeof(buf), f); - sscanf(buf, "Version %u", &version); - if (version >= 6*10000+5*100+1) { - fgets(buf, sizeof(buf), f); - c = buf; - while ((c = strchr(c, ' '))) { - c++; - actfmt = kern2utilfmt(strtol(c, NULL, 10)); - if (actfmt >= 0) /* Known format? */ - kernel_formats |= 1 << actfmt; - } - kernel_iface = IFACE_GENERIC; - } - else { - kernel_formats = 1 << QF_VFSV0; - kernel_iface = IFACE_VFSV0; - } - fclose(f); + if (!stat("/proc/sys/fs/quota", &st)) { + kernel_iface = IFACE_GENERIC; + kernel_formats |= (1 << QF_VFSOLD) | (1 << QF_VFSV0); } else { struct v2_dqstats v2_stats; @@ -556,10 +536,8 @@ void init_kernel_interface(void) if (sigaction(SIGSEGV, &sig, &oldsig) < 0) die(2, _("Can't set signal handler: %s\n"), strerror(errno)); if (quotactl(QCMD(Q_V2_GETSTATS, 0), NULL, 0, (void *)&v2_stats) >= 0) { - version = v2_stats.version; kernel_formats |= (1 << QF_VFSV0); kernel_iface = IFACE_VFSV0; - version = 6*10000+5*100+0; } else if (errno != ENOSYS && errno != ENOTSUP) { /* RedHat 7.1 (2.4.2-2) newquota check @@ -580,20 +558,15 @@ void init_kernel_interface(void) if (err_stat == 0 && err_quota == EINVAL) { kernel_formats |= (1 << QF_VFSV0); kernel_iface = IFACE_VFSV0; - version = 6*10000+5*100+0; } else { kernel_formats |= (1 << QF_VFSOLD); kernel_iface = IFACE_VFSOLD; - version = 6*10000+4*100+0; } } if (sigaction(SIGSEGV, &oldsig, NULL) < 0) die(2, _("Can't reset signal handler: %s\n"), strerror(errno)); } - - if (version > KERN_KNOWN_QUOTA_VERSION) - errstr(_("WARNING - Kernel quota is newer than supported. Quota utilities need not work properly.\n")); } /* Check whether old quota is turned on on given device */ diff --git a/quotasys.h b/quotasys.h index 8e95c13..a945558 100644 --- a/quotasys.h +++ b/quotasys.h @@ -24,7 +24,6 @@ #define IOI_READONLY 0x2 /* Only readonly access */ #define IOI_OPENFILE 0x4 /* Open file even if kernel has quotas turned on */ -#define QSTAT_FILE "/proc/fs/quota" /* File with quotastats */ #define KERN_KNOWN_QUOTA_VERSION (6*10000 + 5*100 + 1) /* Interface versions */ -- cgit v1.2.3