Added seek.c, an interface to the lseek systemcall
This commit is contained in:
parent
6161b898cd
commit
1487265556
|
@ -17,3 +17,4 @@ system.h
|
||||||
time.c
|
time.c
|
||||||
unlock.c
|
unlock.c
|
||||||
write.c
|
write.c
|
||||||
|
seek.c
|
||||||
|
|
|
@ -7,10 +7,10 @@ INCLUDES = -I.
|
||||||
CFLAGS = $(INCLUDES) -O
|
CFLAGS = $(INCLUDES) -O
|
||||||
OBJ = access.o break.o chmode.o close.o create.o filesize.o \
|
OBJ = access.o break.o chmode.o close.o create.o filesize.o \
|
||||||
modtime.o lock.o open.o read.o remove.o stop.o \
|
modtime.o lock.o open.o read.o remove.o stop.o \
|
||||||
system.o time.o unlock.o write.o
|
system.o time.o unlock.o write.o seek.o
|
||||||
CSRC = access.c break.c chmode.c close.c create.c filesize.c \
|
CSRC = access.c break.c chmode.c close.c create.c filesize.c \
|
||||||
modtime.c lock.c open.c read.c remove.c stop.c \
|
modtime.c lock.c open.c read.c remove.c stop.c \
|
||||||
system.c time.c unlock.c write.c
|
system.c time.c unlock.c write.c seek.c
|
||||||
SRC = Makefile system.h $(CSRC)
|
SRC = Makefile system.h $(CSRC)
|
||||||
|
|
||||||
all: $(LIBSYS)
|
all: $(LIBSYS)
|
||||||
|
|
18
modules/src/system/seek.c
Normal file
18
modules/src/system/seek.c
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
|
*/
|
||||||
|
/* $Header$ */
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
|
|
||||||
|
long lseek();
|
||||||
|
|
||||||
|
int
|
||||||
|
sys_seek(fp, off, whence, poff)
|
||||||
|
File *fp;
|
||||||
|
long off;
|
||||||
|
long *poff;
|
||||||
|
{
|
||||||
|
return (*poff = lseek(fp->o_fd, off, whence)) >= 0;
|
||||||
|
}
|
|
@ -29,6 +29,12 @@ sys_break, sys_stop, sys_time \- system call interface
|
||||||
.B char *bufptr;
|
.B char *bufptr;
|
||||||
.B int nbytes;
|
.B int nbytes;
|
||||||
.PP
|
.PP
|
||||||
|
.B int sys_seek(filep, offset, whence, poffset)
|
||||||
|
.B File *filep;
|
||||||
|
.B long offset;
|
||||||
|
.B int whence;
|
||||||
|
.B long *poffset;
|
||||||
|
.PP
|
||||||
.B int sys_reset(filep)
|
.B int sys_reset(filep)
|
||||||
.B File *filep
|
.B File *filep
|
||||||
.PP
|
.PP
|
||||||
|
@ -142,6 +148,31 @@ A non-zero return value indicates that
|
||||||
.I nbytes
|
.I nbytes
|
||||||
are actually written.
|
are actually written.
|
||||||
.PP
|
.PP
|
||||||
|
.I Sys_seek
|
||||||
|
sets the file pointer of
|
||||||
|
.I filep
|
||||||
|
as follows:
|
||||||
|
.IP " "
|
||||||
|
If
|
||||||
|
.I whence
|
||||||
|
is 0, the pointer is set to
|
||||||
|
.I offset
|
||||||
|
bytes.
|
||||||
|
.IP " "
|
||||||
|
If
|
||||||
|
.I whence
|
||||||
|
is 1, the pointer is set to its current location plus
|
||||||
|
.IR offset .
|
||||||
|
.IP " "
|
||||||
|
If
|
||||||
|
.I whence
|
||||||
|
is 2, the pointer is set to the size of the file plus
|
||||||
|
.IR offset .
|
||||||
|
.PP
|
||||||
|
Upon succesful completion, the resulting pointer location is returned in
|
||||||
|
.IR poffset ,
|
||||||
|
and 1 is returned. Otherwise, 0 is returned.
|
||||||
|
.PP
|
||||||
.I Sys_reset
|
.I Sys_reset
|
||||||
causes the open file known by
|
causes the open file known by
|
||||||
.I filep
|
.I filep
|
||||||
|
|
Loading…
Reference in a new issue