4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / sbin / dumplfs / misc.c
CommitLineData
98afd458 1/*-
4c008f37
KB
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
98afd458
KB
4 *
5 * %sccs.include.redist.c%
6 */
7
8#ifndef lint
4c008f37 9static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) %G%";
98afd458
KB
10#endif /* not lint */
11
12#include <sys/types.h>
13#include <unistd.h>
14#include <errno.h>
15#include <stdlib.h>
16#include <stdio.h>
17#include <string.h>
18#include "extern.h"
19
20void
21get(fd, off, p, len)
22 int fd;
23 off_t off;
24 void *p;
25 size_t len;
26{
27 int rbytes;
28
29 if (lseek(fd, off, SEEK_SET) < 0)
30 err("%s: %s", special, strerror(errno));
31 if ((rbytes = read(fd, p, len)) < 0)
32 err("%s: %s", special, strerror(errno));
33 if (rbytes != len)
34 err("%s: short read (%d, not %d)", special, rbytes, len);
35}
36
37#if __STDC__
38#include <stdarg.h>
39#else
40#include <varargs.h>
41#endif
42
43void
44#if __STDC__
45err(const char *fmt, ...)
46#else
47err(fmt, va_alist)
48 char *fmt;
49 va_dcl
50#endif
51{
52 va_list ap;
53#if __STDC__
54 va_start(ap, fmt);
55#else
56 va_start(ap);
57#endif
58 (void)fprintf(stderr, "dumplfs: ");
59 (void)vfprintf(stderr, fmt, ap);
60 va_end(ap);
61 (void)fprintf(stderr, "\n");
62 exit(1);
63 /* NOTREACHED */
64}