10 #include <linux/capability.h>
12 #include <linux/errno.h>
15 #include <linux/time.h>
18 #include <linux/slab.h>
21 #include <linux/sched.h>
23 #include <asm/uaccess.h>
28 #define NCP_OBJECT_NAME_MAX_LEN 4096
30 #define NCP_PRIVATE_DATA_MAX_LEN 8192
32 #define NCP_PACKET_SIZE_INTERNAL 65536
72 info2.mounted_uid = server->
m.mounted_uid;
75 info2.volume_number = NCP_FINFO(inode)->volNumber;
76 info2.directory_id = NCP_FINFO(inode)->DosDirNum;
85 struct compat_ncp_objectname_ioctl
92 struct compat_ncp_fs_info_v2 {
106 struct compat_ncp_ioctl_request {
112 struct compat_ncp_privatedata_ioctl
118 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct compat_ncp_fs_info_v2)
119 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct compat_ncp_ioctl_request)
120 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct compat_ncp_objectname_ioctl)
121 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct compat_ncp_objectname_ioctl)
122 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct compat_ncp_privatedata_ioctl)
123 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl)
126 ncp_get_compat_fs_info_v2(
struct ncp_server * server,
struct inode *inode,
127 struct compat_ncp_fs_info_v2 __user * arg)
129 struct compat_ncp_fs_info_v2
info2;
138 info2.mounted_uid = server->
m.mounted_uid;
141 info2.volume_number = NCP_FINFO(inode)->volNumber;
142 info2.directory_id = NCP_FINFO(inode)->DosDirNum;
151 #define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16)
152 #define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32)
153 #define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64)
155 #ifdef CONFIG_NCPFS_NLS
203 oldset_cp = codepage;
204 oldset_io = iocharset;
213 oldset_io = server->
nls_io;
214 server->
nls_io = iocharset;
237 user.codepage[len] = 0;
247 user.iocharset[len] = 0;
257 static long __ncp_ioctl(
struct inode *inode,
unsigned int cmd,
unsigned long arg)
267 case NCP_IOC_NCPREQUEST_32:
271 if (cmd == NCP_IOC_NCPREQUEST_32) {
272 struct compat_ncp_ioctl_request request32;
275 request.function = request32.function;
277 request.data = compat_ptr(request32.data);
311 DPRINTK(
"ncp_ioctl: copy %d bytes\n",
335 return ncp_get_fs_info(server, inode, argp);
338 return ncp_get_fs_info_v2(server, inode, argp);
341 case NCP_IOC_GET_FS_INFO_V2_32:
342 return ncp_get_compat_fs_info_v2(server, inode, argp);
351 SET_UID(uid, server->
m.mounted_uid);
373 if (server->
m.mounted_vol[0]) {
377 struct inode* s_inode = dentry->
d_inode;
380 sr.volNumber = NCP_FINFO(s_inode)->volNumber;
381 sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum;
385 DPRINTK(
"ncpfs: s_root->d_inode==NULL\n");
387 DPRINTK(
"ncpfs: s_root==NULL\n");
406 struct dentry* dentry;
414 if (
sr.volNumber < 0) {
415 server->
m.mounted_vol[0] = 0;
423 sr.namespace,
sr.dirEntNum,
424 &vnum, &de, &dosde)) {
430 dentry = inode->
i_sb->s_root;
432 struct inode* s_inode = dentry->
d_inode;
435 NCP_FINFO(s_inode)->volNumber = vnum;
436 NCP_FINFO(s_inode)->dirEntNum = de;
437 NCP_FINFO(s_inode)->DosDirNum = dosde;
440 DPRINTK(
"ncpfs: s_root->d_inode==NULL\n");
444 DPRINTK(
"ncpfs: s_root==NULL\n");
455 #ifdef CONFIG_NCPFS_PACKET_SIGNING
487 if (
put_user(state, (
int __user *)argp))
497 if (
get_user(newstate, (
unsigned char __user *)argp))
514 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
521 if (rqdata.origin != 0)
524 switch (rqdata.cmd) {
527 if (rqdata.timeout == 0)
549 result = ncp_ClearPhysicalRecord(
NCP_SERVER(inode),
553 if (result > 0) result = 0;
563 default: lockcmd=0;
break;
571 if (result > 0) result = -
EAGAIN;
574 ncp_inode_close(inode);
580 case NCP_IOC_GETOBJECTNAME_32:
582 struct compat_ncp_objectname_ioctl
user;
588 user.auth_type = server->
auth.auth_type;
589 outl =
user.object_name_len;
590 user.object_name_len = server->
auth.object_name_len;
591 if (outl >
user.object_name_len)
592 outl =
user.object_name_len;
596 server->
auth.object_name,
615 user.auth_type = server->
auth.auth_type;
616 outl =
user.object_name_len;
617 user.object_name_len = server->
auth.object_name_len;
618 if (outl >
user.object_name_len)
619 outl =
user.object_name_len;
623 server->
auth.object_name,
634 case NCP_IOC_SETOBJECTNAME_32:
643 size_t oldprivatelen;
646 if (cmd == NCP_IOC_SETOBJECTNAME_32) {
647 struct compat_ncp_objectname_ioctl
user32;
651 user.object_name_len =
user32.object_name_len;
652 user.object_name = compat_ptr(
user32.object_name);
660 if (
user.object_name_len) {
662 user.object_name_len);
664 return PTR_ERR(newname);
669 oldname = server->
auth.object_name;
670 oldnamelen = server->
auth.object_name_len;
671 oldprivate = server->
priv.data;
672 oldprivatelen = server->
priv.len;
673 server->
auth.auth_type =
user.auth_type;
674 server->
auth.object_name_len =
user.object_name_len;
675 server->
auth.object_name = newname;
676 server->
priv.len = 0;
685 case NCP_IOC_GETPRIVATEDATA_32:
693 if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
694 struct compat_ncp_privatedata_ioctl
user32;
707 if (outl >
user.len) outl =
user.len;
719 if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
720 struct compat_ncp_privatedata_ioctl
user32;
734 case NCP_IOC_SETPRIVATEDATA_32:
744 if (cmd == NCP_IOC_SETPRIVATEDATA_32) {
745 struct compat_ncp_privatedata_ioctl
user32;
765 old = server->
priv.data;
766 oldlen = server->
priv.len;
768 server->
priv.data =
new;
774 #ifdef CONFIG_NCPFS_NLS
776 return ncp_set_charsets(server, argp);
779 return ncp_get_charsets(server, argp);
792 user = (user *
HZ) / 1000;
811 struct inode *inode = filp->f_dentry->d_inode;
814 int need_drop_write = 0;
827 if (server->
m.mounted_uid != uid) {
839 case NCP_IOC_GETOBJECTNAME_32:
840 case NCP_IOC_SETOBJECTNAME_32:
841 case NCP_IOC_GETPRIVATEDATA_32:
842 case NCP_IOC_SETPRIVATEDATA_32:
865 case NCP_IOC_GET_FS_INFO_V2_32:
866 case NCP_IOC_NCPREQUEST_32:
901 ret = __ncp_ioctl(inode, cmd, arg);
914 arg = (
unsigned long) compat_ptr(arg);