patch-2.1.45 linux/net/socket.c

Next file: linux/net/unix/af_unix.c
Previous file: linux/net/netlink.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.44/linux/net/socket.c linux/net/socket.c
@@ -67,7 +67,6 @@
 #include <linux/socket.h>
 #include <linux/fcntl.h>
 #include <linux/file.h>
-#include <linux/dalloc.h>
 #include <linux/net.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
@@ -150,7 +149,11 @@
 #define MAX_SOCK_ADDR	128		/* 108 for Unix domain - 
 					   16 for IP, 16 for IPX,
 					   24 for IPv6,
-					   about 80 for AX.25 */
+					   about 80 for AX.25 
+					   must be at least one bigger than
+					   the AF_UNIX size (see net/unix/af_unix.c
+					   :unix_mkname()).  
+					 */
  
 int move_addr_to_kernel(void *uaddr, int ulen, void *kaddr)
 {
@@ -207,13 +210,24 @@
 			return -ENFILE;
 		}
 
+		file->f_dentry = d_alloc_root(inode, NULL);
+		if (!file->f_dentry) {
+			put_filp(file);
+			put_unused_fd(fd);
+			return -ENOMEM;
+		}
+
+		/*
+		 * The socket maintains a reference to the inode, so we
+		 * have to increment the count.
+		 */
+		inode->i_count++;
+
 		current->files->fd[fd] = file;
 		file->f_op = &socket_file_ops;
 		file->f_mode = 3;
 		file->f_flags = O_RDWR;
-		file->f_inode = inode;
-		if (inode) 
-			atomic_inc(&inode->i_count);
+		file->f_dentry = d_alloc_root(inode, NULL);
 		file->f_pos = 0;
 	}
 	return fd;
@@ -239,11 +253,11 @@
 		return NULL;
 	}
 
-	inode = file->f_inode;
+	inode = file->f_dentry->d_inode;
 	if (!inode || !inode->i_sock || !socki_lookup(inode))
 	{
 		*err = -ENOTSOCK;
-		fput(file,inode);
+		fput(file);
 		return NULL;
 	}
 
@@ -252,7 +266,7 @@
 
 extern __inline__ void sockfd_put(struct socket *sock)
 {
-	fput(sock->file,sock->inode);
+	fput(sock->file);
 }
 
 /*
@@ -461,7 +475,7 @@
 {
 	struct socket *sock;
 
-	sock = socki_lookup(file->f_inode);
+	sock = socki_lookup(file->f_dentry->d_inode);
 
 	/*
 	 *	We can't return errors to poll, so it's either yes or no. 
@@ -1293,7 +1307,7 @@
 {
 	struct socket *sock;
 
-	sock = socki_lookup (filp->f_inode);
+	sock = socki_lookup (filp->f_dentry->d_inode);
 	if (sock && sock->ops && sock->ops->fcntl)
 		return sock->ops->fcntl(sock, cmd, arg);
 	return(-EINVAL);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov