patch-2.4.0-test3 linux/fs/coda/psdev.c

Next file: linux/fs/coda/symlink.c
Previous file: linux/fs/coda/pioctl.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test2/linux/fs/coda/psdev.c linux/fs/coda/psdev.c
@@ -109,7 +109,7 @@
 	ssize_t retval = 0, count = 0;
 	int error;
 
-	if ( !coda_upc_comm.vc_pid ) 
+	if ( !coda_upc_comm.vc_inuse ) 
 		return -EIO;
         /* Peek at the opcode, uniquefier */
 	if (copy_from_user(&hdr, buf, 2 * sizeof(u_long)))
@@ -291,29 +291,14 @@
         struct venus_comm *vcp = &coda_upc_comm;
         ENTRY;
 	
-	/* first opener: must be lento. Initialize & take its pid */
-	if ( (file->f_flags & O_ACCMODE) == O_RDWR ) {
-		if ( vcp->vc_pid ) {
-			printk("Venus pid already set to %d!!\n", vcp->vc_pid);
-			return -1;
-		}
-		if ( vcp->vc_inuse ) {
-			printk("psdev_open: Cannot O_RDWR while open.\n");
-			return -1;
-		}
+	/* first opener, initialize */
+	if (!vcp->vc_inuse++) {
+            INIT_LIST_HEAD(&vcp->vc_pending);
+            INIT_LIST_HEAD(&vcp->vc_processing);
+            vcp->vc_seq = 0;
 	}
-	
-	vcp->vc_inuse++;
 
-	if ( (file->f_flags & O_ACCMODE) == O_RDWR ) {
-		vcp->vc_pid = current->pid;
-		vcp->vc_seq = 0;
-		INIT_LIST_HEAD(&vcp->vc_pending);
-		INIT_LIST_HEAD(&vcp->vc_processing);
-	}
-
-	CDEBUG(D_PSDEV, "inuse: %d, vc_pid %d, caller %d\n",
-	       vcp->vc_inuse, vcp->vc_pid, current->pid);
+	CDEBUG(D_PSDEV, "inuse: %d\n", vcp->vc_inuse);
 
 	EXIT;
         return 0;
@@ -332,17 +317,9 @@
 		return -1;
 	}
 
-	vcp->vc_inuse--;
-	CDEBUG(D_PSDEV, "inuse: %d, vc_pid %d, caller %d\n",
-	       vcp->vc_inuse, vcp->vc_pid, current->pid);
-
-	if ( vcp->vc_pid != current->pid ) {
-		/* FIXME: this is broken. If venus does fork(), accounting goes wrong */
-		printk( "Closed by someone else than caller?\n" );
-		return 0;
-	}
+	CDEBUG(D_PSDEV, "psdev_release: inuse %d\n", vcp->vc_inuse);
+	if (--vcp->vc_inuse) return 0;
         
-	vcp->vc_pid = 0;
         /* Wakeup clients so they can return. */
 	CDEBUG(D_PSDEV, "wake up pending clients\n");
 	lh = vcp->vc_pending.next;
@@ -414,7 +391,7 @@
 		     CODA_PSDEV_MAJOR);
               return -EIO;
 	}
-	devfs_handle = devfs_mk_dir (NULL, "coda", 4, NULL);
+	devfs_handle = devfs_mk_dir (NULL, "coda", NULL);
 	devfs_register_series (devfs_handle, "%u", MAX_CODADEVS, DEVFS_FL_NONE,
 			       CODA_PSDEV_MAJOR, 0,
 			       S_IFCHR | S_IRUSR | S_IWUSR,

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)