ioctl.c 3.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5
/*
 *   fs/cifs/ioctl.c
 *
 *   vfs operations that deal with io control
 *
S
Steve French 已提交
6
 *   Copyright (C) International Business Machines  Corp., 2005,2007
L
Linus Torvalds 已提交
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
 */
23

L
Linus Torvalds 已提交
24 25 26 27 28
#include <linux/fs.h>
#include "cifspdu.h"
#include "cifsglob.h"
#include "cifsproto.h"
#include "cifs_debug.h"
29
#include "cifsfs.h"
L
Linus Torvalds 已提交
30

31 32
#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)

33
long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
L
Linus Torvalds 已提交
34
{
35
	struct inode *inode = filep->f_dentry->d_inode;
L
Linus Torvalds 已提交
36
	int rc = -ENOTTY; /* strange error - but the precedent */
37 38
	int xid;
	struct cifs_sb_info *cifs_sb;
L
Linus Torvalds 已提交
39
#ifdef CONFIG_CIFS_POSIX
40
	struct cifsFileInfo *pSMBFile = filep->private_data;
41
	struct cifs_tcon *tcon;
42 43
	__u64	ExtAttrBits = 0;
	__u64	ExtAttrMask = 0;
44
	__u64   caps;
45
#endif /* CONFIG_CIFS_POSIX */
46 47 48

	xid = GetXid();

49
	cFYI(1, "ioctl file %p  cmd %u  arg %lu", filep, command, arg);
50

51 52
	cifs_sb = CIFS_SB(inode->i_sb);

S
Steve French 已提交
53
	switch (command) {
54
		static bool warned = false;
55
		case CIFS_IOC_CHECKUMOUNT:
56 57 58 59 60 61 62
			if (!warned) {
				warned = true;
				cERROR(1, "the CIFS_IOC_CHECKMOUNT ioctl will "
					  "be deprecated in 3.7. Please "
					  "migrate away from the use of "
					  "umount.cifs");
			}
63
			cFYI(1, "User unmount attempted");
64
			if (cifs_sb->mnt_uid == current_uid())
65 66 67
				rc = 0;
			else {
				rc = -EACCES;
68
				cFYI(1, "uids do not match");
69 70 71
			}
			break;
#ifdef CONFIG_CIFS_POSIX
72
		case FS_IOC_GETFLAGS:
73 74 75 76
			if (pSMBFile == NULL)
				break;
			tcon = tlink_tcon(pSMBFile->tlink);
			caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
S
Steve French 已提交
77
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
78 79
				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
					&ExtAttrBits, &ExtAttrMask);
S
Steve French 已提交
80
				if (rc == 0)
81
					rc = put_user(ExtAttrBits &
82
						FS_FL_USER_VISIBLE,
83 84 85 86
						(int __user *)arg);
			}
			break;

87
		case FS_IOC_SETFLAGS:
88 89 90 91
			if (pSMBFile == NULL)
				break;
			tcon = tlink_tcon(pSMBFile->tlink);
			caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
S
Steve French 已提交
92 93
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
				if (get_user(ExtAttrBits, (int __user *)arg)) {
94
					rc = -EFAULT;
95
					break;
96
				}
97
				/* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
98 99
					extAttrBits, &ExtAttrMask);*/
			}
100
			cFYI(1, "set flags not implemented yet");
101
			break;
102
#endif /* CONFIG_CIFS_POSIX */
L
Linus Torvalds 已提交
103
		default:
104
			cFYI(1, "unsupported ioctl");
105
			break;
L
Linus Torvalds 已提交
106
	}
107 108

	FreeXid(xid);
L
Linus Torvalds 已提交
109
	return rc;
S
Steve French 已提交
110
}