From b57c1def9a907b81a49aa91eeb39c9321763c276 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Jul 2011 23:13:01 +0000 Subject: Fri Jul 22 23:13:01 UTC 2011 --- extra/quota-tools/PKGBUILD | 33 ++++-- extra/quota-tools/nulls.diff | 20 ++++ extra/quota-tools/quotaon.diff | 216 +++++++++++++++++++++++++++++++++++ extra/quota-tools/repquota.diff | 91 +++++++++++++++ extra/quota-tools/system_inodes.diff | 18 +++ 5 files changed, 369 insertions(+), 9 deletions(-) create mode 100644 extra/quota-tools/nulls.diff create mode 100644 extra/quota-tools/quotaon.diff create mode 100644 extra/quota-tools/repquota.diff create mode 100644 extra/quota-tools/system_inodes.diff (limited to 'extra/quota-tools') diff --git a/extra/quota-tools/PKGBUILD b/extra/quota-tools/PKGBUILD index cf88fa2f0..79bb209a4 100644 --- a/extra/quota-tools/PKGBUILD +++ b/extra/quota-tools/PKGBUILD @@ -1,25 +1,40 @@ -# $Id: PKGBUILD 122880 2011-05-07 02:23:54Z eric $ +# $Id: PKGBUILD 131802 2011-07-15 11:55:43Z eric $ # Maintainer: Eric BĂ©langer pkgname=quota-tools -pkgver=3.17 -pkgrel=2 +pkgver=4.00_pre1 +pkgrel=1 pkgdesc="Tools to manage kernel-level quotas in Linux" arch=('i686' 'x86_64') url="http://sourceforge.net/projects/linuxquota/" license=('GPL' 'BSD') -depends=('e2fsprogs' 'tcp_wrappers') +depends=('e2fsprogs') backup=('etc/warnquota.conf' 'etc/quotatab' 'etc/quotagrpadmins') options=('!emptydirs') -source=(http://downloads.sourceforge.net/sourceforge/linuxquota/quota-${pkgver}.tar.gz LICENSE) -md5sums=('cb3e98a039c0cf98e7c1ad4b50a5bda7' - 'dd792440e684043e4e4ef80963d0237b') -sha1sums=('8dc04ea803a43496dfe275a8260757f558a2d762' - '57297bdc9e638c500506169bbbe12eb89bcf7d07') +source=(http://downloads.sourceforge.net/sourceforge/linuxquota/quota-${pkgver/_/-}.tar.gz LICENSE \ + quotaon.diff system_inodes.diff repquota.diff nulls.diff) +md5sums=('ef9d66e8a968ecffd2d9df648fa8ada2' + 'dd792440e684043e4e4ef80963d0237b' + '9ac7ca4746de1ad057baee21474b7906' + '92d9f2a4b3e5e3adf2977051391785a7' + 'd1d70d4167e53d1414079b4391f1cfb8' + '094bce5226c4fd1c383bd0b75405ee2c') +sha1sums=('adf29b49dab449078eb6ffdfe8af51fe85419e28' + '57297bdc9e638c500506169bbbe12eb89bcf7d07' + '2304f03cddd06d8791167f621683f7ef54610673' + 'e2a33f1f95a3ff8c741a2067058e898f6054af09' + '8b00e7c4f7af2188ad49a50a616c1d71eee20459' + '0527f761aa869f5d9e463ceab4a3bf82881d05c2') build() { cd "${srcdir}/${pkgname}" + patch -p1 -i "${srcdir}/quotaon.diff" + patch -p1 -i "${srcdir}/system_inodes.diff" + patch -p1 -i "${srcdir}/repquota.diff" + patch -p1 -i "${srcdir}/nulls.diff" ./configure --prefix=/usr --sysconfdir=/etc + sed -i -e 's/#define HOSTS_ACCESS 1//' -e 's/HOSTS_ACCESS//' config.h + sed -i 's/-lwrap//' Makefile make } diff --git a/extra/quota-tools/nulls.diff b/extra/quota-tools/nulls.diff new file mode 100644 index 000000000..97c5bc482 --- /dev/null +++ b/extra/quota-tools/nulls.diff @@ -0,0 +1,20 @@ +#Description: Avoid memory corruption of NULL address +#Author: Petr Pisar + +--- quota/quotasys.c 2010-02-18 09:44:11.000000000 +0100 ++++ quota-tools/quotasys.c 2010-05-05 08:02:53.000000000 +0200 +@@ -746,9 +746,12 @@ + kernel_qfmt_num = 0; + if (!stat("/proc/fs/xfs/stat", &st)) + kernel_qfmt[kernel_qfmt_num++] = QF_XFS; +- else +- if (!quotactl(QCMD(Q_XGETQSTAT, 0), NULL, 0, NULL) || (errno != EINVAL && errno != ENOSYS)) ++ else { ++ fs_quota_stat_t dummy; ++ ++ if (!quotactl(QCMD(Q_XGETQSTAT, 0), "/dev/root", 0, (void *)&dummy) || (errno != EINVAL && errno != ENOSYS)) + kernel_qfmt[kernel_qfmt_num++] = QF_XFS; ++ } + /* Detect new kernel interface; Assume generic interface unless we can prove there is not one... */ + if (!stat("/proc/sys/fs/quota", &st) || errno != ENOENT) { + kernel_iface = IFACE_GENERIC; diff --git a/extra/quota-tools/quotaon.diff b/extra/quota-tools/quotaon.diff new file mode 100644 index 000000000..6a43cee6c --- /dev/null +++ b/extra/quota-tools/quotaon.diff @@ -0,0 +1,216 @@ +# Description: Fix quotaon to work with XFS and print all informational messages only in verbose mode +# Author: Jan Kara + +diff -u quota/quotaon.c quota-tools/quotaon.c +--- quota/quotaon.c 2010-07-28 11:14:02.000000000 +0200 ++++ quota-tools/quotaon.c 2010-06-15 10:11:30.000000000 +0200 +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + + #include "quotaon.h" + #include "quota.h" +@@ -145,6 +146,19 @@ + } + } + ++int pinfo(char *fmt, ...) ++{ ++ va_list arg; ++ int ret; ++ ++ if (!(flags & FL_VERBOSE)) ++ return 0; ++ va_start(arg, fmt); ++ ret = vprintf(fmt, arg); ++ va_end(arg); ++ return ret; ++} ++ + /* + * Enable/disable rsquash on given filesystem + */ +@@ -171,10 +185,10 @@ + errstr(_("set root_squash on %s: %s\n"), quotadev, strerror(errno)); + return 1; + } +- if ((flags & STATEFLAG_VERBOSE) && (flags & STATEFLAG_OFF)) +- printf(_("%s: %s root_squash turned off\n"), quotadev, type2name(type)); +- else if ((flags & STATEFLAG_VERBOSE) && (flags & STATEFLAG_ON)) +- printf(_("%s: %s root_squash turned on\n"), quotadev, type2name(type)); ++ if (flags & STATEFLAG_OFF) ++ pinfo(_("%s: %s root_squash turned off\n"), quotadev, type2name(type)); ++ else if (flags & STATEFLAG_ON) ++ pinfo(_("%s: %s root_squash turned on\n"), quotadev, type2name(type)); + #endif + return 0; + } +@@ -195,8 +209,7 @@ + errstr(_("quotactl on %s [%s]: %s\n"), quotadev, quotadir, strerror(errno)); + return 1; + } +- if (flags & STATEFLAG_VERBOSE) +- printf(_("%s [%s]: %s quotas turned off\n"), quotadev, quotadir, type2name(type)); ++ pinfo(_("%s [%s]: %s quotas turned off\n"), quotadev, quotadir, type2name(type)); + return 0; + } + if (kernel_iface == IFACE_GENERIC) { +@@ -218,8 +231,7 @@ + errstr(_("Quota format not supported in kernel.\n")); + return 1; + } +- if (flags & STATEFLAG_VERBOSE) +- printf(_("%s [%s]: %s quotas turned on\n"), quotadev, quotadir, type2name(type)); ++ pinfo(_("%s [%s]: %s quotas turned on\n"), quotadev, quotadir, type2name(type)); + return 0; + } + +@@ -268,8 +280,6 @@ + int sflags, ret = 0; + + sflags = flags & FL_OFF ? STATEFLAG_OFF : STATEFLAG_ON; +- if (flags & FL_VERBOSE) +- sflags |= STATEFLAG_VERBOSE; + if (flags & FL_ALL) + sflags |= STATEFLAG_ALL; + +@@ -281,10 +291,7 @@ + errstr(_("Cannot change state of XFS quota. It's not compiled in kernel.\n")); + return 1; + } +- if ((flags & FL_OFF && (kern_quota_on(mnt->mnt_fsname, USRQUOTA, QF_XFS) != -1 +- || kern_quota_on(mnt->mnt_fsname, GRPQUOTA, QF_XFS) != -1)) +- || (!(flags & FL_OFF) && kern_quota_on(mnt->mnt_fsname, type, QF_XFS) == -1)) +- ret = xfs_newstate(mnt, type, extra, sflags); ++ ret = xfs_newstate(mnt, type, extra, sflags); + } + else if (meta_qf_fstype(mnt->mnt_type)) { + if (!hasquota(mnt, type, 0)) +@@ -376,7 +383,7 @@ + while ((mnt = get_next_mount())) { + if (nfs_fstype(mnt->mnt_type)) { + if (!(flags & FL_ALL)) +- fprintf(stderr, "%s: Quota cannot be turned on on NFS filesystem\n", mnt->mnt_fsname); ++ errstr(_("%s: Quota cannot be turned on on NFS filesystem\n"), mnt->mnt_fsname); + continue; + } + +diff -u quota/quotaon.h quota-tools/quotaon.h +--- quota/quotaon.h 2010-02-18 09:44:11.000000000 +0100 ++++ quota-tools/quotaon.h 2010-06-12 12:06:08.000000000 +0200 +@@ -13,7 +13,7 @@ + #define STATEFLAG_ON 0x01 + #define STATEFLAG_OFF 0x02 + #define STATEFLAG_ALL 0x04 +-#define STATEFLAG_VERBOSE 0x08 + + typedef int (newstate_t) (struct mntent * mnt, int type, char *file, int flags); + extern int xfs_newstate(struct mntent *mnt, int type, char *file, int flags); ++extern int pinfo(char *fmt, ...); +diff -u quota/quotaon_xfs.c quota-tools/quotaon_xfs.c +--- quota/quotaon_xfs.c 2010-07-26 18:48:24.000000000 +0200 ++++ quota-tools/quotaon_xfs.c 2010-06-15 10:11:30.000000000 +0200 +@@ -59,8 +59,8 @@ + return 1; + case Q_XFS_QUOTAON: + if (roothack) { +- printf(_("Enabling %s quota on root filesystem" +- " (reboot to take effect)\n"), type2name(type)); ++ pinfo(_("Enabling %s quota on root filesystem" ++ " (reboot to take effect)\n"), type2name(type)); + return 1; + } + errstr(_("Enable XFS %s quota accounting during mount\n"), +@@ -79,12 +79,12 @@ + return -1; + case Q_XFS_QUOTAON: + if (roothack) { +- printf(_("Enabling %s quota on root filesystem" +- " (reboot to take effect)\n"), type2name(type)); ++ pinfo(_("Enabling %s quota on root filesystem" ++ " (reboot to take effect)\n"), type2name(type)); + return 1; + } + if (xopts & XFS_QUOTA_UDQ_ENFD || xopts & XFS_QUOTA_GDQ_ENFD) { +- printf(_("Enabling %s quota enforcement on %s\n"), type2name(type), dev); ++ pinfo(_("Enabling %s quota enforcement on %s\n"), type2name(type), dev); + return 1; + } + errstr(_("Already accounting %s quota on %s\n"), +@@ -92,7 +92,7 @@ + return -1; + case Q_XFS_QUOTAOFF: + if (xopts & XFS_QUOTA_UDQ_ACCT || xopts & XFS_QUOTA_GDQ_ACCT) { +- printf(_("Disabling %s quota accounting on %s\n"), ++ pinfo(_("Disabling %s quota accounting on %s\n"), + type2name(type), dev); + return 1; + } +@@ -121,9 +121,9 @@ + return -1; + } + if (xopts & XFS_QUOTA_UDQ_ACCT || xopts & XFS_QUOTA_GDQ_ACCT) +- acctstr = _("and accounting "); +- printf(_("Disabling %s quota enforcement %son %s\n"), +- type2name(type), acctstr, dev); ++ acctstr = _("and accounting "); ++ pinfo(_("Disabling %s quota enforcement %son %s\n"), ++ type2name(type), acctstr, dev); + return 1; + } + break; +@@ -146,10 +146,10 @@ + errstr(_("quotactl on %s: %s\n"), dev, strerror(errno)); + return 1; + } +- if ((flags & STATEFLAG_VERBOSE) && qoff) +- printf(_("%s: %s quotas turned off\n"), dev, type2name(type)); +- else if ((flags & STATEFLAG_VERBOSE) && !qoff) +- printf(_("%s: %s quotas turned on\n"), dev, type2name(type)); ++ if (qoff) ++ pinfo(_("%s: %s quotas turned off\n"), dev, type2name(type)); ++ else ++ pinfo(_("%s: %s quotas turned on\n"), dev, type2name(type)); + return 0; + } + +@@ -168,8 +168,7 @@ + return 1; + } + +- if (flags & STATEFLAG_VERBOSE) +- printf(_("%s: deleted %s quota blocks\n"), dev, type2name(type)); ++ pinfo(_("%s: deleted %s quota blocks\n"), dev, type2name(type)); + return 0; + } + +@@ -208,16 +207,12 @@ + } + #endif /* XFS_ROOTHACK */ + +- if (xarg == NULL) { /* both acct & enfd on/off */ +- xopts |= (type == USRQUOTA) ? +- (XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_UDQ_ENFD) : +- (XFS_QUOTA_GDQ_ACCT | XFS_QUOTA_GDQ_ENFD); ++ if (xarg == NULL) { /* only enfd on/off */ ++ xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ENFD : ++ XFS_QUOTA_GDQ_ENFD; + err = xfs_onoff((char *)dev, type, flags, roothack, xopts); + } + else if (strcmp(xarg, "account") == 0) { +- /* only useful if we want root accounting only */ +- if (!roothack || !(flags & STATEFLAG_ON)) +- goto done; + xopts |= (type == USRQUOTA) ? XFS_QUOTA_UDQ_ACCT : XFS_QUOTA_GDQ_ACCT; + err = xfs_onoff((char *)dev, type, flags, roothack, xopts); + } +@@ -231,7 +226,6 @@ + } + else + die(1, _("Invalid argument \"%s\"\n"), xarg); +- done: + free((char *)dev); + return err; + } diff --git a/extra/quota-tools/repquota.diff b/extra/quota-tools/repquota.diff new file mode 100644 index 000000000..3d79497d9 --- /dev/null +++ b/extra/quota-tools/repquota.diff @@ -0,0 +1,91 @@ +# Description: fix repquota to get latest quota info header +# Author: Jan Kara + +diff -u quota/quotaio.c quota-tools/quotaio.c +--- quota/quotaio.c 2010-07-28 11:14:02.000000000 +0200 ++++ quota-tools/quotaio.c 2010-05-28 09:05:21.000000000 +0200 +@@ -147,6 +147,15 @@ + } + } + if (!QIO_ENABLED(h) || flags & IOI_OPENFILE) { /* Need to open file? */ ++ if (QIO_ENABLED(h)) { /* Kernel uses same file? */ ++ unsigned int cmd = ++ (kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC; ++ if (quotactl(QCMD(cmd, h->qh_type), h->qh_quotadev, ++ 0, NULL) < 0) { ++ die(4, _("Cannot sync quotas on device %s: %s\n"), ++ h->qh_quotadev, strerror(errno)); ++ } ++ } + /* We still need to open file for operations like 'repquota' */ + if ((fd = open(qfname, QIO_RO(h) ? O_RDONLY : O_RDWR)) < 0) { + errstr(_("Cannot open quotafile %s: %s\n"), +diff -u quota/quotaio_v1.c quota-tools/quotaio_v1.c +--- quota/quotaio_v1.c 2010-07-26 18:48:24.000000000 +0200 ++++ quota-tools/quotaio_v1.c 2010-05-28 09:05:23.000000000 +0200 +@@ -348,11 +348,6 @@ + struct dquot *dquot = get_empty_dquot(); + qid_t id = 0; + +- if (QIO_ENABLED(h)) /* Kernel uses same file? */ +- if (quotactl(QCMD((kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC, h->qh_type), +- h->qh_quotadev, 0, NULL) < 0) +- die(4, _("Cannot sync quotas on device %s: %s\n"), h->qh_quotadev, +- strerror(errno)); + memset(dquot, 0, sizeof(*dquot)); + dquot->dq_h = h; + lseek(h->qh_fd, 0, SEEK_SET); +diff -u quota/quotaio_v2.c quota-tools/quotaio_v2.c +--- quota/quotaio_v2.c 2010-02-18 09:44:11.000000000 +0100 ++++ quota-tools/quotaio_v2.c 2010-05-28 09:05:23.000000000 +0200 +@@ -484,11 +484,6 @@ + + static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *, char *)) + { +- if (QIO_ENABLED(h)) /* Kernel uses same file? */ +- if (quotactl(QCMD((kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC, h->qh_type), +- h->qh_quotadev, 0, NULL) < 0) +- die(4, _("Cannot sync quotas on device %s: %s\n"), h->qh_quotadev, +- strerror(errno)); + return qtree_scan_dquots(h, process_dquot); + } + +diff -u quota/quotasys.c quota-tools/quotasys.c +--- quota/quotasys.c 2010-07-28 11:14:02.000000000 +0200 ++++ quota-tools/quotasys.c 2010-06-15 10:11:30.000000000 +0200 +@@ -861,22 +861,23 @@ + if (kernel_iface == IFACE_GENERIC) { + int actfmt; + +- if (quotactl(QCMD(Q_GETFMT, type), dev, 0, (void *)&actfmt) < 0) +- return -1; +- actfmt = kern2utilfmt(actfmt); +- if (actfmt < 0) +- return -1; +- return actfmt; ++ if (quotactl(QCMD(Q_GETFMT, type), dev, 0, ++ (void *)&actfmt) >= 0) { ++ actfmt = kern2utilfmt(actfmt); ++ if (actfmt >= 0) ++ return actfmt; ++ } ++ } else { ++ if ((fmt == -1 || fmt == QF_VFSV0) && ++ v2_kern_quota_on(dev, type)) /* VFSv0 quota format */ ++ return QF_VFSV0; ++ if ((fmt == -1 || fmt == QF_VFSOLD) && ++ v1_kern_quota_on(dev, type)) /* Old quota format */ ++ return QF_VFSOLD; + } +- if ((fmt == -1 || fmt == QF_VFSV0) && +- v2_kern_quota_on(dev, type)) /* VFSv0 quota format */ +- return QF_VFSV0; + if ((fmt == -1 || fmt == QF_XFS) && + xfs_kern_quota_on(dev, type)) /* XFS quota format */ + return QF_XFS; +- if ((fmt == -1 || fmt == QF_VFSOLD) && +- v1_kern_quota_on(dev, type)) /* Old quota format */ +- return QF_VFSOLD; + return -1; + } + diff --git a/extra/quota-tools/system_inodes.diff b/extra/quota-tools/system_inodes.diff new file mode 100644 index 000000000..94f4d66da --- /dev/null +++ b/extra/quota-tools/system_inodes.diff @@ -0,0 +1,18 @@ +# Description: Do not count system inodes into quota for ext[234] +# Author: Jan Kara + +--- quota/quotacheck.c 2010-02-18 09:44:10.000000000 +0100 ++++ quota-tools//quotacheck.c 2010-05-22 16:47:53.000000000 +0200 +@@ -455,8 +455,10 @@ + return -1; + } + +- while ((long)i_num) { +- if (inode.i_links_count) { ++ while (i_num) { ++ if ((i_num == EXT2_ROOT_INO || ++ i_num >= EXT2_FIRST_INO(fs->super)) && ++ inode.i_links_count) { + debug(FL_DEBUG, _("Found i_num %ld, blocks %ld\n"), (long)i_num, (long)inode.i_blocks); + if (flags & FL_VERBOSE) + blit(NULL); -- cgit v1.2.3-54-g00ecf