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