163276Smckusick /*-
2*63370Sbostic * Copyright (c) 1993
3*63370Sbostic * The Regents of the University of California. All rights reserved.
463276Smckusick *
563276Smckusick * This code is derived from software contributed to Berkeley by
663276Smckusick * The Mach Operating System project at Carnegie-Mellon University.
763276Smckusick *
863276Smckusick * %sccs.include.redist.c%
963276Smckusick *
10*63370Sbostic * @(#)lseek.c 8.1 (Berkeley) 06/11/93
1163276Smckusick *
1263276Smckusick *
1363276Smckusick * Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
1463276Smckusick * All Rights Reserved.
1563276Smckusick *
1663276Smckusick * Author: Alessandro Forin
1763276Smckusick *
1863276Smckusick * Permission to use, copy, modify and distribute this software and its
1963276Smckusick * documentation is hereby granted, provided that both the copyright
2063276Smckusick * notice and this permission notice appear in all copies of the
2163276Smckusick * software, derivative works or modified versions, and any portions
2263276Smckusick * thereof, and that both notices appear in supporting documentation.
2363276Smckusick *
2463276Smckusick * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
2563276Smckusick * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
2663276Smckusick * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
2763276Smckusick *
2863276Smckusick * Carnegie Mellon requests users of this software to return to
2963276Smckusick *
3063276Smckusick * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
3163276Smckusick * School of Computer Science
3263276Smckusick * Carnegie Mellon University
3363276Smckusick * Pittsburgh PA 15213-3890
3463276Smckusick *
3563276Smckusick * any improvements or extensions that they make and grant Carnegie the
3663276Smckusick * rights to redistribute these changes.
3763276Smckusick */
3863276Smckusick
3963276Smckusick #include <stand/stand.h>
4063276Smckusick
4163276Smckusick off_t
lseek(fd,offset,where)4263276Smckusick lseek(fd, offset, where)
4363276Smckusick int fd;
4463276Smckusick off_t offset;
4563276Smckusick int where;
4663276Smckusick {
4763276Smckusick register struct open_file *f = &files[fd];
4863276Smckusick
4963276Smckusick if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
5063276Smckusick errno = EBADF;
5163276Smckusick return (-1);
5263276Smckusick }
5363276Smckusick
5463276Smckusick /* seek is not supported on raw devices */
5563276Smckusick if (f->f_flags & F_RAW)
5663276Smckusick return ((off_t)-1);
5763276Smckusick
5863276Smckusick return (f->f_ops->seek)(f, offset, where);
5963276Smckusick }
60