quotacheck.c revision d1a180b0452ce86577a43be3245d2eacdeec1a34
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Fix up / report on disc quotas & usage
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <pwd.h>
#include <iso/limits_iso.h>
union {
} un;
#define ITABSZ 256
struct fileusage {
};
#define FUHASH 997
int fi;
extern int optind;
extern char *optarg;
extern int fsync(int);
static void acct();
static void bread();
static void usage();
static int chkquota();
static int quotactl();
static int preen();
static int waiter();
static int oneof();
int vflag; /* verbose */
int aflag; /* all file systems */
int pflag; /* fsck like parallel check */
int fflag; /* force flag */
#define QFNAME "quotas"
#define CHUNK 50
char **listbuf;
struct fileusage zerofileusage;
int
{
char **listp;
int listcnt;
int listmax = 0;
char quotafile[MAXPATHLEN];
int errs = 0;
int opt;
}
switch (opt) {
case 'v':
vflag++;
break;
case 'a':
aflag++;
break;
case 'p':
pflag++;
break;
case 'V': /* Print command line */
{
char *opt_text;
int opt_count;
opt_count++) {
if (opt_text)
opt_text);
}
}
break;
case 'f':
fflag++;
break;
case '?':
usage();
}
}
usage();
}
printf("Warning: Quotas are not compiled into this kernel\n");
sync();
if (aflag) {
/*
* Go through vfstab and make a list of appropriate
* filesystems.
*/
listcnt = 0;
}
(vfsbuf.vfs_mntopts == 0) ||
continue;
listp++;
listcnt++;
/* grow listbuf if needed */
sizeof (char *) * listmax);
"Can't grow listbuf.\n");
}
}
}
*listp = (char *)0;
} else {
}
if (pflag) {
} else {
}
errs +=
}
}
}
while (listcnt--) {
if (*listp) {
errs++;
}
listp++;
}
if (errs > 0)
errs += 31;
return (errs);
}
struct active {
char *rdev;
};
int
{
extern char *getfullrawname(), *getfullblkname();
char quotafile[MAXPATHLEN];
char name[MAXPATHLEN];
}
errs = 0;
serially = 0;
serially = 1;
} else if (preen_addev(rdev) != 0) {
serially = 1;
}
if (serially) {
*lp = (char *)0;
}
}
}
nactive = 0;
switch (rc) {
case 1:
name);
if (bdev)
continue;
}
continue;
continue;
}
}
}
case -1:
perror("fork");
break;
case 0:
break;
default:
nactive++;
break;
}
break;
case 2:
nactive--;
break;
}
}
while (nactive > 0) {
nactive--;
}
return (errs);
}
int
{
int status;
if (curpid == -1) {
return (0);
perror("wait");
}
break;
}
} else if (lap) {
} else {
}
}
int
{
int cg, i;
char *rawdisk;
extern char *getfullrawname();
return (1);
}
if (*rawdisk == '\0') {
fsdev);
return (1);
}
if (vflag)
if (fi < 0) {
return (1);
}
return (1);
}
return (1);
}
return (1);
}
return (1);
}
/*
* Flush filesystem since we are going to read
* disk raw and we want to make sure everything is
* synced to disk before we read it.
*/
qffile);
return (1);
}
/*
* no need to quotacheck a rw, mounted, and logging file system
*/
return (0);
}
ino = 0;
}
break;
if (fup == 0)
fup = &zerofileusage;
fup->fu_curfiles = 0;
fup->fu_curblocks = 0;
}
fup->fu_curfiles = 0;
fup->fu_curblocks = 0;
continue;
}
/*
* The maximum number of blocks that can be stored in the
* dqb_curblocks field in the quota record is 2^32 - 1,
* since it must fit into an unsigned 32-bit quantity.
* If this user has more blocks than that, print a message
* to that effect and reduce the count of allocated blocks
* to the maximum value, which is UINT_MAX.
*/
printf("512-byte blocks allocated to user ");
else
"This exceeds the maximum number of blocks recordable in a quota record.\n");
"The value will be set to the maximum, which is %lu.\n", UINT_MAX);
}
if (vflag) {
else
printf(" files %lu -> %lu",
printf(" blocks %lu -> %llu",
printf("\n");
}
/*
* If quotas are not enabled for the current filesystem
* then just update the quotas file directly.
*/
/* back up, overwrite the entry we just read */
}
fup->fu_curfiles = 0;
fup->fu_curblocks = 0;
}
return (0);
}
void
{
return;
}
return;
fup->fu_curfiles++;
return;
}
int
{
int n = on;
while (n--) {
*listp = (char *)0;
return (1);
}
listp++;
}
return (0);
}
struct dinode *
ginode()
{
}
if (ino++ < UFSROOTINO)
return (NULL);
return (dp);
}
void
{
perror("lseek");
}
perror("read");
}
}
struct fileusage *
{
return (fup);
return ((struct fileusage *)0);
}
struct fileusage *
{
if (fup != 0)
return (fup);
if (fup == 0) {
}
return (fup);
}
void
usage()
{
}
int
{
int fd;
int status;
char qfile[MAXPATHLEN];
/*
* Find the mount point of any ufs file system. This is
* because the ioctl that implements the quotactl call has
* to go to a real file, and not to the block device.
*/
perror("open");
}
fd = -1;
continue;
sizeof (qfile))) {
continue;
}
break;
}
if (fd == -1) {
return (-1);
}
} else {
return (-1);
}
sizeof (qfile)) ||
sizeof (qfile))) {
return (-1);
}
perror("open");
}
} /* else */
if (fd != 0)
return (status);
}
char *
{
char *f, *opts;
static char *tmpopts;
if (tmpopts == 0) {
if (tmpopts == 0)
return (0);
}
}
return (NULL);
}