There is important information about booting non-ack images in docs/UPDATING. ack/aout-format images can't be built any more, and booting clang/ELF-format ones is a little different. Updating to the new boot monitor is recommended. Changes in this commit: . drop boot monitor -> allowing dropping ack support . facility to copy ELF boot files to /boot so that old boot monitor can still boot fairly easily, see UPDATING . no more ack-format libraries -> single-case libraries . some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases . drop several ack toolchain commands, but not all support commands (e.g. aal is gone but acksize is not yet). . a few libc files moved to netbsd libc dir . new /bin/date as minix date used code in libc/ . test compile fix . harmonize includes . /usr/lib is no longer special: without ack, /usr/lib plays no kind of special bootstrapping role any more and bootstrapping is done exclusively through packages, so releases depend even less on the state of the machine making them now. . rename nbsd_lib* to lib* . reduce mtree
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/* asyn_write() Author: Kees J. Bot
|
|
* 7 Jul 1997
|
|
*/
|
|
#include "asyn.h"
|
|
#include <signal.h>
|
|
|
|
ssize_t asyn_write(asynchio_t *asyn, int fd, const void *buf, size_t len)
|
|
/* Nonblocking write(). (See asyn_read()). */
|
|
{
|
|
asynfd_t *afd;
|
|
|
|
asyn->asyn_more++;
|
|
|
|
if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
|
|
afd= &asyn->asyn_afd[fd];
|
|
|
|
if (!afd->afd_seen) {
|
|
if ((afd->afd_flags= fcntl(fd, F_GETFL)) < 0) return -1;
|
|
afd->afd_seen= 1;
|
|
}
|
|
|
|
if (afd->afd_state[SEL_WRITE] == PENDING) {
|
|
sigset_t mask;
|
|
ssize_t result;
|
|
int err;
|
|
|
|
sigemptyset(&mask);
|
|
if (sigprocmask(SIG_SETMASK, &mask, &mask) < 0) return -1;
|
|
(void) fcntl(fd, F_SETFL, afd->afd_flags | O_NONBLOCK);
|
|
|
|
result= write(fd, buf, len);
|
|
err= errno;
|
|
|
|
(void) fcntl(fd, F_SETFL, afd->afd_flags);
|
|
(void) sigprocmask(SIG_SETMASK, &mask, nil);
|
|
|
|
errno= err;
|
|
if (result != -1 || errno != EAGAIN) {
|
|
afd->afd_state[SEL_WRITE]= IDLE;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
afd->afd_state[SEL_WRITE]= WAITING;
|
|
FD_SET(fd, &asyn->asyn_fdset[SEL_WRITE]);
|
|
errno= EAGAIN;
|
|
asyn->asyn_more--;
|
|
return -1;
|
|
}
|