2 * Unix SMB/CIFS implementation.
3 * Samba system utilities
4 * Copyright (C) Andrew Tridgell 1992-1998
5 * Copyright (C) Jeremy Allison 1998-2005
6 * Copyright (C) Timur Bakeyev 2005
7 * Copyright (C) Bjoern Jacke 2006-2007
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "system/filesys.h"
25 #include "lib/sys_rw.h"
27 /*******************************************************************
28 A read wrapper that will deal with EINTR/EWOULDBLOCK
29 ********************************************************************/
31 ssize_t
sys_read(int fd
, void *buf
, size_t count
)
36 ret
= read(fd
, buf
, count
);
37 } while (ret
== -1 && (errno
== EINTR
|| errno
== EAGAIN
||
38 errno
== EWOULDBLOCK
));
43 /*******************************************************************
44 A write wrapper that will deal with EINTR/EWOULDBLOCK.
45 ********************************************************************/
47 ssize_t
sys_write(int fd
, const void *buf
, size_t count
)
52 ret
= write(fd
, buf
, count
);
53 } while (ret
== -1 && (errno
== EINTR
|| errno
== EAGAIN
||
54 errno
== EWOULDBLOCK
));
59 /*******************************************************************
60 A writev wrapper that will deal with EINTR.
61 ********************************************************************/
63 ssize_t
sys_writev(int fd
, const struct iovec
*iov
, int iovcnt
)
68 ret
= writev(fd
, iov
, iovcnt
);
69 } while (ret
== -1 && (errno
== EINTR
|| errno
== EAGAIN
||
70 errno
== EWOULDBLOCK
));
75 /*******************************************************************
76 A pread wrapper that will deal with EINTR
77 ********************************************************************/
79 ssize_t
sys_pread(int fd
, void *buf
, size_t count
, off_t off
)
84 ret
= pread(fd
, buf
, count
, off
);
85 } while (ret
== -1 && errno
== EINTR
);
89 /*******************************************************************
90 A write wrapper that will deal with EINTR
91 ********************************************************************/
93 ssize_t
sys_pwrite(int fd
, const void *buf
, size_t count
, off_t off
)
98 ret
= pwrite(fd
, buf
, count
, off
);
99 } while (ret
== -1 && errno
== EINTR
);