blob: 711bb7a3a98e09e737c8c90c2e1d72c07af1257d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs/ioctl.c
3 *
4 * vfs operations that deal with io control
5 *
6 * Copyright (C) International Business Machines Corp., 2005
7 * Author(s): Steve French (sfrench@us.ibm.com)
8 *
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
Steve Frenchf654bac2005-04-28 22:41:04 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/fs.h>
25#include <linux/ext2_fs.h>
26#include "cifspdu.h"
27#include "cifsglob.h"
28#include "cifsproto.h"
29#include "cifs_debug.h"
Steve Frenchc67593a2005-04-28 22:41:04 -070030#include "cifsfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Steve Frenchf28ac912005-04-28 22:41:07 -070032#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034int cifs_ioctl (struct inode * inode, struct file * filep,
35 unsigned int command, unsigned long arg)
36{
37 int rc = -ENOTTY; /* strange error - but the precedent */
38#ifdef CONFIG_CIFS_POSIX
Steve Frenchf654bac2005-04-28 22:41:04 -070039 __u64 ExtAttrBits = 0;
40 __u64 ExtAttrMask = 0;
Steve Frenchf654bac2005-04-28 22:41:04 -070041#endif /* CONFIG_CIFS_POSIX */
Steve Frenchf28ac912005-04-28 22:41:07 -070042 __u64 caps;
Steve Frenchf654bac2005-04-28 22:41:04 -070043 int xid;
44 struct cifs_sb_info *cifs_sb;
45 struct cifsTconInfo *tcon;
46 struct cifsFileInfo *pSMBFile =
47 (struct cifsFileInfo *)filep->private_data;
48
49 xid = GetXid();
50
Steve Frenchf28ac912005-04-28 22:41:07 -070051 cFYI(1,("ioctl file %p cmd %u arg %lu",filep,command,arg));
52
Steve Frenchf654bac2005-04-28 22:41:04 -070053 cifs_sb = CIFS_SB(inode->i_sb);
54 tcon = cifs_sb->tcon;
Steve Frenchf654bac2005-04-28 22:41:04 -070055
Steve Frenchf654bac2005-04-28 22:41:04 -070056 if(tcon)
57 caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
58 else {
59 rc = -EIO;
60 goto cifs_ioctl_out;
61 }
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 switch(command) {
Steve Frenchf28ac912005-04-28 22:41:07 -070064 case CIFS_IOC_CHECKUMOUNT:
65 cFYI(1,("User unmount attempted"));
66 /* BB FIXME - add missing code here FIXME */
67 if(cifs_sb->mnt_uid == current->uid)
68 rc = 0;
69 else {
70 rc = -EACCES;
71 cFYI(1,("uids do not match"));
72 }
73 break;
74#ifdef CONFIG_CIFS_POSIX
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 case EXT2_IOC_GETFLAGS:
Steve Frenchf654bac2005-04-28 22:41:04 -070076 if(CIFS_UNIX_EXTATTR_CAP & caps) {
Steve Frenchf28ac912005-04-28 22:41:07 -070077 if (pSMBFile == NULL)
78 goto cifs_ioctl_out;
Steve Frenchf654bac2005-04-28 22:41:04 -070079 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
80 &ExtAttrBits, &ExtAttrMask);
81 if(rc == 0)
82 rc = put_user(ExtAttrBits &
83 EXT2_FL_USER_VISIBLE,
84 (int __user *)arg);
85 }
86 break;
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 case EXT2_IOC_SETFLAGS:
Steve Frenchf654bac2005-04-28 22:41:04 -070089 if(CIFS_UNIX_EXTATTR_CAP & caps) {
90 if(get_user(ExtAttrBits,(int __user *)arg)) {
91 rc = -EFAULT;
92 goto cifs_ioctl_out;
93 }
Steve Frenchf28ac912005-04-28 22:41:07 -070094 if (pSMBFile == NULL)
95 goto cifs_ioctl_out;
96 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
Steve Frenchf654bac2005-04-28 22:41:04 -070097 extAttrBits, &ExtAttrMask);*/
98
99 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 cFYI(1,("set flags not implemented yet"));
Steve Frenchf654bac2005-04-28 22:41:04 -0700101 break;
Steve Frenchf28ac912005-04-28 22:41:07 -0700102#endif /* CONFIG_CIFS_POSIX */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 default:
104 cFYI(1,("unsupported ioctl"));
Steve Frenchf28ac912005-04-28 22:41:07 -0700105 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 }
Steve Frenchf654bac2005-04-28 22:41:04 -0700107
108cifs_ioctl_out:
109 FreeXid(xid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 return rc;
111}