ioctl.c 2.8 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)

S
Steve French 已提交
33
int cifs_ioctl(struct inode *inode, struct file *filep,
L
Linus Torvalds 已提交
34 35 36
		unsigned int command, unsigned long arg)
{
	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 41
	__u64	ExtAttrBits = 0;
	__u64	ExtAttrMask = 0;
42
	__u64   caps;
43 44 45
	struct cifsTconInfo *tcon;
	struct cifsFileInfo *pSMBFile =
		(struct cifsFileInfo *)filep->private_data;
46
#endif /* CONFIG_CIFS_POSIX */
47 48 49

	xid = GetXid();

S
Steve French 已提交
50
	cFYI(1, ("ioctl file %p  cmd %u  arg %lu", filep, command, arg));
51

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

54 55
#ifdef CONFIG_CIFS_POSIX
	tcon = cifs_sb->tcon;
S
Steve French 已提交
56
	if (tcon)
57 58 59
		caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
	else {
		rc = -EIO;
60 61
		FreeXid(xid);
		return -EIO;
62
	}
63
#endif /* CONFIG_CIFS_POSIX */
64

S
Steve French 已提交
65
	switch (command) {
66
		case CIFS_IOC_CHECKUMOUNT:
S
Steve French 已提交
67 68
			cFYI(1, ("User unmount attempted"));
			if (cifs_sb->mnt_uid == current->uid)
69 70 71
				rc = 0;
			else {
				rc = -EACCES;
S
Steve French 已提交
72
				cFYI(1, ("uids do not match"));
73 74 75
			}
			break;
#ifdef CONFIG_CIFS_POSIX
76
		case FS_IOC_GETFLAGS:
S
Steve French 已提交
77
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
78
				if (pSMBFile == NULL)
79
					break;
80 81
				rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
					&ExtAttrBits, &ExtAttrMask);
S
Steve French 已提交
82
				if (rc == 0)
83
					rc = put_user(ExtAttrBits &
84
						FS_FL_USER_VISIBLE,
85 86 87 88
						(int __user *)arg);
			}
			break;

89
		case FS_IOC_SETFLAGS:
S
Steve French 已提交
90 91
			if (CIFS_UNIX_EXTATTR_CAP & caps) {
				if (get_user(ExtAttrBits, (int __user *)arg)) {
92
					rc = -EFAULT;
93
					break;
94
				}
95
				if (pSMBFile == NULL)
96
					break;
97
				/* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
98 99
					extAttrBits, &ExtAttrMask);*/
			}
S
Steve French 已提交
100
			cFYI(1, ("set flags not implemented yet"));
101
			break;
102
#endif /* CONFIG_CIFS_POSIX */
L
Linus Torvalds 已提交
103
		default:
S
Steve French 已提交
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
}