Update.
[glibc.git] / db2 / os / os_seek.c
blob159425cc2728caf0ddea09e51aee611cfb807cd4
1 /*-
2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997, 1998
5 * Sleepycat Software. All rights reserved.
6 */
8 #include "config.h"
10 #ifndef lint
11 static const char sccsid[] = "@(#)os_seek.c 10.9 (Sleepycat) 4/19/98";
12 #endif /* not lint */
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
17 #include <errno.h>
18 #include <unistd.h>
19 #endif
21 #include "db_int.h"
24 * __os_seek --
25 * Seek to a page/byte offset in the file.
27 * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int));
29 int
30 __os_seek(fd, pgsize, pageno, relative, isrewind, whence)
31 int fd;
32 size_t pgsize;
33 db_pgno_t pageno;
34 u_int32_t relative;
35 int isrewind, whence;
37 off_t offset;
39 offset = (off_t)pgsize * pageno + relative;
40 if (isrewind)
41 offset = -offset;
43 return (lseek(fd, offset, whence) == -1 ? errno : 0);