1 /*- 2 * Copyright (c) 1982, 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 * 7 * @(#)lseek.c 7.1 (Berkeley) 05/05/91 8 */ 9 10 #include <sys/param.h> 11 #include "saio.h" 12 13 lseek(fdesc, addr, ptr) 14 int fdesc, ptr; 15 off_t addr; 16 { 17 register struct iob *io; 18 19 #ifndef SMALL 20 if (ptr != L_SET) { 21 printf("Seek not from beginning of file\n"); 22 errno = EOFFSET; 23 return (-1); 24 } 25 #endif 26 fdesc -= 3; 27 #ifndef SMALL 28 if (fdesc < 0 || fdesc >= SOPEN_MAX || 29 ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0) { 30 errno = EBADF; 31 return (-1); 32 } 33 #endif 34 io->i_offset = addr; 35 io->i_bn = addr / DEV_BSIZE; 36 io->i_cc = 0; 37 return (0); 38 } 39