]> Zhao Yanbai Git Server - minix.git/commitdiff
Return EIO if a filedescriptor cannot be re-opened after a driver restart.
authorPhilip Homburg <philip@cs.vu.nl>
Wed, 15 Aug 2007 12:53:52 +0000 (12:53 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Wed, 15 Aug 2007 12:53:52 +0000 (12:53 +0000)
Select now returns such a filedescriptor as ready (instead of EBADF).
Reply before dev_up in FSSIGNON to avoid the problem that a DEV_OPEN
request is received by a driver that expects a reply from the FSSIGNON.

servers/vfs/device.c
servers/vfs/filedes.c
servers/vfs/misc.c
servers/vfs/read.c
servers/vfs/select.c

index be6933a3b7e90612abe46c24b197ae294b061e4d..36b449b2d3bb669374111001c40a9d39ed6831d2 100644 (file)
@@ -807,10 +807,12 @@ printf("VFSdev_up: error sending new driver endpoint. FS_e: %d req_nr: %d\n",
 
         minor = ((vp->v_sdev >> MINOR) & BYTE);
 
-        printf("VFS: reopening special %d/%d..\n", maj, minor);
+        printf("vfs:dev_up: reopening special %d/%d..\n", maj, minor);
 
-        if((r = dev_open(vp->v_sdev, FS_PROC_NR,
-                        vp->v_mode & (R_BIT|W_BIT))) != OK) {
+       printf("vfs:dev_up: before dev_open\n");
+        r = dev_open(vp->v_sdev, FS_PROC_NR, vp->v_mode & (R_BIT|W_BIT));
+       printf("vfs:dev_up: after dev_open: result = %d\n", r);
+        if (r != OK) {
             int n;
             /* This function will set the fp_filp[]s of processes
              * holding that fp to NULL, but _not_ clear
index 6e57d8f6c9b1464cffe27491f53fad2bd6f14339..f1fae581cbfab275ad1aa24b1a7ec574b8799039 100644 (file)
@@ -84,6 +84,13 @@ int fild;                    /* file descriptor */
 
   err_code = EBADF;
   if (fild < 0 || fild >= OPEN_MAX ) return(NIL_FILP);
+  if (rfp->fp_filp[fild] == NIL_FILP && FD_ISSET(fild, &rfp->fp_filp_inuse))
+  {
+       printf("get_filp2: setting err_code to EIO for proc %d fd %d\n",
+               rfp->fp_endpoint, fild);
+       err_code = EIO; /* The filedes is not there, but is not closed either.
+                        */
+  }
   return(rfp->fp_filp[fild]);  /* may also be NIL_FILP */
 }
 
index 240fd03fb4b5aea539c43a54f3dd7a17e4b0acfe..5d24df96c2526d9c701ff147fd4250ade712fc77 100644 (file)
@@ -550,7 +550,11 @@ PUBLIC int do_svrctl()
                 * to be up.
                */
                if(fproc[proc_nr_n].fp_execced) {
+                       /* Reply before calling dev_up */
+                       printf("do_svrctl: replying before dev_up\n");
+                       reply(who_e, r);
                        dev_up(major);
+                       r= SUSPEND;
                } else {
                        dmap[major].dmap_flags |= DMAP_BABY;
                }
index 46ee6c88dc31dfa527d1364e6c161164d0e47a70..d3660d6cf36513f9c8dd31fd5130c7b7c9ae61ff 100644 (file)
@@ -71,7 +71,8 @@ int rw_flag;                  /* READING or WRITING */
 
   if ((f = get_filp(m_in.fd)) == NIL_FILP)
   {
-       printf("vfs:read_write: returning %d\n", err_code);
+       printf("vfs:read_write: returning %d to endpoint %d\n",
+               err_code, who_e);
        return(err_code);
   }
   if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) {
index 05fd10c796b66e154b40c943ff10a2d7f3f39511..710e3ed63124dc60df3a3a1a374948e92166589e 100644 (file)
@@ -278,9 +278,17 @@ PUBLIC int do_select(void)
        
                if (!(orig_ops = ops = tab2ops(fd, &selecttab[s])))
                        continue;
-               if (!(filp = selecttab[s].filps[fd] = get_filp(fd))) {
-                       select_cancel_all(&selecttab[s]);
-                       return EBADF;
+               filp = selecttab[s].filps[fd] = get_filp(fd);
+               if (filp == NULL) {
+                       if (err_code == EBADF) {
+                               select_cancel_all(&selecttab[s]);
+                               return EBADF;
+                       }
+
+                       /* File descriptor is 'ready' to return EIO */
+                       printf("vfs:do_select: EIO after driver failure\n");
+                       ops2tab(SEL_RD|SEL_WR|SEL_ERR, fd, &selecttab[s]);
+                       continue;
                }
 
                for(t = 0; t < SEL_FDS; t++) {