Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src Add quotactl(8), a tools which reads a quota command...
details: https://anonhg.NetBSD.org/src/rev/a1b3cf63b7da
branches: bouyer-quota2
changeset: 761102:a1b3cf63b7da
user: bouyer <bouyer%NetBSD.org@localhost>
date: Mon Jan 31 21:14:05 2011 +0000
description:
Add quotactl(8), a tools which reads a quota command plist from stdin or file
and send it to kernel.
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/man/mi | 5 +-
usr.sbin/Makefile | 4 +-
usr.sbin/quotactl/Makefile | 16 +++
usr.sbin/quotactl/quotactl.8 | 80 ++++++++++++++++++
usr.sbin/quotactl/quotactl.c | 182 +++++++++++++++++++++++++++++++++++++++++++
6 files changed, 286 insertions(+), 4 deletions(-)
diffs (truncated from 358 to 300 lines):
diff -r 4666ece5dc8b -r a1b3cf63b7da distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Mon Jan 31 21:09:53 2011 +0000
+++ b/distrib/sets/lists/base/mi Mon Jan 31 21:14:05 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.915 2011/01/13 22:28:36 haad Exp $
+# $NetBSD: mi,v 1.915.2.1 2011/01/31 21:14:05 bouyer Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -1330,6 +1330,7 @@
./usr/sbin/pwd_mkdb base-sysutil-bin
./usr/sbin/quot base-sysutil-bin
./usr/sbin/quotacheck base-sysutil-bin
+./usr/sbin/quotactl base-sysutil-bin
./usr/sbin/quotaoff base-sysutil-bin
./usr/sbin/quotaon base-sysutil-bin
./usr/sbin/racoon base-netutil-bin crypto
diff -r 4666ece5dc8b -r a1b3cf63b7da distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Mon Jan 31 21:09:53 2011 +0000
+++ b/distrib/sets/lists/man/mi Mon Jan 31 21:14:05 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1278 2011/01/17 16:08:19 jmcneill Exp $
+# $NetBSD: mi,v 1.1278.2.1 2011/01/31 21:14:05 bouyer Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2578,6 +2578,7 @@
./usr/share/man/cat8/qmqpd.0 man-obsolete obsolete
./usr/share/man/cat8/quot.0 man-sysutil-catman .cat
./usr/share/man/cat8/quotacheck.0 man-sysutil-catman .cat
+./usr/share/man/cat8/quotactl.0 man-sysutil-catman .cat
./usr/share/man/cat8/quotaoff.0 man-sysutil-catman .cat
./usr/share/man/cat8/quotaon.0 man-sysutil-catman .cat
./usr/share/man/cat8/racoon.0 man-netutil-catman crypto,.cat
@@ -5068,6 +5069,7 @@
./usr/share/man/html8/qmgr.html man-postfix-htmlman postfix,html
./usr/share/man/html8/quot.html man-sysutil-htmlman html
./usr/share/man/html8/quotacheck.html man-sysutil-htmlman html
+./usr/share/man/html8/quotactl.html man-sysutil-htmlman html
./usr/share/man/html8/quotaoff.html man-sysutil-htmlman html
./usr/share/man/html8/quotaon.html man-sysutil-htmlman html
./usr/share/man/html8/racoon.html man-netutil-htmlman crypto,html
@@ -7832,6 +7834,7 @@
./usr/share/man/man8/qmqpd.8 man-obsolete obsolete
./usr/share/man/man8/quot.8 man-sysutil-man .man
./usr/share/man/man8/quotacheck.8 man-sysutil-man .man
+./usr/share/man/man8/quotactl.8 man-sysutil-man .man
./usr/share/man/man8/quotaoff.8 man-sysutil-man .man
./usr/share/man/man8/quotaon.8 man-sysutil-man .man
./usr/share/man/man8/racoon.8 man-netutil-man crypto,.man
diff -r 4666ece5dc8b -r a1b3cf63b7da usr.sbin/Makefile
--- a/usr.sbin/Makefile Mon Jan 31 21:09:53 2011 +0000
+++ b/usr.sbin/Makefile Mon Jan 31 21:14:05 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.250 2011/01/13 22:28:35 haad Exp $
+# $NetBSD: Makefile,v 1.250.2.1 2011/01/31 21:14:06 bouyer Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@@ -16,7 +16,7 @@
mrinfo mrouted mscdlabel mtrace \
mtree ndbootd ndiscvt netgroup_mkdb nfsd ofctl paxctl pcictl \
pppd psrset pstat pwd_mkdb postinstall powerd puffs quot quotacheck \
- quotaon rarpd rbootd rdate \
+ quotactl quotaon rarpd rbootd rdate \
repquota rmt rpc.bootparamd rpc.lockd rpc.pcnfsd \
rpc.statd rpcbind rwhod sa screenblank sdpd services_mkdb sesd \
schedctl sliplogin \
diff -r 4666ece5dc8b -r a1b3cf63b7da usr.sbin/quotactl/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/quotactl/Makefile Mon Jan 31 21:14:05 2011 +0000
@@ -0,0 +1,16 @@
+# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
+# $NetBSD: Makefile,v 1.1.2.1 2011/01/31 21:14:06 bouyer Exp $
+
+.include <bsd.own.mk>
+PROG= quotactl
+SRCS= quotactl.c
+MAN= quotactl.8
+
+CPPFLAGS+=-I${NETBSDSRCDIR}/sys
+DPADD= ${LIBPROP}
+LDADD= -lprop
+
+.PATH: ${NETBSDSRCDIR}/sys/ufs/ufs
+SRCS+= quota2_prop.c
+
+.include <bsd.prog.mk>
diff -r 4666ece5dc8b -r a1b3cf63b7da usr.sbin/quotactl/quotactl.8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/quotactl/quotactl.8 Mon Jan 31 21:14:05 2011 +0000
@@ -0,0 +1,80 @@
+.\" $NetBSD: quotactl.8,v 1.1.2.1 2011/01/31 21:14:06 bouyer Exp $
+.\"
+.\" Copyright (c) 2011 Manuel Bouyer
+.\" All rights reserved.
+.\"
+.\" 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+.\"
+.\"
+.Dd January 31, 2011
+.Dt QUOTACTL 8
+.Os
+.Sh NAME
+.Nm quotactl
+.Nd send commands to the kernel disk quota subsystem
+.Sh SYNOPSIS
+.Nm
+.Op Fl D
+.Op Fl x
+.Ar filesystem
+.Op Ar plist
+.Sh DESCRIPTION
+.Nm
+reads a property list of commands from the specified file or stdin,
+and sends it to the kernel for the specified filesystem through the
+.Xr quotactl 2
+system call.
+.Pp
+Available options:
+.Bl -tag -width Ds
+.It Fl x
+Do not parse reply from kernel for errors and print it to stdout
+.It Fl D
+Debug: print plist sent to and received from kernel to stderr
+.El
+.Pp
+If
+.Fl x
+is not specified,
+.Nm
+parses the reply from the kernel, looking at each command return value
+and reporting errors.
+.Sh EXIT STATUS
+.Nm
+exists with 0 on success. If there was problems parsing the command plist,
+or the reply from the kernel, or if the
+.Xr quotactl 2
+system call returned an error, the exist status will be 1.
+Unless
+.Fl x
+is present, a message is printed to stderr for each failed command,
+and the exit status will be 2 if any comand failed.
+.Sh SEE ALSO
+.Xr quota 1 ,
+.Xr quotactl 2 ,
+.Xr proplib 3 ,
+.Xr edquota 8 ,
+.Xr repquota 8 .
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Nx 6.0 .
diff -r 4666ece5dc8b -r a1b3cf63b7da usr.sbin/quotactl/quotactl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/quotactl/quotactl.c Mon Jan 31 21:14:05 2011 +0000
@@ -0,0 +1,182 @@
+/* $NetBSD: quotactl.c,v 1.1.2.1 2011/01/31 21:14:06 bouyer Exp $ */
+/*-
+ * Copyright (c) 2011 Manuel Bouyer
+ * All rights reserved.
+ * This software is distributed under the following condiions
+ * compliant with the NetBSD foundation policy.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: quotactl.c,v 1.1.2.1 2011/01/31 21:14:06 bouyer Exp $");
+#endif /* not lint */
+
+/*
+ * Quota report
+ */
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <prop/proplib.h>
+#include <sys/quota.h>
+
+#include <errno.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <ufs/ufs/quota2_prop.h>
+
+void usage(void);
+
+#define READ_SIZE 4096
+
+int
+main(int argc, char * const argv[])
+{
+ int xflag = 0;
+ int Dflag = 0;
+ FILE *f = NULL;
+ int ch;
+ char *plist, *p;
+ size_t plistsize;
+ int status = 0, error;
+ struct plistref pref;
+ prop_dictionary_t qdict, cmd;
+ prop_array_t cmds;
+ prop_object_iterator_t cmditer;
+ const char *mp, *xmlfile = NULL;
+
+ while ((ch = getopt(argc, argv, "Dx")) != -1) {
+ switch (ch) {
+ case 'x':
+ xflag++;
+ break;
+ case 'D':
+ Dflag++;
+ break;
+ default:
+ usage();
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc == 0 || argc > 2) {
+ usage();
+ } else if (argc == 1) {
+ xmlfile = "<stdin>";
+ f = stdin;
+ } else {
+ xmlfile = argv[1];
+ f = fopen(xmlfile, "r");
+ if (f == NULL)
+ err(1, "%s", xmlfile);
+ }
+ mp = argv[0];
+
+ plist = malloc(READ_SIZE);
+ if (plist == NULL)
+ err(1, "alloc buffer");
+ p = plist;
+ plistsize = READ_SIZE;
+ while (fread(p, sizeof(char), READ_SIZE, f) == READ_SIZE) {
+ plist = realloc(plist, plistsize + READ_SIZE);
+ if (plist == NULL)
+ err(1, "realloc buffer");
+ p += READ_SIZE;
+ plistsize += READ_SIZE;
+ }
+ if (ferror(f))
+ err(1, "error reading %s", xmlfile);
+
+ qdict = prop_dictionary_internalize(plist);
+ if (qdict == NULL)
+ err(1, "can't parse %s", xmlfile);
+ free(plist);
+ if (!prop_dictionary_send_syscall(qdict, &pref))
+ err(1, "can't externalize to syscall");
+ if (Dflag) {
+ plist = prop_dictionary_externalize(qdict);
+ fprintf(stderr, "message to kernel:\n%s\n", plist);
Home |
Main Index |
Thread Index |
Old Index