ioctl.c 2.8 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 *   fs/cifs/ioctl.c
 *
 *   vfs operations that deal with io control
 *
 *   Copyright (C) International Business Machines  Corp., 2005
 *   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)

L
Linus Torvalds 已提交
33 34 35 36
int cifs_ioctl (struct inode * inode, struct file * filep, 
		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();

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

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

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

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

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

	FreeXid(xid);
L
Linus Torvalds 已提交
110 111
	return rc;
}