diff --git a/src/sys/include/vfs/file.h b/src/sys/include/vfs/file.h index 9614d81..f03aaeb 100644 --- a/src/sys/include/vfs/file.h +++ b/src/sys/include/vfs/file.h @@ -28,8 +28,6 @@ #include #include -#define SEEK_SET 0x0 - #define VBLKSHIFT 12 #define VBLKSIZE (1 << VBLKSHIFT) #define SBLOCKSIZE 8192 diff --git a/src/sys/include/vfs/vfs.h b/src/sys/include/vfs/vfs.h index ac4d84a..a06784a 100644 --- a/src/sys/include/vfs/vfs.h +++ b/src/sys/include/vfs/vfs.h @@ -48,6 +48,16 @@ #define fileBinary 0x0004 #define fileAppend 0x0008 +/* New Stuff */ + +/* whence values for lseek(2) */ +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + + /*! \brief filesSystem Structure diff --git a/src/sys/kernel/gen_calls.c b/src/sys/kernel/gen_calls.c index 004380a..fb27767 100644 --- a/src/sys/kernel/gen_calls.c +++ b/src/sys/kernel/gen_calls.c @@ -187,29 +187,6 @@ return(error); } -int lseek(struct thread *td, struct lseek_args *uap) { - int error = 0x0; - struct file *fd = 0x0; - - getfd(td,&fd,uap->fd); - switch (uap->whence) { - case 2: - K_PANIC("UNHANDLED WHENCE"); - break; - case 1: - fd->fd->offset += uap->offset; - break; - case 0: - fd->fd->offset = uap->offset; - break; - default: - kprintf("offset: [%i], whence: [%i]\n",uap->offset,uap->whence); - break; - } - - return(error); - } - /*** END ***/ diff --git a/src/sys/vfs/Makefile b/src/sys/vfs/Makefile index a8748fe..5fbbef6 100644 --- a/src/sys/vfs/Makefile +++ b/src/sys/vfs/Makefile @@ -6,7 +6,7 @@ include ../Makefile.inc # Objects -OBJS = mount.o file.o vfs.o +OBJS = mount.o file.o vfs.o vfs_syscalls.o all: $(OBJS) diff --git a/src/sys/vfs/vfs_syscalls.c b/src/sys/vfs/vfs_syscalls.c new file mode 100644 index 0000000..4c4cee8 --- /dev/null +++ b/src/sys/vfs/vfs_syscalls.c @@ -0,0 +1,61 @@ +/***************************************************************************************** + Copyright (c) 2007 The UbixOS Project + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + $Id$ + +*****************************************************************************************/ + +#include +#include +#include +#include + +int lseek(struct thread *td, struct lseek_args *uap) { + int error = 0x0; + struct file *fd = 0x0; + + getfd(td,&fd,uap->fd); + switch (uap->whence) { + case SEEK_END: + K_PANIC("UNHANDLED WHENCE"); + break; + case SEEK_CUR: + fd->fd->offset += uap->offset; + break; + case SEEK_SET: + fd->fd->offset = uap->offset; + break; + default: + kprintf("offset: [%i], whence: [%i]\n",uap->offset,uap->whence); + K_PANIC("Invalid whence"); + break; + } + + return(error); + } /* end func */ + +/*** + END + ***/ diff --git a/ubixos.kdevelop.filelist b/ubixos.kdevelop.filelist index 2bbd436..b56194b 100644 --- a/ubixos.kdevelop.filelist +++ b/ubixos.kdevelop.filelist @@ -10,3 +10,4 @@ src/sys/vmm/vmm_virtual.c src/sys/include/vmm/vmm.h src/sys/include/vmm/paging.h +src/sys/vfs/vfs_syscalls.c