xref: /csrg-svn/sys/stand.att/lseek.c (revision 63370)
149148Sbostic /*-
2*63370Sbostic  * Copyright (c) 1982, 1988, 1993
3*63370Sbostic  *	The Regents of the University of California.  All rights reserved.
449148Sbostic  *
549148Sbostic  * %sccs.include.proprietary.c%
649148Sbostic  *
7*63370Sbostic  *	@(#)lseek.c	8.1 (Berkeley) 06/11/93
849148Sbostic  */
949148Sbostic 
1049148Sbostic #include <sys/param.h>
1160327Smckusick #include <stand.att/saio.h>
1249148Sbostic 
1360327Smckusick off_t
lseek(fdesc,addr,ptr)1449148Sbostic lseek(fdesc, addr, ptr)
1549148Sbostic 	int fdesc, ptr;
1649148Sbostic 	off_t addr;
1749148Sbostic {
1849148Sbostic 	register struct iob *io;
1949148Sbostic 
2049148Sbostic #ifndef SMALL
2149148Sbostic 	if (ptr != L_SET) {
2249148Sbostic 		printf("Seek not from beginning of file\n");
2349148Sbostic 		errno = EOFFSET;
2449148Sbostic 		return (-1);
2549148Sbostic 	}
2649148Sbostic #endif
2749148Sbostic 	fdesc -= 3;
2849148Sbostic #ifndef SMALL
2949148Sbostic 	if (fdesc < 0 || fdesc >= SOPEN_MAX ||
3049148Sbostic 	    ((io = &iob[fdesc])->i_flgs & F_ALLOC) == 0) {
3149148Sbostic 		errno = EBADF;
3249148Sbostic 		return (-1);
3349148Sbostic 	}
3449148Sbostic #endif
3549148Sbostic 	io->i_offset = addr;
3649148Sbostic 	io->i_bn = addr / DEV_BSIZE;
3749148Sbostic 	io->i_cc = 0;
3849148Sbostic 	return (0);
3949148Sbostic }
40