Changeset View
Changeset View
Standalone View
Standalone View
src/estream.c
Context not available. | |||||
int fd; /* The file descriptor we are using for actual output. */ | int fd; /* The file descriptor we are using for actual output. */ | ||||
int no_close; /* If set we won't close the file descriptor. */ | int no_close; /* If set we won't close the file descriptor. */ | ||||
int nonblock; /* Non-blocking mode is enabled. */ | int nonblock; /* Non-blocking mode is enabled. */ | ||||
#ifdef HAVE_W32_SYSTEM | |||||
int no_syscall_clamp; /* Do not use the syscall clamp. */ | |||||
#endif | |||||
} *estream_cookie_fd_t; | } *estream_cookie_fd_t; | ||||
Context not available. | |||||
* Create function for objects indentified by a libc file descriptor. | * Create function for objects indentified by a libc file descriptor. | ||||
*/ | */ | ||||
static int | static int | ||||
func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close) | func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close, | ||||
int no_syscall_clamp) | |||||
{ | { | ||||
estream_cookie_fd_t fd_cookie; | estream_cookie_fd_t fd_cookie; | ||||
int err; | int err; | ||||
Context not available. | |||||
fd_cookie->fd = fd; | fd_cookie->fd = fd; | ||||
fd_cookie->no_close = no_close; | fd_cookie->no_close = no_close; | ||||
fd_cookie->nonblock = !!(modeflags & O_NONBLOCK); | fd_cookie->nonblock = !!(modeflags & O_NONBLOCK); | ||||
#ifdef HAVE_W32_SYSTEM | |||||
fd_cookie->no_syscall_clamp = no_syscall_clamp; | |||||
#else | |||||
(void)no_syscall_clamp; | |||||
#endif | |||||
*cookie = fd_cookie; | *cookie = fd_cookie; | ||||
err = 0; | err = 0; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_pre_syscall (); | _gpgrt_pre_syscall (); | ||||
do | do | ||||
{ | { | ||||
bytes_read = read (file_cookie->fd, buffer, size); | bytes_read = read (file_cookie->fd, buffer, size); | ||||
} | } | ||||
while (bytes_read == -1 && errno == EINTR); | while (bytes_read == -1 && errno == EINTR); | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_post_syscall (); | _gpgrt_post_syscall (); | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
else if (buffer) | else if (buffer) | ||||
{ | { | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_pre_syscall (); | _gpgrt_pre_syscall (); | ||||
do | do | ||||
{ | { | ||||
bytes_written = write (file_cookie->fd, buffer, size); | bytes_written = write (file_cookie->fd, buffer, size); | ||||
} | } | ||||
while (bytes_written == -1 && errno == EINTR); | while (bytes_written == -1 && errno == EINTR); | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_post_syscall (); | _gpgrt_post_syscall (); | ||||
} | } | ||||
else | else | ||||
Context not available. | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_pre_syscall (); | _gpgrt_pre_syscall (); | ||||
offset_new = lseek (file_cookie->fd, *offset, whence); | offset_new = lseek (file_cookie->fd, *offset, whence); | ||||
#ifdef HAVE_W32_SYSTEM | |||||
if (!file_cookie->no_syscall_clamp) | |||||
#endif | |||||
_gpgrt_post_syscall (); | _gpgrt_post_syscall (); | ||||
if (offset_new == -1) | if (offset_new == -1) | ||||
err = -1; | err = -1; | ||||
Context not available. | |||||
stream_internal_new = NULL; | stream_internal_new = NULL; | ||||
#if HAVE_W32_SYSTEM | #if HAVE_W32_SYSTEM | ||||
if ((xmode & X_POLLABLE) && kind != BACKEND_W32) | if ((xmode & X_POLLABLE) | ||||
{ | && !(kind == BACKEND_W32 || kind == BACKEND_FD)) | ||||
/* We require the W32 backend, because only that allows us to | { | ||||
* write directly using the native W32 API and to disable the | /* | ||||
* system clamp. Note that func_w32_create has already been | * W32 backend is supported, because it allows us to write | ||||
* called with the flag to disable the system call clamp. */ | * directly using the native W32 API and to disable the system | ||||
* clamp. | |||||
* | |||||
* FD backend is also supported, disabling system clamp. | |||||
* | |||||
* Note that func_fd_create/func_w32_create has already been | |||||
* called with the flag to disable the system call clamp. | |||||
*/ | |||||
_set_errno (EINVAL); | _set_errno (EINVAL); | ||||
err = -1; | err = -1; | ||||
goto out; | goto out; | ||||
Context not available. | |||||
goto out; | goto out; | ||||
} | } | ||||
err = func_fd_create (&cookie, filedes, modeflags, no_close); | err = func_fd_create (&cookie, filedes, modeflags, no_close, | ||||
!!(xmode & X_POLLABLE)); | |||||
if (err) | if (err) | ||||
goto out; | goto out; | ||||
Context not available. | |||||
goto out; | goto out; | ||||
} | } | ||||
err = func_fd_create (&cookie, fd, modeflags, 0); | err = func_fd_create (&cookie, fd, modeflags, 0, 0); | ||||
if (err) | if (err) | ||||
goto out; | goto out; | ||||
Context not available. |