]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/socket.c
SG: work with the SCSI fixed maximum allocations.
[linux-2.6-omap-h63xx.git] / net / socket.c
index a714c6d4e4a16c798c8b83d849469ee092bf8e01..74784dfe8e5b2b6d304c68e34e9ba4c8194123e3 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;
@@ -791,9 +791,9 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
  */
 
 static DEFINE_MUTEX(br_ioctl_mutex);
-static int (*br_ioctl_hook) (unsigned int cmd, void __user *arg) = NULL;
+static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL;
 
-void brioctl_set(int (*hook) (unsigned int, void __user *))
+void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *))
 {
        mutex_lock(&br_ioctl_mutex);
        br_ioctl_hook = hook;
@@ -803,9 +803,9 @@ void brioctl_set(int (*hook) (unsigned int, void __user *))
 EXPORT_SYMBOL(brioctl_set);
 
 static DEFINE_MUTEX(vlan_ioctl_mutex);
-static int (*vlan_ioctl_hook) (void __user *arg);
+static int (*vlan_ioctl_hook) (struct net *, void __user *arg);
 
-void vlan_ioctl_set(int (*hook) (void __user *))
+void vlan_ioctl_set(int (*hook) (struct net *, void __user *))
 {
        mutex_lock(&vlan_ioctl_mutex);
        vlan_ioctl_hook = hook;
@@ -834,16 +834,20 @@ EXPORT_SYMBOL(dlci_ioctl_set);
 static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 {
        struct socket *sock;
+       struct sock *sk;
        void __user *argp = (void __user *)arg;
        int pid, err;
+       struct net *net;
 
        sock = file->private_data;
+       sk = sock->sk;
+       net = sk->sk_net;
        if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
-               err = dev_ioctl(cmd, argp);
+               err = dev_ioctl(net, cmd, argp);
        } else
 #ifdef CONFIG_WIRELESS_EXT
        if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
-               err = dev_ioctl(cmd, argp);
+               err = dev_ioctl(net, cmd, argp);
        } else
 #endif                         /* CONFIG_WIRELESS_EXT */
                switch (cmd) {
@@ -869,7 +873,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 
                        mutex_lock(&br_ioctl_mutex);
                        if (br_ioctl_hook)
-                               err = br_ioctl_hook(cmd, argp);
+                               err = br_ioctl_hook(net, cmd, argp);
                        mutex_unlock(&br_ioctl_mutex);
                        break;
                case SIOCGIFVLAN:
@@ -880,7 +884,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 
                        mutex_lock(&vlan_ioctl_mutex);
                        if (vlan_ioctl_hook)
-                               err = vlan_ioctl_hook(argp);
+                               err = vlan_ioctl_hook(net, argp);
                        mutex_unlock(&vlan_ioctl_mutex);
                        break;
                case SIOCADDDLCI:
@@ -903,7 +907,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
                         * to the NIC driver.
                         */
                        if (err == -ENOIOCTLCMD)
-                               err = dev_ioctl(cmd, argp);
+                               err = dev_ioctl(net, cmd, argp);
                        break;
                }
        return err;
@@ -1246,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;
@@ -1925,7 +1932,7 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg,
         *      kernel msghdr to use the kernel address space)
         */
 
-       uaddr = (void __user *)msg_sys.msg_name;
+       uaddr = (__force void __user *)msg_sys.msg_name;
        uaddr_len = COMPAT_NAMELEN(msg);
        if (MSG_CMSG_COMPAT & flags) {
                err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE);
@@ -2231,6 +2238,7 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags)
        err = sock->ops->accept(sock, *newsock, flags);
        if (err < 0) {
                sock_release(*newsock);
+               *newsock = NULL;
                goto done;
        }
 
@@ -2311,6 +2319,11 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg)
        return err;
 }
 
+int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how)
+{
+       return sock->ops->shutdown(sock, how);
+}
+
 /* ABI emulation layers need these two */
 EXPORT_SYMBOL(move_addr_to_kernel);
 EXPORT_SYMBOL(move_addr_to_user);
@@ -2337,3 +2350,4 @@ EXPORT_SYMBOL(kernel_getsockopt);
 EXPORT_SYMBOL(kernel_setsockopt);
 EXPORT_SYMBOL(kernel_sendpage);
 EXPORT_SYMBOL(kernel_sock_ioctl);
+EXPORT_SYMBOL(kernel_sock_shutdown);