Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ioctl.c |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996 by Volker Lendecke |
| 5 | * Copyright (C) 1997 by Volker Lendecke |
| 6 | * |
| 7 | * Please add a note about your changes to smbfs in the ChangeLog file. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/fs.h> |
| 12 | #include <linux/ioctl.h> |
| 13 | #include <linux/time.h> |
| 14 | #include <linux/mm.h> |
| 15 | #include <linux/highuid.h> |
Arnd Bergmann | ce8273a | 2010-04-27 16:24:25 +0200 | [diff] [blame] | 16 | #include <linux/smp_lock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/net.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/uaccess.h> |
| 20 | |
Arnd Bergmann | 2116b7a | 2010-10-04 22:55:57 +0200 | [diff] [blame] | 21 | #include "smb_fs.h" |
| 22 | #include "smb_mount.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "proto.h" |
| 24 | |
Arnd Bergmann | ce8273a | 2010-04-27 16:24:25 +0200 | [diff] [blame] | 25 | long |
| 26 | smb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Arnd Bergmann | ce8273a | 2010-04-27 16:24:25 +0200 | [diff] [blame] | 28 | struct smb_sb_info *server = server_from_inode(filp->f_path.dentry->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | struct smb_conn_opt opt; |
| 30 | int result = -EINVAL; |
| 31 | |
Arnd Bergmann | ce8273a | 2010-04-27 16:24:25 +0200 | [diff] [blame] | 32 | lock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | switch (cmd) { |
| 34 | uid16_t uid16; |
| 35 | uid_t uid32; |
| 36 | case SMB_IOC_GETMOUNTUID: |
| 37 | SET_UID(uid16, server->mnt->mounted_uid); |
| 38 | result = put_user(uid16, (uid16_t __user *) arg); |
| 39 | break; |
| 40 | case SMB_IOC_GETMOUNTUID32: |
| 41 | SET_UID(uid32, server->mnt->mounted_uid); |
| 42 | result = put_user(uid32, (uid_t __user *) arg); |
| 43 | break; |
| 44 | |
| 45 | case SMB_IOC_NEWCONN: |
| 46 | /* arg is smb_conn_opt, or NULL if no connection was made */ |
| 47 | if (!arg) { |
| 48 | result = 0; |
| 49 | smb_lock_server(server); |
| 50 | server->state = CONN_RETRIED; |
| 51 | printk(KERN_ERR "Connection attempt failed! [%d]\n", |
| 52 | server->conn_error); |
| 53 | smbiod_flush(server); |
| 54 | smb_unlock_server(server); |
| 55 | break; |
| 56 | } |
| 57 | |
| 58 | result = -EFAULT; |
| 59 | if (!copy_from_user(&opt, (void __user *)arg, sizeof(opt))) |
| 60 | result = smb_newconn(server, &opt); |
| 61 | break; |
| 62 | default: |
| 63 | break; |
| 64 | } |
Arnd Bergmann | ce8273a | 2010-04-27 16:24:25 +0200 | [diff] [blame] | 65 | unlock_kernel(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | return result; |
| 68 | } |