patch-2.4.0-test3 linux/fs/pipe.c

Next file: linux/fs/proc/array.c
Previous file: linux/fs/partitions/ultrix.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test2/linux/fs/pipe.c linux/fs/pipe.c
@@ -366,12 +366,14 @@
 static int
 pipe_rdwr_open(struct inode *inode, struct file *filp)
 {
+	lock_kernel();
 	down(PIPE_SEM(*inode));
 	if (filp->f_mode & FMODE_READ)
 		PIPE_READERS(*inode)++;
 	if (filp->f_mode & FMODE_WRITE)
 		PIPE_WRITERS(*inode)++;
 	up(PIPE_SEM(*inode));
+	unlock_kernel();
 
 	return 0;
 }
@@ -466,6 +468,13 @@
 }
 
 static struct vfsmount *pipe_mnt;
+static int pipefs_delete_dentry(struct dentry *dentry)
+{
+	return 1;
+}
+static struct dentry_operations pipefs_dentry_operations = {
+	d_delete:	pipefs_delete_dentry,
+};
 
 static struct inode * get_pipe_inode(void)
 {
@@ -534,14 +543,15 @@
 	j = error;
 
 	error = -ENOMEM;
-	sprintf(name, "%lu", inode->i_ino);
+	sprintf(name, "[%lu]", inode->i_ino);
 	this.name = name;
 	this.len = strlen(name);
-	/* We don't care for hash - it will never be looked up */
+	this.hash = inode->i_ino; /* will go */
 	dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
+	dentry->d_op = &pipefs_dentry_operations;
 	if (!dentry)
 		goto close_f12_inode_i_j;
-	d_instantiate(dentry, inode);
+	d_add(dentry, inode);
 	f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
 	f1->f_dentry = f2->f_dentry = dget(dentry);
 
@@ -607,6 +617,8 @@
 	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
 	root->i_uid = root->i_gid = 0;
 	root->i_atime = root->i_mtime = root->i_ctime = CURRENT_TIME;
+	root->i_sb = sb;
+	root->i_dev = sb->s_dev;
 	sb->s_blocksize = 1024;
 	sb->s_blocksize_bits = 10;
 	sb->s_magic = PIPEFS_MAGIC;
@@ -631,7 +643,9 @@
 	if (!err) {
 		pipe_mnt = kern_mount(&pipe_fs_type);
 		err = PTR_ERR(pipe_mnt);
-		if (!IS_ERR(pipe_mnt))
+		if (IS_ERR(pipe_mnt))
+			unregister_filesystem(&pipe_fs_type);
+		else
 			err = 0;
 	}
 	return err;

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