1 |
#ifndef lint |
2 |
static const char RCSid[] = "$Id: preadwrite.c,v 3.1 2003/02/22 02:07:22 greg Exp $"; |
3 |
#endif |
4 |
/* |
5 |
* Substitute routines for pread(2) and pwrite(2) |
6 |
*/ |
7 |
|
8 |
#include "platform.h" |
9 |
|
10 |
|
11 |
int |
12 |
pread(fd, buf, siz, offs) /* read buffer from an open file */ |
13 |
int fd; |
14 |
char *buf; |
15 |
unsigned int siz; |
16 |
long offs; |
17 |
{ |
18 |
if (lseek(fd, (off_t)offs, SEEK_SET) != offs) |
19 |
return(-1); |
20 |
return(read(fd, buf, siz)); |
21 |
/* technically, we should reset pointer here */ |
22 |
} |
23 |
|
24 |
|
25 |
int |
26 |
pwrite(fd, buf, siz, offs) /* write buffer to an open file */ |
27 |
int fd; |
28 |
char *buf; |
29 |
unsigned int siz; |
30 |
long offs; |
31 |
{ |
32 |
if (lseek(fd, (off_t)offs, SEEK_SET) != offs) |
33 |
return(-1); |
34 |
return(write(fd, buf, siz)); |
35 |
/* technically, we should reset pointer here */ |
36 |
} |