Blame view

fs/cifs/ioctl.c 2.82 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
  /*
   *   fs/cifs/ioctl.c
   *
   *   vfs operations that deal with io control
   *
fb8c4b14d   Steve French   [CIFS] whitespace...
6
   *   Copyright (C) International Business Machines  Corp., 2005,2007
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
   *   Author(s): Steve French (sfrench@us.ibm.com)
   *
   *   This library is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU Lesser General Public License as published
   *   by the Free Software Foundation; either version 2.1 of the License, or
   *   (at your option) any later version.
   *
   *   This library is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   *   the GNU Lesser General Public License for more details.
   *
   *   You should have received a copy of the GNU Lesser General Public License
   *   along with this library; if not, write to the Free Software
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
f654bac22   Steve French   [PATCH] cifs: add...
23

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  #include <linux/fs.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
  #include "cifspdu.h"
  #include "cifsglob.h"
  #include "cifsproto.h"
  #include "cifs_debug.h"
c67593a03   Steve French   [PATCH] cifs: Ena...
29
  #include "cifsfs.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

f28ac91b0   Steve French   [PATCH] cifs: CIF...
31
  #define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
f9ddcca4c   Steve French   [CIFS] BKL-remova...
32
  long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
  {
f9ddcca4c   Steve French   [CIFS] BKL-remova...
34
  	struct inode *inode = filep->f_dentry->d_inode;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
  	int rc = -ENOTTY; /* strange error - but the precedent */
c81156dd2   Steve French   [PATCH] cifs: cle...
36
37
  	int xid;
  	struct cifs_sb_info *cifs_sb;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
  #ifdef CONFIG_CIFS_POSIX
f654bac22   Steve French   [PATCH] cifs: add...
39
40
  	__u64	ExtAttrBits = 0;
  	__u64	ExtAttrMask = 0;
f28ac91b0   Steve French   [PATCH] cifs: CIF...
41
  	__u64   caps;
f654bac22   Steve French   [PATCH] cifs: add...
42
  	struct cifsTconInfo *tcon;
c21dfb699   Joe Perches   fs/cifs: Remove u...
43
  	struct cifsFileInfo *pSMBFile = filep->private_data;
c81156dd2   Steve French   [PATCH] cifs: cle...
44
  #endif /* CONFIG_CIFS_POSIX */
f654bac22   Steve French   [PATCH] cifs: add...
45
46
  
  	xid = GetXid();
b6b38f704   Joe Perches   [CIFS] Neaten cER...
47
  	cFYI(1, "ioctl file %p  cmd %u  arg %lu", filep, command, arg);
f28ac91b0   Steve French   [PATCH] cifs: CIF...
48

f654bac22   Steve French   [PATCH] cifs: add...
49
  	cifs_sb = CIFS_SB(inode->i_sb);
f654bac22   Steve French   [PATCH] cifs: add...
50

c81156dd2   Steve French   [PATCH] cifs: cle...
51
52
  #ifdef CONFIG_CIFS_POSIX
  	tcon = cifs_sb->tcon;
5fdae1f68   Steve French   [CIFS] whitespace...
53
  	if (tcon)
f654bac22   Steve French   [PATCH] cifs: add...
54
55
56
  		caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
  	else {
  		rc = -EIO;
c81156dd2   Steve French   [PATCH] cifs: cle...
57
58
  		FreeXid(xid);
  		return -EIO;
f654bac22   Steve French   [PATCH] cifs: add...
59
  	}
c81156dd2   Steve French   [PATCH] cifs: cle...
60
  #endif /* CONFIG_CIFS_POSIX */
f654bac22   Steve French   [PATCH] cifs: add...
61

5fdae1f68   Steve French   [CIFS] whitespace...
62
  	switch (command) {
f28ac91b0   Steve French   [PATCH] cifs: CIF...
63
  		case CIFS_IOC_CHECKUMOUNT:
b6b38f704   Joe Perches   [CIFS] Neaten cER...
64
  			cFYI(1, "User unmount attempted");
a001e5b55   David Howells   CRED: Wrap task c...
65
  			if (cifs_sb->mnt_uid == current_uid())
f28ac91b0   Steve French   [PATCH] cifs: CIF...
66
67
68
  				rc = 0;
  			else {
  				rc = -EACCES;
b6b38f704   Joe Perches   [CIFS] Neaten cER...
69
  				cFYI(1, "uids do not match");
f28ac91b0   Steve French   [PATCH] cifs: CIF...
70
71
72
  			}
  			break;
  #ifdef CONFIG_CIFS_POSIX
36695673b   David Howells   [PATCH] BLOCK: Mo...
73
  		case FS_IOC_GETFLAGS:
5fdae1f68   Steve French   [CIFS] whitespace...
74
  			if (CIFS_UNIX_EXTATTR_CAP & caps) {
f28ac91b0   Steve French   [PATCH] cifs: CIF...
75
  				if (pSMBFile == NULL)
c81156dd2   Steve French   [PATCH] cifs: cle...
76
  					break;
f654bac22   Steve French   [PATCH] cifs: add...
77
78
  				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
  					&ExtAttrBits, &ExtAttrMask);
5fdae1f68   Steve French   [CIFS] whitespace...
79
  				if (rc == 0)
f654bac22   Steve French   [PATCH] cifs: add...
80
  					rc = put_user(ExtAttrBits &
36695673b   David Howells   [PATCH] BLOCK: Mo...
81
  						FS_FL_USER_VISIBLE,
f654bac22   Steve French   [PATCH] cifs: add...
82
83
84
  						(int __user *)arg);
  			}
  			break;
36695673b   David Howells   [PATCH] BLOCK: Mo...
85
  		case FS_IOC_SETFLAGS:
5fdae1f68   Steve French   [CIFS] whitespace...
86
87
  			if (CIFS_UNIX_EXTATTR_CAP & caps) {
  				if (get_user(ExtAttrBits, (int __user *)arg)) {
f654bac22   Steve French   [PATCH] cifs: add...
88
  					rc = -EFAULT;
c81156dd2   Steve French   [PATCH] cifs: cle...
89
  					break;
f654bac22   Steve French   [PATCH] cifs: add...
90
  				}
f28ac91b0   Steve French   [PATCH] cifs: CIF...
91
  				if (pSMBFile == NULL)
c81156dd2   Steve French   [PATCH] cifs: cle...
92
  					break;
f28ac91b0   Steve French   [PATCH] cifs: CIF...
93
  				/* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
f654bac22   Steve French   [PATCH] cifs: add...
94
  					extAttrBits, &ExtAttrMask);*/
f654bac22   Steve French   [PATCH] cifs: add...
95
  			}
b6b38f704   Joe Perches   [CIFS] Neaten cER...
96
  			cFYI(1, "set flags not implemented yet");
f654bac22   Steve French   [PATCH] cifs: add...
97
  			break;
f28ac91b0   Steve French   [PATCH] cifs: CIF...
98
  #endif /* CONFIG_CIFS_POSIX */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99
  		default:
b6b38f704   Joe Perches   [CIFS] Neaten cER...
100
  			cFYI(1, "unsupported ioctl");
f28ac91b0   Steve French   [PATCH] cifs: CIF...
101
  			break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
  	}
f654bac22   Steve French   [PATCH] cifs: add...
103

f654bac22   Steve French   [PATCH] cifs: add...
104
  	FreeXid(xid);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
105
  	return rc;
5fdae1f68   Steve French   [CIFS] whitespace...
106
  }