4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / sbin / dumplfs / misc.c
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
*/
#ifndef lint
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "extern.h"
void
get(fd, off, p, len)
int fd;
off_t off;
void *p;
size_t len;
{
int rbytes;
if (lseek(fd, off, SEEK_SET) < 0)
err("%s: %s", special, strerror(errno));
if ((rbytes = read(fd, p, len)) < 0)
err("%s: %s", special, strerror(errno));
if (rbytes != len)
err("%s: short read (%d, not %d)", special, rbytes, len);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
err(const char *fmt, ...)
#else
err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "dumplfs: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
exit(1);
/* NOTREACHED */
}