1*326b2259Sagc /* $NetBSD: misc.c,v 1.7 2003/08/07 11:25:20 agc Exp $ */
20114e805Scgd
3ccfa3742Smycroft /*-
4ccfa3742Smycroft * Copyright (c) 1991, 1993
5ccfa3742Smycroft * The Regents of the University of California. All rights reserved.
6ccfa3742Smycroft *
7ccfa3742Smycroft * Redistribution and use in source and binary forms, with or without
8ccfa3742Smycroft * modification, are permitted provided that the following conditions
9ccfa3742Smycroft * are met:
10ccfa3742Smycroft * 1. Redistributions of source code must retain the above copyright
11ccfa3742Smycroft * notice, this list of conditions and the following disclaimer.
12ccfa3742Smycroft * 2. Redistributions in binary form must reproduce the above copyright
13ccfa3742Smycroft * notice, this list of conditions and the following disclaimer in the
14ccfa3742Smycroft * documentation and/or other materials provided with the distribution.
15*326b2259Sagc * 3. Neither the name of the University nor the names of its contributors
16ccfa3742Smycroft * may be used to endorse or promote products derived from this software
17ccfa3742Smycroft * without specific prior written permission.
18ccfa3742Smycroft *
19ccfa3742Smycroft * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20ccfa3742Smycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21ccfa3742Smycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22ccfa3742Smycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23ccfa3742Smycroft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24ccfa3742Smycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25ccfa3742Smycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26ccfa3742Smycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27ccfa3742Smycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28ccfa3742Smycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29ccfa3742Smycroft * SUCH DAMAGE.
30ccfa3742Smycroft */
31ccfa3742Smycroft
32e5bc90f4Sfvdl #include <sys/cdefs.h>
33e5bc90f4Sfvdl
34ccfa3742Smycroft #ifndef lint
350114e805Scgd #if 0
36e5bc90f4Sfvdl static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95";
370114e805Scgd #else
38*326b2259Sagc __RCSID("$NetBSD: misc.c,v 1.7 2003/08/07 11:25:20 agc Exp $");
390114e805Scgd #endif
40ccfa3742Smycroft #endif /* not lint */
41ccfa3742Smycroft
42ccfa3742Smycroft #include <sys/types.h>
438ffd59e2Smycroft
448ffd59e2Smycroft #include <err.h>
45ccfa3742Smycroft #include <errno.h>
46ccfa3742Smycroft #include <stdio.h>
478ffd59e2Smycroft #include <stdlib.h>
48ccfa3742Smycroft #include <string.h>
498ffd59e2Smycroft #include <unistd.h>
50ccfa3742Smycroft #include "extern.h"
51ccfa3742Smycroft
52ccfa3742Smycroft void
get(int fd,off_t off,void * p,size_t len)534e3fced9Sperseant get(int fd, off_t off, void *p, size_t len)
54ccfa3742Smycroft {
55ccfa3742Smycroft int rbytes;
56ccfa3742Smycroft
57ccfa3742Smycroft if (lseek(fd, off, SEEK_SET) < 0)
588ffd59e2Smycroft err(1, "%s", special);
59ccfa3742Smycroft if ((rbytes = read(fd, p, len)) < 0)
608ffd59e2Smycroft err(1, "%s", special);
61ccfa3742Smycroft if (rbytes != len)
62a14f3dadSthorpej errx(1, "%s: short read (%d, not %lu)", special, rbytes,
63a14f3dadSthorpej (u_long)len);
64ccfa3742Smycroft }
65