xref: /minix3/minix/lib/libc/sys/lseek.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #include <sys/cdefs.h>
2*433d6423SLionel Sambuc #include "namespace.h"
3*433d6423SLionel Sambuc #include <lib.h>
4*433d6423SLionel Sambuc 
5*433d6423SLionel Sambuc #include <string.h>
6*433d6423SLionel Sambuc #include <minix/u64.h>
7*433d6423SLionel Sambuc #include <unistd.h>
8*433d6423SLionel Sambuc 
9*433d6423SLionel Sambuc #ifdef __weak_alias
__weak_alias(lseek,_lseek)10*433d6423SLionel Sambuc __weak_alias(lseek, _lseek)
11*433d6423SLionel Sambuc #endif
12*433d6423SLionel Sambuc 
13*433d6423SLionel Sambuc off_t
14*433d6423SLionel Sambuc lseek(int fd, off_t offset, int whence)
15*433d6423SLionel Sambuc {
16*433d6423SLionel Sambuc   message m;
17*433d6423SLionel Sambuc 
18*433d6423SLionel Sambuc   memset(&m, 0, sizeof(m));
19*433d6423SLionel Sambuc   m.m_lc_vfs_lseek.fd = fd;
20*433d6423SLionel Sambuc   m.m_lc_vfs_lseek.offset = offset;
21*433d6423SLionel Sambuc   m.m_lc_vfs_lseek.whence = whence;
22*433d6423SLionel Sambuc   if (_syscall(VFS_PROC_NR, VFS_LSEEK, &m) < 0) return( (off_t) -1);
23*433d6423SLionel Sambuc   return(m.m_vfs_lc_lseek.offset);
24*433d6423SLionel Sambuc }
25