Last change
on this file since 535 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | FUNCTION |
---|
3 | <<pwrite64>>---write a large file from specified position |
---|
4 | |
---|
5 | INDEX |
---|
6 | pwrite64 |
---|
7 | |
---|
8 | SYNOPSIS |
---|
9 | #include <unistd.h> |
---|
10 | ssize_t pwrite64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>); |
---|
11 | |
---|
12 | DESCRIPTION |
---|
13 | The <<pwrite64>> function is similar to <<pwrite>>. The only difference is |
---|
14 | that it operates on large files and so takes a 64-bit offset. Like <<pwrite>>>, |
---|
15 | the file position is unchanged by the function (i.e. the file position |
---|
16 | is the same before and after a call to <<pwrite>>). |
---|
17 | |
---|
18 | RETURNS |
---|
19 | <<pwrite64>> returns the number of bytes written or <<-1>> if failure occurred. |
---|
20 | |
---|
21 | PORTABILITY |
---|
22 | <<pwrite64>> is an EL/IX extension. |
---|
23 | |
---|
24 | Supporting OS subroutine required: <<write>>, <<lseek64>>. |
---|
25 | */ |
---|
26 | |
---|
27 | #include <_ansi.h> |
---|
28 | #include <unistd.h> |
---|
29 | #include <reent.h> |
---|
30 | #include <machine/weakalias.h> |
---|
31 | |
---|
32 | ssize_t |
---|
33 | __libc_pwrite64 (int fd, |
---|
34 | void *buf, |
---|
35 | size_t n, |
---|
36 | loff_t off) |
---|
37 | { |
---|
38 | loff_t cur_pos; |
---|
39 | _READ_WRITE_RETURN_TYPE num_written; |
---|
40 | |
---|
41 | if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1) |
---|
42 | return -1; |
---|
43 | |
---|
44 | if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1) |
---|
45 | return -1; |
---|
46 | |
---|
47 | num_written = write (fd, buf, n); |
---|
48 | |
---|
49 | if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1) |
---|
50 | return -1; |
---|
51 | |
---|
52 | return (ssize_t)num_written; |
---|
53 | } |
---|
54 | weak_alias(__libc_pwrite64,pwrite64) |
---|
55 | |
---|
Note: See
TracBrowser
for help on using the repository browser.