]> Zhao Yanbai Git Server - minix.git/commitdiff
. fix for wild store at startup time by calling dev_io without fp
authorBen Gras <ben@minix3.org>
Thu, 10 Aug 2006 11:51:11 +0000 (11:51 +0000)
committerBen Gras <ben@minix3.org>
Thu, 10 Aug 2006 11:51:11 +0000 (11:51 +0000)
   initialized
 . fix for writing exactly PIPE_SIZE to a pipe with O_NONBLOCK blocking
   anyway because of incomplete logic in pipe_check

servers/fs/device.c
servers/fs/pipe.c

index 81995c19eb399f73c2046b6674cc1b54e426685e..e480eee2a22ac4a204c906666f28a6f936f39571 100644 (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);
        }
   }
index 790e7c7c3fd72965d746a1c9063ff2d64d64987f..57a8ebb1caa6d81b9e9b8c9416cef2b17dd8439b 100644 (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)) {