* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)repquota.c 5.6 (Berkeley) %G%";
struct fileusage
*fu_next
;
char fu_name
[LOGINNAMESIZE
+ 1];
struct fileusage
*fuhead
[FUHASH
];
struct fileusage
*lookup();
struct fileusage
*adduid();
struct passwd
*getpwent();
int aflag
; /* all file systems */
register struct fstab
*fs
;
register struct passwd
*pw
;
register struct fileusage
*fup
;
char quotafile
[MAXPATHLEN
];
if (argc
> 0 && strcmp(*argv
, "-v") == 0) {
if (argc
> 0 && strcmp(*argv
, "-a") == 0) {
if (argc
<= 0 && !aflag
) {
fprintf(stderr
, "Usage:\n\t%s\n\t%s\n",
"repquota [-v] filesys ...");
while ((pw
= getpwent()) != 0) {
fup
= lookup(pw
->pw_uid
);
fup
= adduid(pw
->pw_uid
);
strncpy(fup
->fu_name
, pw
->pw_name
, sizeof(fup
->fu_name
));
while ((fs
= getfsent()) != NULL
) {
(fs
->fs_type
== 0 || strcmp(fs
->fs_type
, "rq") != 0))
!(oneof(fs
->fs_file
, argv
, argc
) ||
oneof(fs
->fs_spec
, argv
, argc
)))
(void) sprintf(quotafile
, "%s/%s", fs
->fs_file
, qfname
);
errs
+= repquota(fs
->fs_spec
, fs
->fs_file
, quotafile
);
for (i
= 0; i
< argc
; i
++)
if ((done
& (1 << i
)) == 0)
fprintf(stderr
, "%s not found in /etc/fstab\n",
repquota(fsdev
, fsfile
, qffile
)
register struct fileusage
*fup
;
fprintf(stdout
, "*** Quota report for %s (%s)\n", fsdev
, fsfile
);
if (fstat(fileno(qf
), &statb
) < 0) {
if (quota(Q_SYNC
, 0, statb
.st_dev
, 0) < 0 &&
errno
== EINVAL
&& !warned
&& vflag
) {
"*** Warning: Quotas are not compiled into this kernel\n");
fread(&dqbuf
, sizeof(struct dqblk
), 1, qf
);
if ((fup
== 0 || fup
->fu_name
[0] == 0) &&
dqbuf
.dqb_curinodes
== 0 && dqbuf
.dqb_curblocks
== 0)
printf(" Block limits File limits\n");
printf("User used soft hard warn used soft hard warn\n");
for (uid
= 0; uid
<= highuid
; uid
++) {
if (fup
->fu_dqblk
.dqb_curinodes
== 0 &&
fup
->fu_dqblk
.dqb_curblocks
== 0)
if (fup
->fu_name
[0] != '\0')
printf("%-10s", fup
->fu_name
);
printf("%c%c%8d%8d%8d %5d %5d %5d %5d %5d\n",
fup
->fu_dqblk
.dqb_bsoftlimit
&&
fup
->fu_dqblk
.dqb_curblocks
>=
fup
->fu_dqblk
.dqb_bsoftlimit
? '+' : '-',
fup
->fu_dqblk
.dqb_isoftlimit
&&
fup
->fu_dqblk
.dqb_curinodes
>=
fup
->fu_dqblk
.dqb_isoftlimit
? '+' : '-',
dbtob(fup
->fu_dqblk
.dqb_curblocks
) / 1024,
dbtob(fup
->fu_dqblk
.dqb_bsoftlimit
) / 1024,
dbtob(fup
->fu_dqblk
.dqb_bhardlimit
) / 1024,
fup
->fu_dqblk
.dqb_curinodes
,
fup
->fu_dqblk
.dqb_isoftlimit
,
fup
->fu_dqblk
.dqb_ihardlimit
,
fup
->fu_dqblk
.dqb_iwarn
);
fup
->fu_dqblk
= zerodqblk
;
if (strcmp(target
, list
[i
]) == 0) {
register struct fileusage
*fup
;
for (fup
= fuhead
[uid
% FUHASH
]; fup
!= 0; fup
= fup
->fu_next
)
return ((struct fileusage
*)0);
struct fileusage
*fup
, **fhp
;
fup
= (struct fileusage
*)calloc(1, sizeof(struct fileusage
));
fprintf(stderr
, "out of memory for fileusage structures\n");
fhp
= &fuhead
[uid
% FUHASH
];