[quota] Add quotasync tool
Petr Pisar
ppisar at fedoraproject.org
Fri Feb 4 12:37:18 UTC 2011
commit cd814ce168a655773cb4f29d78cfbab397fe62cd
Author: Petr Písař <ppisar at redhat.com>
Date: Fri Feb 4 13:27:11 2011 +0100
Add quotasync tool
quota-4.00_pre1-Add-quotasync-tool.patch | 182 ++++++++++++++++++++++++++++++
quota.spec | 4 +
2 files changed, 186 insertions(+), 0 deletions(-)
---
diff --git a/quota-4.00_pre1-Add-quotasync-tool.patch b/quota-4.00_pre1-Add-quotasync-tool.patch
new file mode 100644
index 0000000..e2b595d
--- /dev/null
+++ b/quota-4.00_pre1-Add-quotasync-tool.patch
@@ -0,0 +1,182 @@
+From 1be8727ae92a78a5e7fde5ecc6c59740ca2eabe4 Mon Sep 17 00:00:00 2001
+From: Abhijith Das <adas at redhat.com>
+Date: Tue, 1 Feb 2011 17:16:12 +0100
+Subject: [PATCH] Add quotasync tool
+
+Add tool allowing to sync quotas for some / all filesystems.
+
+Signed-off-by: Jan Kara <jack at suse.cz>
+
+Petr Pisar: Remove STRIP from Makefile.in
+---
+ Makefile.in | 8 ++-
+ quotasync.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 132 insertions(+), 3 deletions(-)
+ create mode 100644 quotasync.c
+
+diff --git a/Makefile.in b/Makefile.in
+index aeaa79f..0b343a3 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -1,5 +1,5 @@
+-PROGS = quotacheck quotaon quota quot repquota warnquota quotastats xqmstats edquota setquota convertquota rpc.rquotad @QUOTA_NETLINK_PROG@
+-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_tree.c quotaio_xfs.c quotaio_meta.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 svc_socket.c
++PROGS = quotacheck quotaon quota quot repquota warnquota quotastats xqmstats edquota setquota convertquota rpc.rquotad quotasync @QUOTA_NETLINK_PROG@
++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_tree.c quotaio_xfs.c quotaio_meta.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 svc_socket.c quotasync.c
+ CFLAGS = @CFLAGS@ -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ CPPFLAGS = @CPPFLAGS@
+ EXT2LIBS = @EXT2LIBS@
+@@ -94,7 +94,7 @@ install: all @INSTMO@
+ -mkdir -p $(ROOTDIR)$(mandir)/man8
+ -$(INSTALL) -m 755 -d $(ROOTDIR)$(includedir)/rpcsvc
+ -$(INSTALL) -m 644 rquota.h rquota.x $(ROOTDIR)$(includedir)/rpcsvc
+- -$(INSTALL) -m $(DEF_SBIN_MODE) quota $(ROOTDIR)$(bindir)
++ -$(INSTALL) -m $(DEF_SBIN_MODE) quota quotasync $(ROOTDIR)$(bindir)
+ -$(INSTALL) -m $(DEF_SBIN_MODE) rpc.rquotad $(ROOTDIR)$(sbindir)
+ ifneq ($(NETLINKLIBS),)
+ -$(INSTALL) -m $(DEF_SBIN_MODE) quota_nld $(ROOTDIR)$(sbindir)
+@@ -111,6 +111,8 @@ quotacheck: quotacheck.o quotacheck_v1.o quotacheck_v2.o quotaops.o $(LIBOBJS)
+
+ quota: quota.o quotaops.o $(LIBOBJS)
+
++quotasync: quotasync.o $(LIBOBJS)
++
+ quot: quot.o $(LIBOBJS)
+
+ repquota: repquota.o $(LIBOBJS)
+diff --git a/quotasync.c b/quotasync.c
+new file mode 100644
+index 0000000..0ce44c9
+--- /dev/null
++++ b/quotasync.c
+@@ -0,0 +1,127 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <string.h>
++#include <errno.h>
++#include <getopt.h>
++
++#include "pot.h"
++#include "common.h"
++#include "quotasys.h"
++#include "quotaio.h"
++
++#define FL_USER 1 /* sync user quotas */
++#define FL_GROUP 2 /* sync group quotas */
++#define FL_ALL 4 /* sync quotas on all filesystems */
++
++int flags, fmt = -1;
++char **mnt;
++int mntcnt;
++char *progname;
++
++static void usage(void)
++{
++ errstr(_("Utility for syncing quotas.\nUsage:\n%s [-ug] -a | mntpoint...\n\n"), progname);
++ fprintf(stderr, _("Bugs to %s\n"), MY_EMAIL);
++ exit(1);
++}
++
++static void parse_options(int argcnt, char **argstr)
++{
++ int ret;
++ struct option long_opts[] = {
++ { "user", 0, NULL, 'u' },
++ { "group", 0, NULL, 'g' },
++ { "all", 0, NULL, 'a' },
++ { "version", 0, NULL, 'V' },
++ { "help", 0, NULL, 'h' },
++ { NULL, 0, NULL, 0 }
++ };
++
++ while ((ret = getopt_long(argcnt, argstr, "ahugV", long_opts, NULL)) != -1) {
++ switch (ret) {
++ case '?':
++ case 'h':
++ usage();
++ case 'V':
++ version();
++ exit(0);
++ case 'u':
++ flags |= FL_USER;
++ break;
++ case 'g':
++ flags |= FL_GROUP;
++ break;
++ case 'a':
++ flags |= FL_ALL;
++ break;
++ }
++ }
++
++ if ((flags & FL_ALL && optind != argcnt) ||
++ (!(flags & FL_ALL) && optind == argcnt)) {
++ fputs(_("Bad number of arguments.\n"), stderr);
++ usage();
++ }
++ if (!(flags & FL_ALL)) {
++ mnt = argstr + optind;
++ mntcnt = argcnt - optind;
++ }
++ if (!(flags & (FL_USER | FL_GROUP)))
++ flags |= FL_USER;
++}
++
++static int sync_one(int type, char *dev)
++{
++ int qcmd = QCMD(Q_SYNC, type);
++
++ return quotactl(qcmd, dev, 0, NULL);
++}
++
++int syncquotas(int type)
++{
++ struct quota_handle **handles, *h;
++ int i, ret = 0;
++
++ if (flags & FL_ALL) {
++ if (sync_one(type, NULL) < 0)
++ errstr(_("%s quota sync failed: %s\n"), type2name(type),
++ strerror(errno));
++ return -1;
++ }
++
++ handles = create_handle_list(mntcnt, mnt, type, fmt,
++ IOI_READONLY, MS_LOCALONLY | MS_NO_AUTOFS);
++
++ for (i = 0; handles[i]; i++) {
++ h = handles[i];
++ if (sync_one(type, h->qh_quotadev)) {
++ errstr(_("%s quota sync failed for %s: %s\n"),
++ type2name(type), h->qh_quotadev, strerror(errno));
++ ret = -1;
++ }
++ }
++ dispose_handle_list(handles);
++
++ return ret;
++}
++
++int main(int argc, char **argv)
++{
++ int ret = 0;
++
++ gettexton();
++ progname = basename(argv[0]);
++
++ parse_options(argc, argv);
++ init_kernel_interface();
++
++ if (flags & FL_USER)
++ if (syncquotas(USRQUOTA))
++ ret = 1;
++ if (flags & FL_GROUP)
++ if (syncquotas(GRPQUOTA))
++ ret = 1;
++ return ret;
++}
+--
+1.7.4
+
diff --git a/quota.spec b/quota.spec
index f224810..e7f18db 100644
--- a/quota.spec
+++ b/quota.spec
@@ -54,6 +54,8 @@ Patch17: quota-4.00_pre1-Added-reference-to-setquota-to-quota-1-manpage.patch
Patch18: quota-4.00_pre1-Correct-no-mixed-pathnames-documentation.patch
# Bug #634137, submitted to upstream
Patch19: quota-4.00_pre1-Store-PID-of-quota_nld.patch
+# Bug #596794, in upstream 4.00_pre2
+Patch20: quota-4.00_pre1-Add-quotasync-tool.patch
%description
The quota package contains system administration tools for monitoring
@@ -143,6 +145,7 @@ Linux/UNIX environment.
%patch17 -p1 -b .reference_to_setquota_doc
%patch18 -p1 -b .mixed_pathnames_doc
%patch19 -p1 -b .store_pid
+%patch20 -p1 -b .add_quotasync
# quotactl(2) moved into `man-pages' package (bug #640590)
rm -f quotactl.2
# remove VCS files
@@ -268,6 +271,7 @@ rm -rf %{buildroot}
* Fri Feb 04 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-0.6.pre1
- Store quota_nld PID into PID file (bug #634137)
- Do not allow non-root to control quota_nld service (bug #634137)
+- Add quotasync tool (bug #596794)
* Wed Feb 02 2011 Petr Pisar <ppisar at redhat.com> - 1:4.00-0.5.pre1
- Correct manual pages
More information about the scm-commits
mailing list