151145Sbostic /*- 2*61488Sbostic * Copyright (c) 1991, 1993 3*61488Sbostic * The Regents of the University of California. All rights reserved. 451145Sbostic * 551145Sbostic * %sccs.include.redist.c% 651145Sbostic */ 751145Sbostic 851145Sbostic #ifndef lint 9*61488Sbostic static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 06/05/93"; 1051145Sbostic #endif /* not lint */ 1151145Sbostic 1251145Sbostic #include <sys/types.h> 1351145Sbostic #include <unistd.h> 1451145Sbostic #include <errno.h> 1551145Sbostic #include <stdlib.h> 1651145Sbostic #include <stdio.h> 1751145Sbostic #include <string.h> 1851145Sbostic #include "extern.h" 1951145Sbostic 2051145Sbostic void 2151145Sbostic get(fd, off, p, len) 2251145Sbostic int fd; 2351145Sbostic off_t off; 2451145Sbostic void *p; 2551145Sbostic size_t len; 2651145Sbostic { 2751145Sbostic int rbytes; 2851145Sbostic 2951145Sbostic if (lseek(fd, off, SEEK_SET) < 0) 3051145Sbostic err("%s: %s", special, strerror(errno)); 3151145Sbostic if ((rbytes = read(fd, p, len)) < 0) 3251145Sbostic err("%s: %s", special, strerror(errno)); 3351145Sbostic if (rbytes != len) 3451145Sbostic err("%s: short read (%d, not %d)", special, rbytes, len); 3551145Sbostic } 3651145Sbostic 3751145Sbostic #if __STDC__ 3851145Sbostic #include <stdarg.h> 3951145Sbostic #else 4051145Sbostic #include <varargs.h> 4151145Sbostic #endif 4251145Sbostic 4351145Sbostic void 4451145Sbostic #if __STDC__ 4551145Sbostic err(const char *fmt, ...) 4651145Sbostic #else 4751145Sbostic err(fmt, va_alist) 4851145Sbostic char *fmt; 4951145Sbostic va_dcl 5051145Sbostic #endif 5151145Sbostic { 5251145Sbostic va_list ap; 5351145Sbostic #if __STDC__ 5451145Sbostic va_start(ap, fmt); 5551145Sbostic #else 5651145Sbostic va_start(ap); 5751145Sbostic #endif 5851145Sbostic (void)fprintf(stderr, "dumplfs: "); 5951145Sbostic (void)vfprintf(stderr, fmt, ap); 6051145Sbostic va_end(ap); 6151145Sbostic (void)fprintf(stderr, "\n"); 6251145Sbostic exit(1); 6351145Sbostic /* NOTREACHED */ 6451145Sbostic } 65