disable WARNS here, fix .Nm usage, deprecate register, s/index/strchr/
This commit is contained in:
parent
2d6dc609e6
commit
0d374e0c45
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: quota.1,v 1.8 1997/10/19 04:59:23 mrg Exp $
|
.\" $NetBSD: quota.1,v 1.9 1997/10/19 13:16:33 lukem Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1983, 1990, 1993
|
.\" Copyright (c) 1983, 1990, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
@ -43,20 +43,20 @@
|
||||||
.Nm quota
|
.Nm quota
|
||||||
.Nd display disk usage and limits
|
.Nd display disk usage and limits
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm quota
|
.Nm
|
||||||
.Op Fl g
|
.Op Fl g
|
||||||
.Op Fl u
|
.Op Fl u
|
||||||
.Op Fl v | Fl q
|
.Op Fl v | Fl q
|
||||||
.Nm quota
|
.Nm ""
|
||||||
.Op Fl u
|
.Op Fl u
|
||||||
.Op Fl v | Fl q
|
.Op Fl v | Fl q
|
||||||
.Ar user
|
.Ar user
|
||||||
.Nm quota
|
.Nm ""
|
||||||
.Op Fl g
|
.Op Fl g
|
||||||
.Op Fl v | Fl q
|
.Op Fl v | Fl q
|
||||||
.Ar group
|
.Ar group
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Quota
|
.Nm
|
||||||
displays users' disk usage and limits.
|
displays users' disk usage and limits.
|
||||||
By default only the user quotas are printed.
|
By default only the user quotas are printed.
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -70,7 +70,7 @@ The optional
|
||||||
.Fl u
|
.Fl u
|
||||||
flag is equivalent to the default.
|
flag is equivalent to the default.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
.Nm quota
|
.Nm
|
||||||
will display quotas on filesystems
|
will display quotas on filesystems
|
||||||
where no storage is allocated.
|
where no storage is allocated.
|
||||||
.It Fl q
|
.It Fl q
|
||||||
|
@ -103,21 +103,21 @@ flag takes precedence over the
|
||||||
.Fl v
|
.Fl v
|
||||||
flag.
|
flag.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm Quota
|
.Nm
|
||||||
tries to report the quotas of all mounted filesystems.
|
tries to report the quotas of all mounted filesystems.
|
||||||
If the filesystem is mounted via
|
If the filesystem is mounted via
|
||||||
.Nm NFS ,
|
.Em NFS
|
||||||
it will attempt to contact the
|
it will attempt to contact the
|
||||||
.Xr rpc.rquotad 8
|
.Xr rpc.rquotad 8
|
||||||
daemon on the
|
daemon on the
|
||||||
.Nm NFS
|
.Em NFS
|
||||||
server.
|
server.
|
||||||
For
|
For
|
||||||
.Nm FFS
|
.Em FFS
|
||||||
filesystems, quotas must be turned on in
|
filesystems, quotas must be turned on in
|
||||||
.Pa /etc/fstab .
|
.Pa /etc/fstab .
|
||||||
If
|
If
|
||||||
.Nm quota
|
.Nm
|
||||||
exits with a non-zero status, one or more filesystems
|
exits with a non-zero status, one or more filesystems
|
||||||
are over quota.
|
are over quota.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
|
@ -131,7 +131,7 @@ to find filesystem names and locations
|
||||||
.El
|
.El
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Nm quota
|
.Nm
|
||||||
command appeared in
|
command appeared in
|
||||||
.Bx 4.2 .
|
.Bx 4.2 .
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: quota.c,v 1.15 1997/10/19 04:59:20 mrg Exp $ */
|
/* $NetBSD: quota.c,v 1.16 1997/10/19 13:16:42 lukem Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1980, 1990, 1993
|
* Copyright (c) 1980, 1990, 1993
|
||||||
|
@ -36,17 +36,17 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
__COPYRIGHT("@(#) Copyright (c) 1980, 1990, 1993\n\
|
||||||
"@(#) Copyright (c) 1980, 1990, 1993\n\
|
The Regents of the University of California. All rights reserved.\n");
|
||||||
The Regents of the University of California. All rights reserved.\n";
|
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95";
|
||||||
#else
|
#else
|
||||||
static char rcsid[] = "$NetBSD: quota.c,v 1.15 1997/10/19 04:59:20 mrg Exp $";
|
__RCSID("$NetBSD: quota.c,v 1.16 1997/10/19 13:16:42 lukem Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -62,16 +62,17 @@ static char rcsid[] = "$NetBSD: quota.c,v 1.15 1997/10/19 04:59:20 mrg Exp $";
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
#include <ufs/ufs/quota.h>
|
#include <ufs/ufs/quota.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fstab.h>
|
#include <fstab.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/pmap_prot.h>
|
#include <rpc/pmap_prot.h>
|
||||||
|
@ -88,21 +89,37 @@ struct quotause {
|
||||||
};
|
};
|
||||||
#define FOUND 0x01
|
#define FOUND 0x01
|
||||||
|
|
||||||
char *timeprt __P((time_t seconds));
|
int alldigits __P((char *));
|
||||||
struct quotause *getprivs __P((long id, int quotatype));
|
int callaurpc __P((char *, int, int, int, xdrproc_t, void *,
|
||||||
|
xdrproc_t, void *));
|
||||||
|
int main __P((int, char **));
|
||||||
|
int getnfsquota __P((struct statfs *, struct fstab *, struct quotause *,
|
||||||
|
long, int));
|
||||||
|
struct quotause *getprivs __P((long id, int quotatype));
|
||||||
|
int getufsquota __P((struct statfs *, struct fstab *, struct quotause *,
|
||||||
|
long, int));
|
||||||
|
void heading __P((int, u_long, char *, char *));
|
||||||
|
void showgid __P((gid_t));
|
||||||
|
void showgrpname __P((char *));
|
||||||
|
void showquotas __P((int, u_long, char *));
|
||||||
|
void showuid __P((uid_t));
|
||||||
|
void showusrname __P((char *));
|
||||||
|
char *timeprt __P((time_t seconds));
|
||||||
|
int ufshasquota __P((struct fstab *, int, char **));
|
||||||
|
void usage __P((void));
|
||||||
|
|
||||||
int qflag;
|
int qflag;
|
||||||
int vflag;
|
int vflag;
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
int ngroups;
|
int ngroups;
|
||||||
gid_t mygid, gidset[NGROUPS];
|
gid_t mygid, gidset[NGROUPS];
|
||||||
int i, gflag = 0, uflag = 0;
|
int i, gflag = 0, uflag = 0;
|
||||||
int ch;
|
int ch;
|
||||||
extern char *optarg;
|
|
||||||
extern int optind, errno;
|
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "ugvq")) != -1) {
|
while ((ch = getopt(argc, argv, "ugvq")) != -1) {
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
@ -132,10 +149,8 @@ main(argc, argv)
|
||||||
if (gflag) {
|
if (gflag) {
|
||||||
mygid = getgid();
|
mygid = getgid();
|
||||||
ngroups = getgroups(NGROUPS, gidset);
|
ngroups = getgroups(NGROUPS, gidset);
|
||||||
if (ngroups < 0) {
|
if (ngroups < 0)
|
||||||
perror("quota: getgroups");
|
err(1, "getgroups");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
showgid(mygid);
|
showgid(mygid);
|
||||||
for (i = 0; i < ngroups; i++)
|
for (i = 0; i < ngroups; i++)
|
||||||
if (gidset[i] != mygid)
|
if (gidset[i] != mygid)
|
||||||
|
@ -163,8 +178,11 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -178,11 +196,12 @@ usage()
|
||||||
/*
|
/*
|
||||||
* Print out quotas for a specified user identifier.
|
* Print out quotas for a specified user identifier.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
showuid(uid)
|
showuid(uid)
|
||||||
u_long uid;
|
uid_t uid;
|
||||||
{
|
{
|
||||||
struct passwd *pwd = getpwuid(uid);
|
struct passwd *pwd = getpwuid(uid);
|
||||||
u_long myuid;
|
uid_t myuid;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (pwd == NULL)
|
if (pwd == NULL)
|
||||||
|
@ -200,6 +219,7 @@ showuid(uid)
|
||||||
/*
|
/*
|
||||||
* Print out quotas for a specifed user name.
|
* Print out quotas for a specifed user name.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
showusrname(name)
|
showusrname(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
|
@ -207,13 +227,12 @@ showusrname(name)
|
||||||
u_long myuid;
|
u_long myuid;
|
||||||
|
|
||||||
if (pwd == NULL) {
|
if (pwd == NULL) {
|
||||||
fprintf(stderr, "quota: %s: unknown user\n", name);
|
warnx("%s: unknown user", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myuid = getuid();
|
myuid = getuid();
|
||||||
if (pwd->pw_uid != myuid && myuid != 0) {
|
if (pwd->pw_uid != myuid && myuid != 0) {
|
||||||
fprintf(stderr, "quota: %s (uid %d): permission denied\n",
|
warnx("%s (uid %d): permission denied", name, pwd->pw_uid);
|
||||||
name, pwd->pw_uid);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showquotas(USRQUOTA, pwd->pw_uid, name);
|
showquotas(USRQUOTA, pwd->pw_uid, name);
|
||||||
|
@ -222,13 +241,14 @@ showusrname(name)
|
||||||
/*
|
/*
|
||||||
* Print out quotas for a specified group identifier.
|
* Print out quotas for a specified group identifier.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
showgid(gid)
|
showgid(gid)
|
||||||
u_long gid;
|
gid_t gid;
|
||||||
{
|
{
|
||||||
struct group *grp = getgrgid(gid);
|
struct group *grp = getgrgid(gid);
|
||||||
int ngroups;
|
int ngroups;
|
||||||
gid_t mygid, gidset[NGROUPS];
|
gid_t mygid, gidset[NGROUPS];
|
||||||
register int i;
|
int i;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (grp == NULL)
|
if (grp == NULL)
|
||||||
|
@ -238,7 +258,7 @@ showgid(gid)
|
||||||
mygid = getgid();
|
mygid = getgid();
|
||||||
ngroups = getgroups(NGROUPS, gidset);
|
ngroups = getgroups(NGROUPS, gidset);
|
||||||
if (ngroups < 0) {
|
if (ngroups < 0) {
|
||||||
perror("quota: getgroups");
|
warn("getgroups");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gid != mygid) {
|
if (gid != mygid) {
|
||||||
|
@ -246,9 +266,7 @@ showgid(gid)
|
||||||
if (gid == gidset[i])
|
if (gid == gidset[i])
|
||||||
break;
|
break;
|
||||||
if (i >= ngroups && getuid() != 0) {
|
if (i >= ngroups && getuid() != 0) {
|
||||||
fprintf(stderr,
|
warnx("%s (gid %d): permission denied", name, gid);
|
||||||
"quota: %s (gid %d): permission denied\n",
|
|
||||||
name, gid);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,22 +276,23 @@ showgid(gid)
|
||||||
/*
|
/*
|
||||||
* Print out quotas for a specifed group name.
|
* Print out quotas for a specifed group name.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
showgrpname(name)
|
showgrpname(name)
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
struct group *grp = getgrnam(name);
|
struct group *grp = getgrnam(name);
|
||||||
int ngroups;
|
int ngroups;
|
||||||
gid_t mygid, gidset[NGROUPS];
|
gid_t mygid, gidset[NGROUPS];
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if (grp == NULL) {
|
if (grp == NULL) {
|
||||||
fprintf(stderr, "quota: %s: unknown group\n", name);
|
warnx("%s: unknown group", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mygid = getgid();
|
mygid = getgid();
|
||||||
ngroups = getgroups(NGROUPS, gidset);
|
ngroups = getgroups(NGROUPS, gidset);
|
||||||
if (ngroups < 0) {
|
if (ngroups < 0) {
|
||||||
perror("quota: getgroups");
|
warn("getgroups");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (grp->gr_gid != mygid) {
|
if (grp->gr_gid != mygid) {
|
||||||
|
@ -281,8 +300,7 @@ showgrpname(name)
|
||||||
if (grp->gr_gid == gidset[i])
|
if (grp->gr_gid == gidset[i])
|
||||||
break;
|
break;
|
||||||
if (i >= ngroups && getuid() != 0) {
|
if (i >= ngroups && getuid() != 0) {
|
||||||
fprintf(stderr,
|
warnx("%s (gid %d): permission denied",
|
||||||
"quota: %s (gid %d): permission denied\n",
|
|
||||||
name, grp->gr_gid);
|
name, grp->gr_gid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -290,16 +308,16 @@ showgrpname(name)
|
||||||
showquotas(GRPQUOTA, grp->gr_gid, name);
|
showquotas(GRPQUOTA, grp->gr_gid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
showquotas(type, id, name)
|
showquotas(type, id, name)
|
||||||
int type;
|
int type;
|
||||||
u_long id;
|
u_long id;
|
||||||
char *name;
|
char *name;
|
||||||
{
|
{
|
||||||
register struct quotause *qup;
|
struct quotause *qup;
|
||||||
struct quotause *quplist;
|
struct quotause *quplist;
|
||||||
char *msgi, *msgb, *nam;
|
char *msgi, *msgb, *nam;
|
||||||
int myuid, fd, lines = 0;
|
int lines = 0;
|
||||||
static int first;
|
|
||||||
static time_t now;
|
static time_t now;
|
||||||
|
|
||||||
if (now == 0)
|
if (now == 0)
|
||||||
|
@ -375,14 +393,15 @@ showquotas(type, id, name)
|
||||||
heading(type, id, name, "none");
|
heading(type, id, name, "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
heading(type, id, name, tag)
|
heading(type, id, name, tag)
|
||||||
int type;
|
int type;
|
||||||
u_long id;
|
u_long id;
|
||||||
char *name, *tag;
|
char *name, *tag;
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("Disk quotas for %s %s (%cid %d): %s\n", qfextension[type],
|
printf("Disk quotas for %s %s (%cid %ld): %s\n", qfextension[type],
|
||||||
name, *qfextension[type], id, tag);
|
name, *qfextension[type], (u_long)id, tag);
|
||||||
if (!qflag && tag[0] == '\0') {
|
if (!qflag && tag[0] == '\0') {
|
||||||
printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n"
|
printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n"
|
||||||
, "Filesystem"
|
, "Filesystem"
|
||||||
|
@ -417,14 +436,16 @@ timeprt(seconds)
|
||||||
minutes = (seconds + 30) / 60;
|
minutes = (seconds + 30) / 60;
|
||||||
hours = (minutes + 30) / 60;
|
hours = (minutes + 30) / 60;
|
||||||
if (hours >= 36) {
|
if (hours >= 36) {
|
||||||
(void)snprintf(buf, sizeof buf, "%ddays", (hours + 12) / 24);
|
(void)snprintf(buf, sizeof buf, "%ddays",
|
||||||
|
(int)((hours + 12) / 24));
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
if (minutes >= 60) {
|
if (minutes >= 60) {
|
||||||
(void)snprintf(buf, sizeof buf, "%2d:%d", minutes / 60, minutes % 60);
|
(void)snprintf(buf, sizeof buf, "%2d:%d",
|
||||||
|
(int)(minutes / 60), (int)(minutes % 60));
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
(void)snprintf(buf, sizeof buf, "%2d", minutes);
|
(void)snprintf(buf, sizeof buf, "%2d", (int)minutes);
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,29 +454,26 @@ timeprt(seconds)
|
||||||
*/
|
*/
|
||||||
struct quotause *
|
struct quotause *
|
||||||
getprivs(id, quotatype)
|
getprivs(id, quotatype)
|
||||||
register long id;
|
long id;
|
||||||
int quotatype;
|
int quotatype;
|
||||||
{
|
{
|
||||||
register struct quotause *qup, *quptail;
|
struct quotause *qup, *quptail;
|
||||||
register struct fstab *fs;
|
struct fstab *fs;
|
||||||
struct quotause *quphead;
|
struct quotause *quphead;
|
||||||
struct statfs *fst;
|
struct statfs *fst;
|
||||||
int nfst, i;
|
int nfst, i;
|
||||||
|
|
||||||
qup = quphead = (struct quotause *)0;
|
qup = quphead = quptail = NULL;
|
||||||
|
|
||||||
nfst = getmntinfo(&fst, MNT_WAIT);
|
nfst = getmntinfo(&fst, MNT_WAIT);
|
||||||
if (nfst == 0) {
|
if (nfst == 0)
|
||||||
fprintf(stderr, "quota: no filesystems mounted!\n");
|
errx(2, "no filesystems mounted!");
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
setfsent();
|
setfsent();
|
||||||
for (i=0; i<nfst; i++) {
|
for (i=0; i<nfst; i++) {
|
||||||
if (qup == NULL) {
|
if (qup == NULL) {
|
||||||
if ((qup = (struct quotause *)malloc(sizeof *qup)) == NULL) {
|
if ((qup =
|
||||||
fprintf(stderr, "quota: out of memory\n");
|
(struct quotause *)malloc(sizeof *qup)) == NULL)
|
||||||
exit(2);
|
errx(2, "out of memory");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (strncmp(fst[i].f_fstypename, "nfs", MFSNAMELEN) == 0) {
|
if (strncmp(fst[i].f_fstypename, "nfs", MFSNAMELEN) == 0) {
|
||||||
if (getnfsquota(&fst[i], NULL, qup, id, quotatype) == 0)
|
if (getnfsquota(&fst[i], NULL, qup, id, quotatype) == 0)
|
||||||
|
@ -495,8 +513,9 @@ getprivs(id, quotatype)
|
||||||
/*
|
/*
|
||||||
* Check to see if a particular quota is to be enabled.
|
* Check to see if a particular quota is to be enabled.
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
ufshasquota(fs, type, qfnamep)
|
ufshasquota(fs, type, qfnamep)
|
||||||
register struct fstab *fs;
|
struct fstab *fs;
|
||||||
int type;
|
int type;
|
||||||
char **qfnamep;
|
char **qfnamep;
|
||||||
{
|
{
|
||||||
|
@ -513,7 +532,7 @@ ufshasquota(fs, type, qfnamep)
|
||||||
}
|
}
|
||||||
(void)strncpy(buf, fs->fs_mntops, sizeof(buf) - 1);
|
(void)strncpy(buf, fs->fs_mntops, sizeof(buf) - 1);
|
||||||
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
|
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
|
||||||
if (cp = index(opt, '='))
|
if ((cp = strchr(opt, '=')) != NULL)
|
||||||
*cp++ = '\0';
|
*cp++ = '\0';
|
||||||
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
|
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -549,7 +568,7 @@ getufsquota(fst, fs, qup, id, quotatype)
|
||||||
|
|
||||||
if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) {
|
if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) {
|
||||||
if ((fd = open(qfpathname, O_RDONLY)) < 0) {
|
if ((fd = open(qfpathname, O_RDONLY)) < 0) {
|
||||||
perror(qfpathname);
|
warn("%s", qfpathname);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
(void)lseek(fd, (off_t)(id * sizeof(struct dqblk)), SEEK_SET);
|
(void)lseek(fd, (off_t)(id * sizeof(struct dqblk)), SEEK_SET);
|
||||||
|
@ -559,13 +578,12 @@ getufsquota(fst, fs, qup, id, quotatype)
|
||||||
* Convert implicit 0 quota (EOF)
|
* Convert implicit 0 quota (EOF)
|
||||||
* into an explicit one (zero'ed dqblk)
|
* into an explicit one (zero'ed dqblk)
|
||||||
*/
|
*/
|
||||||
bzero((caddr_t)&qup->dqblk, sizeof(struct dqblk));
|
memset((caddr_t)&qup->dqblk, 0, sizeof(struct dqblk));
|
||||||
break;
|
break;
|
||||||
case sizeof(struct dqblk): /* OK */
|
case sizeof(struct dqblk): /* OK */
|
||||||
break;
|
break;
|
||||||
default: /* ERROR */
|
default: /* ERROR */
|
||||||
fprintf(stderr, "quota: read error");
|
warn("read error `%s'", qfpathname);
|
||||||
perror(qfpathname);
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -602,8 +620,7 @@ getnfsquota(fst, fs, qup, id, quotatype)
|
||||||
*/
|
*/
|
||||||
cp = strchr(fst->f_mntfromname, ':');
|
cp = strchr(fst->f_mntfromname, ':');
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
fprintf(stderr, "cannot find hostname for %s\n",
|
warnx("cannot find hostname for %s", fst->f_mntfromname);
|
||||||
fst->f_mntfromname);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,8 +643,7 @@ getnfsquota(fst, fs, qup, id, quotatype)
|
||||||
case Q_NOQUOTA:
|
case Q_NOQUOTA:
|
||||||
break;
|
break;
|
||||||
case Q_EPERM:
|
case Q_EPERM:
|
||||||
fprintf(stderr, "quota permission error, host: %s\n",
|
warnx("quota permission error, host: %s", fst->f_mntfromname);
|
||||||
fst->f_mntfromname);
|
|
||||||
break;
|
break;
|
||||||
case Q_OK:
|
case Q_OK:
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
@ -656,8 +672,7 @@ getnfsquota(fst, fs, qup, id, quotatype)
|
||||||
*cp = ':';
|
*cp = ':';
|
||||||
return (1);
|
return (1);
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "bad rpc result, host: %s\n",
|
warnx("bad rpc result, host: %s", fst->f_mntfromname);
|
||||||
fst->f_mntfromname);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*cp = ':';
|
*cp = ':';
|
||||||
|
@ -667,8 +682,11 @@ getnfsquota(fst, fs, qup, id, quotatype)
|
||||||
int
|
int
|
||||||
callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||||
char *host;
|
char *host;
|
||||||
xdrproc_t inproc, outproc;
|
int prognum, versnum, procnum;
|
||||||
char *in, *out;
|
xdrproc_t inproc;
|
||||||
|
void *in;
|
||||||
|
xdrproc_t outproc;
|
||||||
|
void *out;
|
||||||
{
|
{
|
||||||
struct sockaddr_in server_addr;
|
struct sockaddr_in server_addr;
|
||||||
enum clnt_stat clnt_stat;
|
enum clnt_stat clnt_stat;
|
||||||
|
@ -682,7 +700,7 @@ callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||||
return ((int) RPC_UNKNOWNHOST);
|
return ((int) RPC_UNKNOWNHOST);
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
timeout.tv_sec = 6;
|
timeout.tv_sec = 6;
|
||||||
bcopy(hp->h_addr, &server_addr.sin_addr, hp->h_length);
|
memmove(&server_addr.sin_addr, hp->h_addr, hp->h_length);
|
||||||
server_addr.sin_family = AF_INET;
|
server_addr.sin_family = AF_INET;
|
||||||
server_addr.sin_port = 0;
|
server_addr.sin_port = 0;
|
||||||
|
|
||||||
|
@ -699,15 +717,16 @@ callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
|
||||||
return ((int) clnt_stat);
|
return ((int) clnt_stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
alldigits(s)
|
alldigits(s)
|
||||||
register char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register c;
|
int c;
|
||||||
|
|
||||||
c = *s++;
|
c = *s++;
|
||||||
do {
|
do {
|
||||||
if (!isdigit(c))
|
if (!isdigit(c))
|
||||||
return (0);
|
return (0);
|
||||||
} while (c = *s++);
|
} while ((c = *s++) != 0);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue