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