summaryrefslogtreecommitdiff
path: root/testing/quota-tools
diff options
context:
space:
mode:
Diffstat (limited to 'testing/quota-tools')
-rw-r--r--testing/quota-tools/LICENSE33
-rw-r--r--testing/quota-tools/PKGBUILD49
-rw-r--r--testing/quota-tools/nulls.diff20
-rw-r--r--testing/quota-tools/quotaon.diff216
-rw-r--r--testing/quota-tools/repquota.diff91
-rw-r--r--testing/quota-tools/system_inodes.diff18
6 files changed, 427 insertions, 0 deletions
diff --git a/testing/quota-tools/LICENSE b/testing/quota-tools/LICENSE
new file mode 100644
index 000000000..4bae71589
--- /dev/null
+++ b/testing/quota-tools/LICENSE
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1980, 1990 Regents of the University of California. All
+ * rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by Robert Elz at
+ * The University of Melbourne.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. 2.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution. 3. All advertising
+ * materials mentioning features or use of this software must display the
+ * following acknowledgement: This product includes software developed by the
+ * University of California, Berkeley and its contributors. 4. Neither the
+ * name of the University nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
diff --git a/testing/quota-tools/PKGBUILD b/testing/quota-tools/PKGBUILD
new file mode 100644
index 000000000..79bb209a4
--- /dev/null
+++ b/testing/quota-tools/PKGBUILD
@@ -0,0 +1,49 @@
+# $Id: PKGBUILD 131802 2011-07-15 11:55:43Z eric $
+# Maintainer: Eric BĂ©langer <eric@archlinux.org>
+
+pkgname=quota-tools
+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')
+backup=('etc/warnquota.conf' 'etc/quotatab' 'etc/quotagrpadmins')
+options=('!emptydirs')
+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
+}
+
+package() {
+ cd "${srcdir}/${pkgname}"
+ make ROOTDIR="${pkgdir}" install
+ install -D -m644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+
+# remove conflicts with glibc and man-pages
+ rm "${pkgdir}"/usr/include/rpcsvc/rquota.{h,x}
+ rm "${pkgdir}/usr/share/man/man2/quotactl.2"
+}
diff --git a/testing/quota-tools/nulls.diff b/testing/quota-tools/nulls.diff
new file mode 100644
index 000000000..97c5bc482
--- /dev/null
+++ b/testing/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/testing/quota-tools/quotaon.diff b/testing/quota-tools/quotaon.diff
new file mode 100644
index 000000000..6a43cee6c
--- /dev/null
+++ b/testing/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 <getopt.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <stdarg.h>
+
+ #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/testing/quota-tools/repquota.diff b/testing/quota-tools/repquota.diff
new file mode 100644
index 000000000..3d79497d9
--- /dev/null
+++ b/testing/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/testing/quota-tools/system_inodes.diff b/testing/quota-tools/system_inodes.diff
new file mode 100644
index 000000000..94f4d66da
--- /dev/null
+++ b/testing/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);