4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 * Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
6 * Modified 1998, 1999 Wolfram Pienkoss for NLS
10 #include <linux/capability.h>
11 #include <linux/compat.h>
12 #include <linux/errno.h>
14 #include <linux/ioctl.h>
15 #include <linux/time.h>
17 #include <linux/mount.h>
18 #include <linux/slab.h>
19 #include <linux/highuid.h>
20 #include <linux/vmalloc.h>
21 #include <linux/sched.h>
22 #include <linux/cred.h>
24 #include <linux/uaccess.h>
28 /* maximum limit for ncp_objectname_ioctl */
29 #define NCP_OBJECT_NAME_MAX_LEN 4096
30 /* maximum limit for ncp_privatedata_ioctl */
31 #define NCP_PRIVATE_DATA_MAX_LEN 8192
32 /* maximum negotiable packet size */
33 #define NCP_PACKET_SIZE_INTERNAL 65536
36 ncp_get_fs_info(struct ncp_server
* server
, struct inode
*inode
,
37 struct ncp_fs_info __user
*arg
)
39 struct ncp_fs_info info
;
41 if (copy_from_user(&info
, arg
, sizeof(info
)))
44 if (info
.version
!= NCP_GET_FS_INFO_VERSION
) {
45 ncp_dbg(1, "info.version invalid: %d\n", info
.version
);
48 /* TODO: info.addr = server->m.serv_addr; */
49 SET_UID(info
.mounted_uid
, from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
));
50 info
.connection
= server
->connection
;
51 info
.buffer_size
= server
->buffer_size
;
52 info
.volume_number
= NCP_FINFO(inode
)->volNumber
;
53 info
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
55 if (copy_to_user(arg
, &info
, sizeof(info
)))
61 ncp_get_fs_info_v2(struct ncp_server
* server
, struct inode
*inode
,
62 struct ncp_fs_info_v2 __user
* arg
)
64 struct ncp_fs_info_v2 info2
;
66 if (copy_from_user(&info2
, arg
, sizeof(info2
)))
69 if (info2
.version
!= NCP_GET_FS_INFO_VERSION_V2
) {
70 ncp_dbg(1, "info.version invalid: %d\n", info2
.version
);
73 info2
.mounted_uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
74 info2
.connection
= server
->connection
;
75 info2
.buffer_size
= server
->buffer_size
;
76 info2
.volume_number
= NCP_FINFO(inode
)->volNumber
;
77 info2
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
78 info2
.dummy1
= info2
.dummy2
= info2
.dummy3
= 0;
80 if (copy_to_user(arg
, &info2
, sizeof(info2
)))
86 struct compat_ncp_objectname_ioctl
90 compat_caddr_t object_name
; /* a userspace data, in most cases user name */
93 struct compat_ncp_fs_info_v2
{
107 struct compat_ncp_ioctl_request
{
113 struct compat_ncp_privatedata_ioctl
116 compat_caddr_t data
; /* ~1000 for NDS */
119 #define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct compat_ncp_fs_info_v2)
120 #define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct compat_ncp_ioctl_request)
121 #define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct compat_ncp_objectname_ioctl)
122 #define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct compat_ncp_objectname_ioctl)
123 #define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct compat_ncp_privatedata_ioctl)
124 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl)
127 ncp_get_compat_fs_info_v2(struct ncp_server
* server
, struct inode
*inode
,
128 struct compat_ncp_fs_info_v2 __user
* arg
)
130 struct compat_ncp_fs_info_v2 info2
;
132 if (copy_from_user(&info2
, arg
, sizeof(info2
)))
135 if (info2
.version
!= NCP_GET_FS_INFO_VERSION_V2
) {
136 ncp_dbg(1, "info.version invalid: %d\n", info2
.version
);
139 info2
.mounted_uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
140 info2
.connection
= server
->connection
;
141 info2
.buffer_size
= server
->buffer_size
;
142 info2
.volume_number
= NCP_FINFO(inode
)->volNumber
;
143 info2
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
144 info2
.dummy1
= info2
.dummy2
= info2
.dummy3
= 0;
146 if (copy_to_user(arg
, &info2
, sizeof(info2
)))
152 #define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16)
153 #define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32)
154 #define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64)
156 #ifdef CONFIG_NCPFS_NLS
157 /* Here we are select the iocharset and the codepage for NLS.
158 * Thanks Petr Vandrovec for idea and many hints.
161 ncp_set_charsets(struct ncp_server
* server
, struct ncp_nls_ioctl __user
*arg
)
163 struct ncp_nls_ioctl user
;
164 struct nls_table
*codepage
;
165 struct nls_table
*iocharset
;
166 struct nls_table
*oldset_io
;
167 struct nls_table
*oldset_cp
;
171 if (copy_from_user(&user
, arg
, sizeof(user
)))
175 user
.codepage
[NCP_IOCSNAME_LEN
] = 0;
176 if (!user
.codepage
[0] || !strcmp(user
.codepage
, "default"))
177 codepage
= load_nls_default();
179 codepage
= load_nls(user
.codepage
);
186 user
.iocharset
[NCP_IOCSNAME_LEN
] = 0;
187 if (!user
.iocharset
[0] || !strcmp(user
.iocharset
, "default")) {
188 iocharset
= load_nls_default();
190 } else if (!strcmp(user
.iocharset
, "utf8")) {
191 iocharset
= load_nls_default();
194 iocharset
= load_nls(user
.iocharset
);
196 unload_nls(codepage
);
202 mutex_lock(&server
->root_setup_lock
);
203 if (server
->root_setuped
) {
204 oldset_cp
= codepage
;
205 oldset_io
= iocharset
;
209 NCP_SET_FLAG(server
, NCP_FLAG_UTF8
);
211 NCP_CLR_FLAG(server
, NCP_FLAG_UTF8
);
212 oldset_cp
= server
->nls_vol
;
213 server
->nls_vol
= codepage
;
214 oldset_io
= server
->nls_io
;
215 server
->nls_io
= iocharset
;
218 mutex_unlock(&server
->root_setup_lock
);
219 unload_nls(oldset_cp
);
220 unload_nls(oldset_io
);
226 ncp_get_charsets(struct ncp_server
* server
, struct ncp_nls_ioctl __user
*arg
)
228 struct ncp_nls_ioctl user
;
231 memset(&user
, 0, sizeof(user
));
232 mutex_lock(&server
->root_setup_lock
);
233 if (server
->nls_vol
&& server
->nls_vol
->charset
) {
234 len
= strlen(server
->nls_vol
->charset
);
235 if (len
> NCP_IOCSNAME_LEN
)
236 len
= NCP_IOCSNAME_LEN
;
237 strncpy(user
.codepage
, server
->nls_vol
->charset
, len
);
238 user
.codepage
[len
] = 0;
241 if (NCP_IS_FLAG(server
, NCP_FLAG_UTF8
))
242 strcpy(user
.iocharset
, "utf8");
243 else if (server
->nls_io
&& server
->nls_io
->charset
) {
244 len
= strlen(server
->nls_io
->charset
);
245 if (len
> NCP_IOCSNAME_LEN
)
246 len
= NCP_IOCSNAME_LEN
;
247 strncpy(user
.iocharset
, server
->nls_io
->charset
, len
);
248 user
.iocharset
[len
] = 0;
250 mutex_unlock(&server
->root_setup_lock
);
252 if (copy_to_user(arg
, &user
, sizeof(user
)))
256 #endif /* CONFIG_NCPFS_NLS */
258 static long __ncp_ioctl(struct inode
*inode
, unsigned int cmd
, unsigned long arg
)
260 struct ncp_server
*server
= NCP_SERVER(inode
);
262 struct ncp_ioctl_request request
;
264 void __user
*argp
= (void __user
*)arg
;
268 case NCP_IOC_NCPREQUEST_32
:
270 case NCP_IOC_NCPREQUEST
:
272 if (cmd
== NCP_IOC_NCPREQUEST_32
) {
273 struct compat_ncp_ioctl_request request32
;
274 if (copy_from_user(&request32
, argp
, sizeof(request32
)))
276 request
.function
= request32
.function
;
277 request
.size
= request32
.size
;
278 request
.data
= compat_ptr(request32
.data
);
281 if (copy_from_user(&request
, argp
, sizeof(request
)))
284 if ((request
.function
> 255)
286 NCP_PACKET_SIZE
- sizeof(struct ncp_request_header
))) {
289 bouncebuffer
= vmalloc(NCP_PACKET_SIZE_INTERNAL
);
292 if (copy_from_user(bouncebuffer
, request
.data
, request
.size
)) {
296 ncp_lock_server(server
);
298 /* FIXME: We hack around in the server's structures
299 here to be able to use ncp_request */
301 server
->has_subfunction
= 0;
302 server
->current_size
= request
.size
;
303 memcpy(server
->packet
, bouncebuffer
, request
.size
);
305 result
= ncp_request2(server
, request
.function
,
306 bouncebuffer
, NCP_PACKET_SIZE_INTERNAL
);
310 result
= server
->reply_size
;
311 ncp_unlock_server(server
);
312 ncp_dbg(1, "copy %d bytes\n", result
);
314 if (copy_to_user(request
.data
, bouncebuffer
, result
))
319 case NCP_IOC_CONN_LOGGED_IN
:
321 if (!(server
->m
.int_flags
& NCP_IMOUNT_LOGGEDIN_POSSIBLE
))
323 mutex_lock(&server
->root_setup_lock
);
324 if (server
->root_setuped
)
327 result
= ncp_conn_logged_in(inode
->i_sb
);
329 server
->root_setuped
= 1;
331 mutex_unlock(&server
->root_setup_lock
);
334 case NCP_IOC_GET_FS_INFO
:
335 return ncp_get_fs_info(server
, inode
, argp
);
337 case NCP_IOC_GET_FS_INFO_V2
:
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
);
344 /* we have too many combinations of CONFIG_COMPAT,
345 * CONFIG_64BIT and CONFIG_UID16, so just handle
346 * any of the possible ioctls */
347 case NCP_IOC_GETMOUNTUID16
:
351 SET_UID(uid
, from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
));
352 if (put_user(uid
, (u16 __user
*)argp
))
356 case NCP_IOC_GETMOUNTUID32
:
358 uid_t uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
359 if (put_user(uid
, (u32 __user
*)argp
))
363 case NCP_IOC_GETMOUNTUID64
:
365 uid_t uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
366 if (put_user(uid
, (u64 __user
*)argp
))
370 case NCP_IOC_GETROOT
:
372 struct ncp_setroot_ioctl sr
;
375 mutex_lock(&server
->root_setup_lock
);
376 if (server
->m
.mounted_vol
[0]) {
377 struct dentry
* dentry
= inode
->i_sb
->s_root
;
380 struct inode
* s_inode
= d_inode(dentry
);
383 sr
.volNumber
= NCP_FINFO(s_inode
)->volNumber
;
384 sr
.dirEntNum
= NCP_FINFO(s_inode
)->dirEntNum
;
385 sr
.namespace = server
->name_space
[sr
.volNumber
];
388 ncp_dbg(1, "d_inode(s_root)==NULL\n");
390 ncp_dbg(1, "s_root==NULL\n");
397 mutex_unlock(&server
->root_setup_lock
);
398 if (!result
&& copy_to_user(argp
, &sr
, sizeof(sr
)))
403 case NCP_IOC_SETROOT
:
405 struct ncp_setroot_ioctl sr
;
409 struct dentry
* dentry
;
411 if (copy_from_user(&sr
, argp
, sizeof(sr
)))
413 mutex_lock(&server
->root_setup_lock
);
414 if (server
->root_setuped
)
417 if (sr
.volNumber
< 0) {
418 server
->m
.mounted_vol
[0] = 0;
419 vnum
= NCP_NUMBER_OF_VOLUMES
;
423 } else if (sr
.volNumber
>= NCP_NUMBER_OF_VOLUMES
) {
425 } else if (ncp_mount_subdir(server
, sr
.volNumber
,
426 sr
.namespace, sr
.dirEntNum
,
427 &vnum
, &de
, &dosde
)) {
433 dentry
= inode
->i_sb
->s_root
;
435 struct inode
* s_inode
= d_inode(dentry
);
438 NCP_FINFO(s_inode
)->volNumber
= vnum
;
439 NCP_FINFO(s_inode
)->dirEntNum
= de
;
440 NCP_FINFO(s_inode
)->DosDirNum
= dosde
;
441 server
->root_setuped
= 1;
443 ncp_dbg(1, "d_inode(s_root)==NULL\n");
447 ncp_dbg(1, "s_root==NULL\n");
452 mutex_unlock(&server
->root_setup_lock
);
457 #ifdef CONFIG_NCPFS_PACKET_SIGNING
458 case NCP_IOC_SIGN_INIT
:
460 struct ncp_sign_init sign
;
463 if (copy_from_user(&sign
, argp
, sizeof(sign
)))
465 ncp_lock_server(server
);
466 mutex_lock(&server
->rcv
.creq_mutex
);
468 if (server
->sign_wanted
) {
469 memcpy(server
->sign_root
,sign
.sign_root
,8);
470 memcpy(server
->sign_last
,sign
.sign_last
,16);
471 server
->sign_active
= 1;
473 /* ignore when signatures not wanted */
475 server
->sign_active
= 0;
477 mutex_unlock(&server
->rcv
.creq_mutex
);
478 ncp_unlock_server(server
);
482 case NCP_IOC_SIGN_WANTED
:
486 ncp_lock_server(server
);
487 state
= server
->sign_wanted
;
488 ncp_unlock_server(server
);
489 if (put_user(state
, (int __user
*)argp
))
494 case NCP_IOC_SET_SIGN_WANTED
:
498 /* get only low 8 bits... */
499 if (get_user(newstate
, (unsigned char __user
*)argp
))
502 ncp_lock_server(server
);
503 if (server
->sign_active
) {
504 /* cannot turn signatures OFF when active */
508 server
->sign_wanted
= newstate
!= 0;
510 ncp_unlock_server(server
);
514 #endif /* CONFIG_NCPFS_PACKET_SIGNING */
516 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
517 case NCP_IOC_LOCKUNLOCK
:
519 struct ncp_lock_ioctl rqdata
;
521 if (copy_from_user(&rqdata
, argp
, sizeof(rqdata
)))
523 if (rqdata
.origin
!= 0)
526 switch (rqdata
.cmd
) {
529 if (rqdata
.timeout
< 0)
531 if (rqdata
.timeout
== 0)
532 rqdata
.timeout
= NCP_LOCK_DEFAULT_TIMEOUT
;
533 else if (rqdata
.timeout
> NCP_LOCK_MAX_TIMEOUT
)
534 rqdata
.timeout
= NCP_LOCK_MAX_TIMEOUT
;
537 rqdata
.timeout
= NCP_LOCK_DEFAULT_TIMEOUT
; /* has no effect */
543 /* locking needs both read and write access */
544 if ((result
= ncp_make_open(inode
, O_RDWR
)) != 0)
549 if (!S_ISREG(inode
->i_mode
))
551 if (rqdata
.cmd
== NCP_LOCK_CLEAR
)
553 result
= ncp_ClearPhysicalRecord(NCP_SERVER(inode
),
554 NCP_FINFO(inode
)->file_handle
,
557 if (result
> 0) result
= 0; /* no such lock */
565 case NCP_LOCK_EX
: lockcmd
=1; break;
566 case NCP_LOCK_SH
: lockcmd
=3; break;
567 default: lockcmd
=0; break;
569 result
= ncp_LogPhysicalRecord(NCP_SERVER(inode
),
570 NCP_FINFO(inode
)->file_handle
,
575 if (result
> 0) result
= -EAGAIN
;
578 ncp_inode_close(inode
);
581 #endif /* CONFIG_NCPFS_IOCTL_LOCKING */
584 case NCP_IOC_GETOBJECTNAME_32
:
586 struct compat_ncp_objectname_ioctl user
;
589 if (copy_from_user(&user
, argp
, sizeof(user
)))
591 down_read(&server
->auth_rwsem
);
592 user
.auth_type
= server
->auth
.auth_type
;
593 outl
= user
.object_name_len
;
594 user
.object_name_len
= server
->auth
.object_name_len
;
595 if (outl
> user
.object_name_len
)
596 outl
= user
.object_name_len
;
599 if (copy_to_user(compat_ptr(user
.object_name
),
600 server
->auth
.object_name
,
604 up_read(&server
->auth_rwsem
);
605 if (!result
&& copy_to_user(argp
, &user
, sizeof(user
)))
611 case NCP_IOC_GETOBJECTNAME
:
613 struct ncp_objectname_ioctl user
;
616 if (copy_from_user(&user
, argp
, sizeof(user
)))
618 down_read(&server
->auth_rwsem
);
619 user
.auth_type
= server
->auth
.auth_type
;
620 outl
= user
.object_name_len
;
621 user
.object_name_len
= server
->auth
.object_name_len
;
622 if (outl
> user
.object_name_len
)
623 outl
= user
.object_name_len
;
626 if (copy_to_user(user
.object_name
,
627 server
->auth
.object_name
,
631 up_read(&server
->auth_rwsem
);
632 if (!result
&& copy_to_user(argp
, &user
, sizeof(user
)))
638 case NCP_IOC_SETOBJECTNAME_32
:
640 case NCP_IOC_SETOBJECTNAME
:
642 struct ncp_objectname_ioctl user
;
647 size_t oldprivatelen
;
650 if (cmd
== NCP_IOC_SETOBJECTNAME_32
) {
651 struct compat_ncp_objectname_ioctl user32
;
652 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
654 user
.auth_type
= user32
.auth_type
;
655 user
.object_name_len
= user32
.object_name_len
;
656 user
.object_name
= compat_ptr(user32
.object_name
);
659 if (copy_from_user(&user
, argp
, sizeof(user
)))
662 if (user
.object_name_len
> NCP_OBJECT_NAME_MAX_LEN
)
664 if (user
.object_name_len
) {
665 newname
= memdup_user(user
.object_name
,
666 user
.object_name_len
);
668 return PTR_ERR(newname
);
672 down_write(&server
->auth_rwsem
);
673 oldname
= server
->auth
.object_name
;
674 oldnamelen
= server
->auth
.object_name_len
;
675 oldprivate
= server
->priv
.data
;
676 oldprivatelen
= server
->priv
.len
;
677 server
->auth
.auth_type
= user
.auth_type
;
678 server
->auth
.object_name_len
= user
.object_name_len
;
679 server
->auth
.object_name
= newname
;
680 server
->priv
.len
= 0;
681 server
->priv
.data
= NULL
;
682 up_write(&server
->auth_rwsem
);
689 case NCP_IOC_GETPRIVATEDATA_32
:
691 case NCP_IOC_GETPRIVATEDATA
:
693 struct ncp_privatedata_ioctl user
;
697 if (cmd
== NCP_IOC_GETPRIVATEDATA_32
) {
698 struct compat_ncp_privatedata_ioctl user32
;
699 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
701 user
.len
= user32
.len
;
702 user
.data
= compat_ptr(user32
.data
);
705 if (copy_from_user(&user
, argp
, sizeof(user
)))
708 down_read(&server
->auth_rwsem
);
710 user
.len
= server
->priv
.len
;
711 if (outl
> user
.len
) outl
= user
.len
;
714 if (copy_to_user(user
.data
,
719 up_read(&server
->auth_rwsem
);
723 if (cmd
== NCP_IOC_GETPRIVATEDATA_32
) {
724 struct compat_ncp_privatedata_ioctl user32
;
725 user32
.len
= user
.len
;
726 user32
.data
= (unsigned long) user
.data
;
727 if (copy_to_user(argp
, &user32
, sizeof(user32
)))
731 if (copy_to_user(argp
, &user
, sizeof(user
)))
738 case NCP_IOC_SETPRIVATEDATA_32
:
740 case NCP_IOC_SETPRIVATEDATA
:
742 struct ncp_privatedata_ioctl user
;
748 if (cmd
== NCP_IOC_SETPRIVATEDATA_32
) {
749 struct compat_ncp_privatedata_ioctl user32
;
750 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
752 user
.len
= user32
.len
;
753 user
.data
= compat_ptr(user32
.data
);
756 if (copy_from_user(&user
, argp
, sizeof(user
)))
759 if (user
.len
> NCP_PRIVATE_DATA_MAX_LEN
)
762 new = memdup_user(user
.data
, user
.len
);
768 down_write(&server
->auth_rwsem
);
769 old
= server
->priv
.data
;
770 oldlen
= server
->priv
.len
;
771 server
->priv
.len
= user
.len
;
772 server
->priv
.data
= new;
773 up_write(&server
->auth_rwsem
);
778 #ifdef CONFIG_NCPFS_NLS
779 case NCP_IOC_SETCHARSETS
:
780 return ncp_set_charsets(server
, argp
);
782 case NCP_IOC_GETCHARSETS
:
783 return ncp_get_charsets(server
, argp
);
785 #endif /* CONFIG_NCPFS_NLS */
787 case NCP_IOC_SETDENTRYTTL
:
791 if (copy_from_user(&user
, argp
, sizeof(user
)))
793 /* 20 secs at most... */
796 user
= (user
* HZ
) / 1000;
797 atomic_set(&server
->dentry_ttl
, user
);
801 case NCP_IOC_GETDENTRYTTL
:
803 u_int32_t user
= (atomic_read(&server
->dentry_ttl
) * 1000) / HZ
;
804 if (copy_to_user(argp
, &user
, sizeof(user
)))
813 long ncp_ioctl(struct file
*filp
, unsigned int cmd
, unsigned long arg
)
815 struct inode
*inode
= file_inode(filp
);
816 struct ncp_server
*server
= NCP_SERVER(inode
);
817 kuid_t uid
= current_uid();
818 int need_drop_write
= 0;
822 case NCP_IOC_SETCHARSETS
:
823 case NCP_IOC_CONN_LOGGED_IN
:
824 case NCP_IOC_SETROOT
:
825 if (!capable(CAP_SYS_ADMIN
)) {
831 if (!uid_eq(server
->m
.mounted_uid
, uid
)) {
834 * Only mount owner can issue these ioctls. Information
835 * necessary to authenticate to other NDS servers are
838 case NCP_IOC_GETOBJECTNAME
:
839 case NCP_IOC_SETOBJECTNAME
:
840 case NCP_IOC_GETPRIVATEDATA
:
841 case NCP_IOC_SETPRIVATEDATA
:
843 case NCP_IOC_GETOBJECTNAME_32
:
844 case NCP_IOC_SETOBJECTNAME_32
:
845 case NCP_IOC_GETPRIVATEDATA_32
:
846 case NCP_IOC_SETPRIVATEDATA_32
:
851 * These require write access on the inode if user id
852 * does not match. Note that they do not write to the
853 * file... But old code did mnt_want_write, so I keep
854 * it as is. Of course not for mountpoint owner, as
855 * that breaks read-only mounts altogether as ncpmount
856 * needs working NCP_IOC_NCPREQUEST and
857 * NCP_IOC_GET_FS_INFO. Some of these codes (setdentryttl,
858 * signinit, setsignwanted) should be probably restricted
859 * to owner only, or even more to CAP_SYS_ADMIN).
861 case NCP_IOC_GET_FS_INFO
:
862 case NCP_IOC_GET_FS_INFO_V2
:
863 case NCP_IOC_NCPREQUEST
:
864 case NCP_IOC_SETDENTRYTTL
:
865 case NCP_IOC_SIGN_INIT
:
866 case NCP_IOC_LOCKUNLOCK
:
867 case NCP_IOC_SET_SIGN_WANTED
:
869 case NCP_IOC_GET_FS_INFO_V2_32
:
870 case NCP_IOC_NCPREQUEST_32
:
872 ret
= mnt_want_write_file(filp
);
876 ret
= inode_permission(inode
, MAY_WRITE
);
881 * Read access required.
883 case NCP_IOC_GETMOUNTUID16
:
884 case NCP_IOC_GETMOUNTUID32
:
885 case NCP_IOC_GETMOUNTUID64
:
886 case NCP_IOC_GETROOT
:
887 case NCP_IOC_SIGN_WANTED
:
888 ret
= inode_permission(inode
, MAY_READ
);
893 * Anybody can read these.
895 case NCP_IOC_GETCHARSETS
:
896 case NCP_IOC_GETDENTRYTTL
:
898 /* Three codes below are protected by CAP_SYS_ADMIN above. */
899 case NCP_IOC_SETCHARSETS
:
900 case NCP_IOC_CONN_LOGGED_IN
:
901 case NCP_IOC_SETROOT
:
905 ret
= __ncp_ioctl(inode
, cmd
, arg
);
908 mnt_drop_write_file(filp
);
914 long ncp_compat_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
918 arg
= (unsigned long) compat_ptr(arg
);
919 ret
= ncp_ioctl(file
, cmd
, arg
);