1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1999 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include "compat.h" 30 #include <errno.h> 31 #include <syscall.h> 32 #include <sys/types.h> 33 #include <unistd.h> 34 35 extern int errno; 36 37 off_t lseek(int fd, off_t offset, int whence) 38 { 39 int off, ret; 40 41 if (whence < 0 || whence > 2) { 42 errno = EINVAL; 43 return (-1); 44 } 45 if (fd_get(fd) != -1) { 46 off = getmodsize(offset, sizeof(struct utmpx), 47 sizeof(struct compat_utmp)); 48 if ((ret = _syscall(SYS_lseek, fd, off, whence)) == -1) 49 return(-1); 50 51 ret = getmodsize(ret, sizeof(struct compat_utmp), 52 sizeof(struct utmpx)); 53 return (ret); 54 } 55 else 56 return (_syscall(SYS_lseek, fd, offset, whence)); 57 } 58