Use err(3). Silent -Wall.
This commit is contained in:
parent
510a2b6c88
commit
ad303c08c1
@ -15,37 +15,40 @@
|
||||
.Op Fl y Ar ysize
|
||||
.Op Fl z Ar zoom
|
||||
.Sh DESCRIPTION
|
||||
.Nm qcamcontrol
|
||||
.Nm Qcamcontrol
|
||||
is a program to demonstrate control over the Connectix QuickCam(TM)
|
||||
parallel port camera and to take a single frame picture.
|
||||
.Pp
|
||||
If the device not specified, "/dev/qcam0" is assumed.
|
||||
If the device not specified,
|
||||
.Pa /dev/qcam0
|
||||
is assumed.
|
||||
If no command is given, then
|
||||
.Nm qcamcontrol
|
||||
.Nm
|
||||
will use its defaults to grab a single frame from the camera. The control
|
||||
program will output a portable pixmap (ppm) file to stdout.
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width "flag whitebalance"
|
||||
.Bl -tag -width indent
|
||||
.It Fl b Ar brightness
|
||||
control the brightness of the picture (0..255)
|
||||
Control the brightness of the picture (0..255).
|
||||
.It Fl c Ar contrast
|
||||
control the contrast of the picture (0..255)
|
||||
Control the contrast of the picture (0..255).
|
||||
.It Fl d Ar depth
|
||||
16 or 64 shades of gray (specified as 4 or 6 bits per pixel)
|
||||
16 or 64 shades of gray (specified as 4 or 6 bits per pixel).
|
||||
.It Fl p Ar device
|
||||
quickcam device (port) (default is /dev/qcam0)
|
||||
Quickcam device (port) (default is
|
||||
.Pa /dev/qcam0 )
|
||||
.It Fl w Ar whitebalance
|
||||
amount of white in the picture (0..255)
|
||||
Amount of white in the picture (0..255).
|
||||
.It Fl x Ar xsize
|
||||
width of image (320 or less)
|
||||
Width of image (320 or less).
|
||||
.It Fl y Ar ysize
|
||||
height of image (240 or less)
|
||||
Height of image (240 or less).
|
||||
.It Fl z Ar zoom
|
||||
zoom in (1, 1.5x, or 2x)
|
||||
Zoom in (1x, 1.5x, or 2x).
|
||||
.El
|
||||
.Sh BUGS
|
||||
.Nm qcamcontrol
|
||||
.Nm Qcamcontrol
|
||||
does not enforce a proper aspect ratio for x y sizes.
|
||||
In practice, standard picture sizes are 320x240 and 180x160 and all smaller
|
||||
sizes that maintain a similar aspect ratio.
|
||||
@ -57,9 +60,9 @@ will return all-black or all-white pictures.
|
||||
.It Pa /dev/qcam0
|
||||
.El
|
||||
.Sh AUTHOR
|
||||
Paul Traina
|
||||
.An Paul Traina
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm qcamcontrol
|
||||
.Nm
|
||||
command appeared in
|
||||
.Fx 2.1.5 .
|
||||
|
@ -30,6 +30,12 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -56,6 +62,7 @@ void print_data(struct qcam *data)
|
||||
data->qc_contrast);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: qcamcontrol [-p port] [-x xsize] [-y ysize] "
|
||||
@ -65,6 +72,7 @@ usage(void)
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct qcam info;
|
||||
@ -92,68 +100,50 @@ main(int argc, char **argv)
|
||||
|
||||
case 'x':
|
||||
x_size = atoi(optarg);
|
||||
if (x_size > QC_MAX_XSIZE) {
|
||||
fprintf(stderr, "x size too large (max %d)\n",
|
||||
QC_MAX_XSIZE);
|
||||
exit(2);
|
||||
}
|
||||
if (x_size > QC_MAX_XSIZE)
|
||||
errx(2, "x size too large (max %d)", QC_MAX_XSIZE);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
y_size = atoi(optarg);
|
||||
if (y_size > QC_MAX_YSIZE) {
|
||||
fprintf(stderr, "x size too large (max %d)\n",
|
||||
QC_MAX_YSIZE);
|
||||
exit(2);
|
||||
}
|
||||
if (y_size > QC_MAX_YSIZE)
|
||||
errx(2, "x size too large (max %d)", QC_MAX_YSIZE);
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
zoom = atoi(optarg);
|
||||
if (zoom > QC_ZOOM_200) {
|
||||
fprintf(stderr, "zoom too large (max %d)\n", QC_ZOOM_200);
|
||||
exit(2);
|
||||
}
|
||||
if (zoom > QC_ZOOM_200)
|
||||
errx(2, "zoom too large (max %d)", QC_ZOOM_200);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
depth = atoi(optarg);
|
||||
if (depth != 4 && depth != 6) {
|
||||
fprintf(stderr, "invalid depth (4 or 6)\n");
|
||||
exit(2);
|
||||
}
|
||||
if (depth != 4 && depth != 6)
|
||||
errx(2, "invalid depth (4 or 6)");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
brightness = atoi(optarg);
|
||||
if (brightness > 255) {
|
||||
fprintf(stderr, "bad brightness (max 255)\n");
|
||||
exit(2);
|
||||
}
|
||||
if (brightness > 255)
|
||||
errx(2, "bad brightness (max 255)");
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
whitebalance = atoi(optarg);
|
||||
if (whitebalance > 255) {
|
||||
fprintf(stderr, "bad white balance (max 255)\n");
|
||||
exit(2);
|
||||
}
|
||||
if (whitebalance > 255)
|
||||
errx(2, "bad white balance (max 255)");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
contrast = atoi(optarg);
|
||||
if (contrast > 255) {
|
||||
fprintf(stderr, "bad contrast (max 255)\n");
|
||||
exit(2);
|
||||
}
|
||||
if (contrast > 255)
|
||||
errx(2, "bad contrast (max 255)");
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
exposure = atoi(optarg);
|
||||
if (exposure < 100) {
|
||||
fprintf(stderr, "bad exposure (min 100)\n");
|
||||
exit(2);
|
||||
}
|
||||
if (exposure < 100)
|
||||
errx(2, "bad exposure (min 100)");
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -164,17 +154,13 @@ main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
/* open device */
|
||||
if ((fd = open(port, O_RDONLY)) < 0) {
|
||||
perror("open");
|
||||
exit(1);
|
||||
}
|
||||
if ((fd = open(port, O_RDONLY)) < 0)
|
||||
err(1, "open");
|
||||
|
||||
|
||||
|
||||
if (ioctl(fd, QC_GET, &info) < 0) { /* read in default info */
|
||||
perror("ioctl(QC_GET)");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, QC_GET, &info) < 0) /* read in default info */
|
||||
err(1, "ioctl(QC_GET)");
|
||||
|
||||
if (x_size > -1)
|
||||
info.qc_xsize = x_size;
|
||||
@ -199,18 +185,14 @@ main(int argc, char **argv)
|
||||
*/
|
||||
info.qc_version = QC_IOCTL_VERSION;
|
||||
|
||||
if (ioctl(fd, QC_SET, &info) < 0) {
|
||||
perror("ioctl(QC_SET)");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, QC_SET, &info) < 0)
|
||||
err(1, "ioctl(QC_SET)");
|
||||
|
||||
/*
|
||||
* Tell us what the kernel thinks we're asking for
|
||||
*/
|
||||
if (ioctl(fd, QC_GET, &info) < 0) {
|
||||
perror("ioctl(QC_SET)");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, QC_GET, &info) < 0)
|
||||
err(1, "ioctl(QC_SET)");
|
||||
|
||||
print_data(&info);
|
||||
|
||||
@ -221,10 +203,8 @@ main(int argc, char **argv)
|
||||
len = info.qc_xsize * info.qc_ysize;
|
||||
while (len) {
|
||||
bytes = read(fd, buffer, len);
|
||||
if (bytes < 0) {
|
||||
perror("read");
|
||||
exit(1);
|
||||
}
|
||||
if (bytes < 0)
|
||||
err(1, "read");
|
||||
len -= bytes;
|
||||
|
||||
if (bytes == 0)
|
||||
@ -238,8 +218,7 @@ main(int argc, char **argv)
|
||||
info.qc_xsize, info.qc_ysize, (1<<info.qc_bpp) - 1);
|
||||
fflush(stdout);
|
||||
|
||||
if (write(1, buffer, info.qc_xsize * info.qc_ysize) < 0) {
|
||||
perror("write");
|
||||
exit(1);
|
||||
}
|
||||
if (write(1, buffer, info.qc_xsize * info.qc_ysize) < 0)
|
||||
err(1, "write");
|
||||
return(0);
|
||||
}
|
||||
|
@ -6,11 +6,13 @@
|
||||
* Paul Traina, Feburary 1996
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <nlist.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <nlist.h>
|
||||
|
||||
#include <machine/qcam.h>
|
||||
|
||||
@ -32,21 +34,15 @@ getaddrs(void)
|
||||
int i;
|
||||
|
||||
if (kmem < 0) {
|
||||
if ((kmem = open(_PATH_KMEM, 0, 0)) < 0) {
|
||||
perror("open kmem");
|
||||
exit(1);
|
||||
}
|
||||
if ((kmem = open(_PATH_KMEM, 0, 0)) < 0)
|
||||
err(1, "open kmem");
|
||||
(void) fcntl(kmem, F_SETFD, 1);
|
||||
|
||||
for (i = 0; i < MAX_SYMBOLS; i++) {
|
||||
if (nlist("/kernel", &names[i]) < 0) {
|
||||
perror("nlist");
|
||||
exit(1);
|
||||
}
|
||||
if (names[i].n_value == 0) {
|
||||
fprintf(stderr, "couldn't find names[%d]\n", i);
|
||||
exit(1);
|
||||
}
|
||||
if (nlist("/kernel", &names[i]) < 0)
|
||||
err(1, "nlist");
|
||||
if (names[i].n_value == 0)
|
||||
errx(1, "couldn't find names[%d]", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,22 +50,14 @@ getaddrs(void)
|
||||
void
|
||||
getdata(void)
|
||||
{
|
||||
if (lseek(kmem, (off_t) names[0].n_value, SEEK_SET) < 0) {
|
||||
perror("lseek high");
|
||||
exit(1);
|
||||
}
|
||||
if (read(kmem, (u_short *) high_times, sizeof(high_times)) < 0) {
|
||||
perror("read high");
|
||||
exit(1);
|
||||
}
|
||||
if (lseek(kmem, (off_t) names[1].n_value, SEEK_SET) < 0) {
|
||||
perror("lseek low");
|
||||
exit(1);
|
||||
}
|
||||
if (read(kmem, (u_short *) low_times, sizeof(low_times)) < 0) {
|
||||
perror("read low");
|
||||
exit(1);
|
||||
}
|
||||
if (lseek(kmem, (off_t) names[0].n_value, SEEK_SET) < 0)
|
||||
err(1, "lseek high");
|
||||
if (read(kmem, (u_short *) high_times, sizeof(high_times)) < 0)
|
||||
err(1, "read high");
|
||||
if (lseek(kmem, (off_t) names[1].n_value, SEEK_SET) < 0)
|
||||
err(1, "lseek low");
|
||||
if (read(kmem, (u_short *) low_times, sizeof(low_times)) < 0)
|
||||
err(1, "read low");
|
||||
}
|
||||
|
||||
|
||||
@ -99,13 +87,15 @@ printdata(u_short * p, int length)
|
||||
} else
|
||||
i += 16;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
getaddrs();
|
||||
getdata();
|
||||
printdata(high_times, FBUFSIZE);
|
||||
printdata(low_times, FBUFSIZE);
|
||||
return(0);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: quot.8,v 1.6 1997/02/22 16:12:38 peter Exp $
|
||||
.\" $Id: quot.8,v 1.7 1997/09/18 06:54:36 charnier Exp $
|
||||
.\"
|
||||
.Dd February 8, 1994
|
||||
.Dt QUOT 8
|
||||
@ -44,7 +44,7 @@
|
||||
is used to gather statistics about the disk usage for each local user.
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width Ds
|
||||
.Bl -tag -width indent
|
||||
.It Fl a
|
||||
Include statistics for all mounted filesystems.
|
||||
.It Fl c
|
||||
@ -97,5 +97,7 @@ ncheck does not exist in FreeBSD.. :-)
|
||||
.Xr mount 8
|
||||
.Sh HISTORY
|
||||
This implementation of
|
||||
.Nm quot
|
||||
is by Wolfgang Solfrank / TooLs GmbH.
|
||||
.Nm
|
||||
is by
|
||||
.An Wolfgang Solfrank
|
||||
/ TooLs GmbH.
|
||||
|
@ -30,7 +30,8 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: quot.c,v 1.5 1997/02/22 16:12:39 peter Exp $";
|
||||
static const char rcsid[] =
|
||||
"$Id: quot.c,v 1.6 1997/08/13 12:09:48 jkh Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,17 +41,20 @@ static char rcsid[] = "$Id: quot.c,v 1.5 1997/02/22 16:12:39 peter Exp $";
|
||||
#include <ufs/ufs/quota.h>
|
||||
#include <ufs/ufs/inode.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* some flags of what to do: */
|
||||
static char estimate;
|
||||
static char count;
|
||||
static char unused;
|
||||
static int (*func)();
|
||||
static void (*func)();
|
||||
static long blocksize;
|
||||
static char *header;
|
||||
static int headerlen;
|
||||
@ -72,7 +76,8 @@ static int headerlen;
|
||||
#define INOCNT(fs) ((fs)->fs_ipg)
|
||||
#define INOSZ(fs) (sizeof(struct dinode) * INOCNT(fs))
|
||||
|
||||
static struct dinode *get_inode(fd,super,ino)
|
||||
static struct dinode *
|
||||
get_inode(fd,super,ino)
|
||||
struct fs *super;
|
||||
ino_t ino;
|
||||
{
|
||||
@ -89,16 +94,12 @@ static struct dinode *get_inode(fd,super,ino)
|
||||
|
||||
if (!ip || ino < last || ino >= last + INOCNT(super)) {
|
||||
if (!ip
|
||||
&& !(ip = (struct dinode *)malloc(INOSZ(super)))) {
|
||||
perror("allocate inodes");
|
||||
exit(1);
|
||||
}
|
||||
&& !(ip = (struct dinode *)malloc(INOSZ(super))))
|
||||
errx(1, "allocate inodes");
|
||||
last = (ino / INOCNT(super)) * INOCNT(super);
|
||||
if (lseek(fd, (off_t)ino_to_fsba(super, last) << super->fs_fshift, 0) < (off_t)0
|
||||
|| read(fd,ip,INOSZ(super)) != INOSZ(super)) {
|
||||
perror("read inodes");
|
||||
exit(1);
|
||||
}
|
||||
|| read(fd,ip,INOSZ(super)) != INOSZ(super))
|
||||
err(1, "read inodes");
|
||||
}
|
||||
|
||||
return ip + ino % INOCNT(super);
|
||||
@ -110,7 +111,7 @@ static struct dinode *get_inode(fd,super,ino)
|
||||
#define actualblocks(super,ip) ((ip)->di_blocks)
|
||||
#endif
|
||||
|
||||
static virtualblocks(super,ip)
|
||||
static int virtualblocks(super,ip)
|
||||
struct fs *super;
|
||||
struct dinode *ip;
|
||||
{
|
||||
@ -144,7 +145,8 @@ static virtualblocks(super,ip)
|
||||
#endif /* COMPAT */
|
||||
}
|
||||
|
||||
static isfree(ip)
|
||||
static int
|
||||
isfree(ip)
|
||||
struct dinode *ip;
|
||||
{
|
||||
#ifdef COMPAT
|
||||
@ -174,7 +176,8 @@ static struct user {
|
||||
} *users;
|
||||
static int nusers;
|
||||
|
||||
static inituser()
|
||||
static void
|
||||
inituser()
|
||||
{
|
||||
register i;
|
||||
register struct user *usr;
|
||||
@ -182,10 +185,8 @@ static inituser()
|
||||
if (!nusers) {
|
||||
nusers = 8;
|
||||
if (!(users =
|
||||
(struct user *)calloc(nusers,sizeof(struct user)))) {
|
||||
perror("allocate users");
|
||||
exit(1);
|
||||
}
|
||||
(struct user *)calloc(nusers,sizeof(struct user))))
|
||||
errx(1, "allocate users");
|
||||
} else {
|
||||
for (usr = users, i = nusers; --i >= 0; usr++) {
|
||||
usr->space = usr->spc30 = usr->spc60 = usr->spc90 = 0;
|
||||
@ -194,7 +195,8 @@ static inituser()
|
||||
}
|
||||
}
|
||||
|
||||
static usrrehash()
|
||||
static void
|
||||
usrrehash()
|
||||
{
|
||||
register i;
|
||||
register struct user *usr, *usrn;
|
||||
@ -202,10 +204,8 @@ static usrrehash()
|
||||
|
||||
svusr = users;
|
||||
nusers <<= 1;
|
||||
if (!(users = (struct user *)calloc(nusers,sizeof(struct user)))) {
|
||||
perror("allocate users");
|
||||
exit(1);
|
||||
}
|
||||
if (!(users = (struct user *)calloc(nusers,sizeof(struct user))))
|
||||
errx(1, "allocate users");
|
||||
for (usr = svusr, i = nusers >> 1; --i >= 0; usr++) {
|
||||
for (usrn = users + (usr->uid&(nusers - 1)); usrn->name;
|
||||
usrn--) {
|
||||
@ -216,7 +216,8 @@ static usrrehash()
|
||||
}
|
||||
}
|
||||
|
||||
static struct user *user(uid)
|
||||
static struct user *
|
||||
user(uid)
|
||||
uid_t uid;
|
||||
{
|
||||
register struct user *usr;
|
||||
@ -230,17 +231,15 @@ static struct user *user(uid)
|
||||
usr->uid = uid;
|
||||
|
||||
if (!(pwd = getpwuid(uid))) {
|
||||
if (usr->name = (char *)malloc(7))
|
||||
if ((usr->name = (char *)malloc(7)))
|
||||
sprintf(usr->name,"#%d",uid);
|
||||
} else {
|
||||
if (usr->name = (char *)
|
||||
malloc(strlen(pwd->pw_name) + 1))
|
||||
if ((usr->name = (char *)
|
||||
malloc(strlen(pwd->pw_name) + 1)))
|
||||
strcpy(usr->name,pwd->pw_name);
|
||||
}
|
||||
if (!usr->name) {
|
||||
perror("allocate users");
|
||||
exit(1);
|
||||
}
|
||||
if (!usr->name)
|
||||
errx(1, "allocate users");
|
||||
|
||||
return usr;
|
||||
|
||||
@ -254,7 +253,8 @@ static struct user *user(uid)
|
||||
}
|
||||
}
|
||||
|
||||
static cmpusers(u1,u2)
|
||||
static int
|
||||
cmpusers(u1,u2)
|
||||
struct user *u1, *u2;
|
||||
{
|
||||
return u2->space - u1->space;
|
||||
@ -263,7 +263,8 @@ static cmpusers(u1,u2)
|
||||
#define sortusers(users) (qsort((users),nusers,sizeof(struct user), \
|
||||
cmpusers))
|
||||
|
||||
static uses(uid,blks,act)
|
||||
static void
|
||||
uses(uid,blks,act)
|
||||
uid_t uid;
|
||||
daddr_t blks;
|
||||
time_t act;
|
||||
@ -298,7 +299,8 @@ struct fsizes {
|
||||
daddr_t fsz_sz[FSZCNT];
|
||||
} *fsizes;
|
||||
|
||||
static initfsizes()
|
||||
static void
|
||||
initfsizes()
|
||||
{
|
||||
register struct fsizes *fp;
|
||||
register i;
|
||||
@ -311,7 +313,8 @@ static initfsizes()
|
||||
}
|
||||
}
|
||||
|
||||
static dofsizes(fd,super,name)
|
||||
static void
|
||||
dofsizes(fd,super,name)
|
||||
struct fs *super;
|
||||
char *name;
|
||||
{
|
||||
@ -323,10 +326,8 @@ static dofsizes(fd,super,name)
|
||||
|
||||
maxino = super->fs_ncg * super->fs_ipg - 1;
|
||||
#ifdef COMPAT
|
||||
if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes)))) {
|
||||
perror("alloc fsize structure");
|
||||
exit(1);
|
||||
}
|
||||
if (!(fsizes = (struct fsizes *)malloc(sizeof(struct fsizes))))
|
||||
errx(1, "alloc fsize structure");
|
||||
#endif /* COMPAT */
|
||||
for (inode = 0; inode < maxino; inode++) {
|
||||
errno = 0;
|
||||
@ -350,16 +351,14 @@ static dofsizes(fd,super,name)
|
||||
}
|
||||
#else /* COMPAT */
|
||||
ksz = SIZE(sz);
|
||||
for (fsp = &fsizes; fp = *fsp; fsp = &fp->fsz_next) {
|
||||
for (fsp = &fsizes; (fp = *fsp); fsp = &fp->fsz_next) {
|
||||
if (ksz < fp->fsz_last)
|
||||
break;
|
||||
}
|
||||
if (!fp || ksz < fp->fsz_first) {
|
||||
if (!(fp = (struct fsizes *)
|
||||
malloc(sizeof(struct fsizes)))) {
|
||||
perror("alloc fsize structure");
|
||||
exit(1);
|
||||
}
|
||||
malloc(sizeof(struct fsizes))))
|
||||
errx(1, "alloc fsize structure");
|
||||
fp->fsz_next = *fsp;
|
||||
*fsp = fp;
|
||||
fp->fsz_first = (ksz / FSZCNT) * FSZCNT;
|
||||
@ -373,8 +372,7 @@ static dofsizes(fd,super,name)
|
||||
fp->fsz_sz[ksz % FSZCNT] += sz;
|
||||
#endif /* COMPAT */
|
||||
} else if (errno) {
|
||||
perror(name);
|
||||
exit(1);
|
||||
err(1, "%s", name);
|
||||
}
|
||||
}
|
||||
sz = 0;
|
||||
@ -388,7 +386,8 @@ static dofsizes(fd,super,name)
|
||||
}
|
||||
}
|
||||
|
||||
static douser(fd,super,name)
|
||||
static void
|
||||
douser(fd,super,name)
|
||||
struct fs *super;
|
||||
char *name;
|
||||
{
|
||||
@ -407,14 +406,11 @@ static douser(fd,super,name)
|
||||
actualblocks(super,ip),
|
||||
ip->di_atime);
|
||||
else if (errno) {
|
||||
perror(name);
|
||||
exit(1);
|
||||
err(1, "%s", name);
|
||||
}
|
||||
}
|
||||
if (!(usrs = (struct user *)malloc(nusers * sizeof(struct user)))) {
|
||||
perror("allocate users");
|
||||
exit(1);
|
||||
}
|
||||
if (!(usrs = (struct user *)malloc(nusers * sizeof(struct user))))
|
||||
errx(1, "allocate users");
|
||||
bcopy(users,usrs,nusers * sizeof(struct user));
|
||||
sortusers(usrs);
|
||||
for (usr = usrs, n = nusers; --n >= 0 && usr->count; usr++) {
|
||||
@ -432,7 +428,8 @@ static douser(fd,super,name)
|
||||
free(usrs);
|
||||
}
|
||||
|
||||
static donames(fd,super,name)
|
||||
static void
|
||||
donames(fd,super,name)
|
||||
struct fs *super;
|
||||
char *name;
|
||||
{
|
||||
@ -449,7 +446,7 @@ static donames(fd,super,name)
|
||||
inode1 = -1;
|
||||
while (scanf("%d",&inode) == 1) {
|
||||
if (inode < 0 || inode > maxino) {
|
||||
fprintf(stderr,"illegal inode %d\n",inode);
|
||||
warnx("illegal inode %d",inode);
|
||||
return;
|
||||
}
|
||||
errno = 0;
|
||||
@ -467,8 +464,7 @@ static donames(fd,super,name)
|
||||
inode1 = inode;
|
||||
} else {
|
||||
if (errno) {
|
||||
perror(name);
|
||||
exit(1);
|
||||
err(1, "%s", name);
|
||||
}
|
||||
/* skip this line */
|
||||
while ((c = getchar()) != EOF && c != '\n');
|
||||
@ -478,18 +474,20 @@ static donames(fd,super,name)
|
||||
}
|
||||
}
|
||||
|
||||
static usage()
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
#ifdef COMPAT
|
||||
fprintf(stderr,"Usage: quot [-nfcvha] [filesystem ...]\n");
|
||||
fprintf(stderr,"usage: quot [-nfcvha] [filesystem ...]\n");
|
||||
#else /* COMPAT */
|
||||
fprintf(stderr,"Usage: quot [ -acfhknv ] [ filesystem ... ]\n");
|
||||
fprintf(stderr,"usage: quot [-acfhknv] [ filesystem ... ]\n");
|
||||
#endif /* COMPAT */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static char superblock[SBSIZE];
|
||||
|
||||
void
|
||||
quot(name,mp)
|
||||
char *name, *mp;
|
||||
{
|
||||
@ -501,12 +499,12 @@ quot(name,mp)
|
||||
if ((fd = open(name,0)) < 0
|
||||
|| lseek(fd,SBOFF,0) != SBOFF
|
||||
|| read(fd,superblock,SBSIZE) != SBSIZE) {
|
||||
perror(name);
|
||||
warn("%s", name);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
if (((struct fs *)superblock)->fs_magic != FS_MAGIC) {
|
||||
fprintf(stderr,"%s: not a BSD filesystem\n",name);
|
||||
warnx("%s: not a BSD filesystem",name);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
@ -518,14 +516,13 @@ quot(name,mp)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int main(argc,argv)
|
||||
int
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
int fd;
|
||||
char all = 0;
|
||||
FILE *fp;
|
||||
struct statfs *mp;
|
||||
struct vfsconf vfc, *vfsp;
|
||||
struct vfsconf *vfsp;
|
||||
char dev[MNAMELEN + 1];
|
||||
char *nm;
|
||||
int cnt;
|
||||
@ -568,13 +565,11 @@ int main(argc,argv)
|
||||
if (all) {
|
||||
cnt = getmntinfo(&mp,MNT_NOWAIT);
|
||||
vfsp = getvfsbyname("ufs");
|
||||
if (vfsp == NULL) {
|
||||
fprintf(stderr, "cannot find ufs/ffs filesystem type!\n");
|
||||
exit(1);
|
||||
}
|
||||
if (vfsp == NULL)
|
||||
errx(1, "cannot find ufs/ffs filesystem type!");
|
||||
for (; --cnt >= 0; mp++) {
|
||||
if (mp->f_type == vfsp->vfc_index) {
|
||||
if (nm = strrchr(mp->f_mntfromname,'/')) {
|
||||
if ((nm = strrchr(mp->f_mntfromname,'/'))) {
|
||||
sprintf(dev,"/dev/r%s",nm + 1);
|
||||
nm = dev;
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user