1 /*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 06/05/93"; 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 20 void 21 get(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 43 void 44 #if __STDC__ 45 err(const char *fmt, ...) 46 #else 47 err(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 } 65