Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
[cascardo/linux.git] / net / socket.c
index 379b3a3..5d879fd 100644 (file)
@@ -258,7 +258,7 @@ static void sock_destroy_inode(struct inode *inode)
                        container_of(inode, struct socket_alloc, vfs_inode));
 }
 
-static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
+static void init_once(struct kmem_cache *cachep, void *foo)
 {
        struct socket_alloc *ei = (struct socket_alloc *)foo;
 
@@ -364,26 +364,26 @@ static int sock_alloc_fd(struct file **filep)
 
 static int sock_attach_fd(struct socket *sock, struct file *file)
 {
+       struct dentry *dentry;
        struct qstr name = { .name = "" };
 
-       file->f_path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
-       if (unlikely(!file->f_path.dentry))
+       dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
+       if (unlikely(!dentry))
                return -ENOMEM;
 
-       file->f_path.dentry->d_op = &sockfs_dentry_operations;
+       dentry->d_op = &sockfs_dentry_operations;
        /*
         * We dont want to push this dentry into global dentry hash table.
         * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
         * This permits a working /proc/$pid/fd/XXX on sockets
         */
-       file->f_path.dentry->d_flags &= ~DCACHE_UNHASHED;
-       d_instantiate(file->f_path.dentry, SOCK_INODE(sock));
-       file->f_path.mnt = mntget(sock_mnt);
-       file->f_mapping = file->f_path.dentry->d_inode->i_mapping;
+       dentry->d_flags &= ~DCACHE_UNHASHED;
+       d_instantiate(dentry, SOCK_INODE(sock));
 
        sock->file = file;
-       file->f_op = SOCK_INODE(sock)->i_fop = &socket_file_ops;
-       file->f_mode = FMODE_READ | FMODE_WRITE;
+       init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE,
+                 &socket_file_ops);
+       SOCK_INODE(sock)->i_fop = &socket_file_ops;
        file->f_flags = O_RDWR;
        file->f_pos = 0;
        file->private_data = sock;
@@ -1250,11 +1250,14 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
                goto out_release_both;
 
        fd1 = sock_alloc_fd(&newfile1);
-       if (unlikely(fd1 < 0))
+       if (unlikely(fd1 < 0)) {
+               err = fd1;
                goto out_release_both;
+       }
 
        fd2 = sock_alloc_fd(&newfile2);
        if (unlikely(fd2 < 0)) {
+               err = fd2;
                put_filp(newfile1);
                put_unused_fd(fd1);
                goto out_release_both;