diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-04-29 19:31:23 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-04-29 19:31:23 +0000 |
commit | 29798f0d57549a89d7ec6c8717fda26347e6bbf7 (patch) | |
tree | 76ffe5ce7c145afb2449d0b56780d8cd03e98ae1 /newlib/libc/sys/linux/pread64.c | |
parent | eccebec08df9f2b74e2bf457f4063c86662727e0 (diff) | |
download | cygnal-29798f0d57549a89d7ec6c8717fda26347e6bbf7.tar.gz cygnal-29798f0d57549a89d7ec6c8717fda26347e6bbf7.tar.bz2 cygnal-29798f0d57549a89d7ec6c8717fda26347e6bbf7.zip |
2002-04-29 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/unistd.h (pread, pwrite): Added prototypes.
* libc/unix/Makefile.am: Add pread.c and pwrite.c.
* libc/sys/linux/Makefile.am: Add pread64.c and pwrite64.c.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/unix/Makefile.in: Ditto.
* libc/sys/linux/pread64.c: New file.
* libc/sys/linux/pwrite64.c: Ditto.
* libc/unix/pread.c: Ditto.
* libc/unix/pwrite.c: Ditto.
Diffstat (limited to 'newlib/libc/sys/linux/pread64.c')
-rw-r--r-- | newlib/libc/sys/linux/pread64.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/newlib/libc/sys/linux/pread64.c b/newlib/libc/sys/linux/pread64.c new file mode 100644 index 000000000..c6d15f91d --- /dev/null +++ b/newlib/libc/sys/linux/pread64.c @@ -0,0 +1,62 @@ +/* +FUNCTION +<<pread64>>---read a large file from specified position + +INDEX + pread64 + +ANSI_SYNOPSIS + #include <unistd.h> + ssize_t pread64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>); + +TRAD_SYNOPSIS + #include <unistd.h> + ssize_t pread64(<[fd]>, <[buf]>, <[n]>, <[off]>) + int <[fd]>; + void *<[buf]>; + size_t <[n]>; + loff_t <[off]>; + +DESCRIPTION +The <<pread64>> function is similar to <<pread>>. The only difference is +that it operates on large files and so takes a 64-bit offset. Like <<pread>>>, +the file position is unchanged by the function (i.e. the file position +is the same before and after a call to <<pread>>). + +RETURNS +<<pread64>> returns the number of bytes read or <<-1>> if failure occurred. + +PORTABILITY +<<pread64>> is an EL/IX extension. + +Supporting OS subroutine required: <<read64>>, <<lseek64>>. +*/ + +#include <_ansi.h> +#include <unistd.h> +#include <reent.h> + +ssize_t +_DEFUN (pread64, (fd, buf, n, off), + int fd _AND + _PTR buf _AND + size_t n _AND + loff_t off) +{ + loff_t cur_pos; + _READ_WRITE_RETURN_TYPE num_read; + + if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1) + return -1; + + if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1) + return -1; + + num_read = read64 (fd, buf, n); + + if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1) + return -1; + + return (ssize_t)num_read; +} + |