1N/A/*-
1N/A * See the file LICENSE for redistribution information.
1N/A *
1N/A * Copyright (c) 1997, 1998
1N/A * Sleepycat Software. All rights reserved.
1N/A */
1N/A
1N/A#include "config.h"
1N/A
1N/A#ifndef lint
1N/Astatic const char sccsid[] = "@(#)os_seek.c 10.11 (Sleepycat) 10/12/98";
1N/A#endif /* not lint */
1N/A
1N/A#ifndef NO_SYSTEM_INCLUDES
1N/A#include <sys/types.h>
1N/A
1N/A#include <errno.h>
1N/A#include <unistd.h>
1N/A#endif
1N/A
1N/A#include "db_int.h"
1N/A#include "os_jump.h"
1N/A
1N/A/*
1N/A * __os_seek --
1N/A * Seek to a page/byte offset in the file.
1N/A *
1N/A * PUBLIC: int __os_seek __P((int, size_t, db_pgno_t, u_int32_t, int, int));
1N/A */
1N/Aint
1N/A__os_seek(fd, pgsize, pageno, relative, isrewind, whence)
1N/A int fd;
1N/A size_t pgsize;
1N/A db_pgno_t pageno;
1N/A u_int32_t relative;
1N/A int isrewind, whence;
1N/A{
1N/A off_t offset;
1N/A int ret;
1N/A
1N/A if (__db_jump.j_seek != NULL)
1N/A ret = __db_jump.j_seek(fd,
1N/A pgsize, pageno, relative, isrewind, whence);
1N/A else {
1N/A offset = (off_t)pgsize * pageno + relative;
1N/A if (isrewind)
1N/A offset = -offset;
1N/A
1N/A ret = lseek(fd, offset, whence);
1N/A }
1N/A return (ret == -1 ? errno : 0);
1N/A}