. fix for wild store at startup time by calling dev_io without fp

initialized
 . fix for writing exactly PIPE_SIZE to a pipe with O_NONBLOCK blocking
   anyway because of incomplete logic in pipe_check
This commit is contained in:
Ben Gras 2006-08-10 11:51:11 +00:00
parent 4ba5826ba6
commit 4539e54d8b
2 changed files with 9 additions and 4 deletions

View file

@ -427,6 +427,7 @@ int flags; /* special flags, like O_NONBLOCK */
static cp_grant_id_t gids[NR_IOREQS];
int vec_grants = 0, orig_op, safe;
void *buf_used;
endpoint_t ioproc;
/* Determine task dmap. */
dp = &dmap[(dev >> MAJOR) & BYTE];
@ -469,8 +470,8 @@ int flags; /* special flags, like O_NONBLOCK */
dev_mess.COUNT = bytes;
dev_mess.HIGHPOS = 0;
/* This field will be used if the i/o is suspended. */
fp->fp_ioproc = dev_mess.IO_ENDPT;
/* This will be used if the i/o is suspended. */
ioproc = dev_mess.IO_ENDPT;
/* Call the task. */
(*dp->dmap_io)(dp->dmap_driver, &dev_mess);
@ -487,10 +488,13 @@ int flags; /* special flags, like O_NONBLOCK */
if(vec_grants > 0) {
panic(__FILE__,"SUSPEND on vectored i/o", NO_NUM);
}
/* fp is uninitialized at init time. */
if(!fp)
panic(__FILE__,"SUSPEND on NULL fp", NO_NUM);
if (flags & O_NONBLOCK) {
/* Not supposed to block. */
dev_mess.m_type = CANCEL;
dev_mess.IO_ENDPT = fp->fp_ioproc;
dev_mess.IO_ENDPT = ioproc;
dev_mess.IO_GRANT = (char *) gid;
/* This R_BIT/W_BIT check taken from suspend()/unpause()
@ -507,6 +511,7 @@ int flags; /* special flags, like O_NONBLOCK */
suspend(dp->dmap_driver);
assert(!GRANT_VALID(fp->fp_grant));
fp->fp_grant = gid; /* revoke this when unsuspended. */
fp->fp_ioproc = ioproc;
return(SUSPEND);
}
}

View file

@ -139,7 +139,7 @@ int notouch; /* check only */
if (position + bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {
if ((oflags & O_NONBLOCK)
&& bytes < PIPE_SIZE(rip->i_sp->s_block_size))
&& bytes <= PIPE_SIZE(rip->i_sp->s_block_size))
return(EAGAIN);
else if ((oflags & O_NONBLOCK)
&& bytes > PIPE_SIZE(rip->i_sp->s_block_size)) {