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>
23 #include <asm/uaccess.h>
27 /* maximum limit for ncp_objectname_ioctl */
28 #define NCP_OBJECT_NAME_MAX_LEN 4096
29 /* maximum limit for ncp_privatedata_ioctl */
30 #define NCP_PRIVATE_DATA_MAX_LEN 8192
31 /* maximum negotiable packet size */
32 #define NCP_PACKET_SIZE_INTERNAL 65536
35 ncp_get_fs_info(struct ncp_server
* server
, struct inode
*inode
,
36 struct ncp_fs_info __user
*arg
)
38 struct ncp_fs_info info
;
40 if (copy_from_user(&info
, arg
, sizeof(info
)))
43 if (info
.version
!= NCP_GET_FS_INFO_VERSION
) {
44 ncp_dbg(1, "info.version invalid: %d\n", info
.version
);
47 /* TODO: info.addr = server->m.serv_addr; */
48 SET_UID(info
.mounted_uid
, from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
));
49 info
.connection
= server
->connection
;
50 info
.buffer_size
= server
->buffer_size
;
51 info
.volume_number
= NCP_FINFO(inode
)->volNumber
;
52 info
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
54 if (copy_to_user(arg
, &info
, sizeof(info
)))
60 ncp_get_fs_info_v2(struct ncp_server
* server
, struct inode
*inode
,
61 struct ncp_fs_info_v2 __user
* arg
)
63 struct ncp_fs_info_v2 info2
;
65 if (copy_from_user(&info2
, arg
, sizeof(info2
)))
68 if (info2
.version
!= NCP_GET_FS_INFO_VERSION_V2
) {
69 ncp_dbg(1, "info.version invalid: %d\n", info2
.version
);
72 info2
.mounted_uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
73 info2
.connection
= server
->connection
;
74 info2
.buffer_size
= server
->buffer_size
;
75 info2
.volume_number
= NCP_FINFO(inode
)->volNumber
;
76 info2
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
77 info2
.dummy1
= info2
.dummy2
= info2
.dummy3
= 0;
79 if (copy_to_user(arg
, &info2
, sizeof(info2
)))
85 struct compat_ncp_objectname_ioctl
89 compat_caddr_t object_name
; /* a userspace data, in most cases user name */
92 struct compat_ncp_fs_info_v2
{
106 struct compat_ncp_ioctl_request
{
112 struct compat_ncp_privatedata_ioctl
115 compat_caddr_t data
; /* ~1000 for NDS */
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
;
131 if (copy_from_user(&info2
, arg
, sizeof(info2
)))
134 if (info2
.version
!= NCP_GET_FS_INFO_VERSION_V2
) {
135 ncp_dbg(1, "info.version invalid: %d\n", info2
.version
);
138 info2
.mounted_uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
139 info2
.connection
= server
->connection
;
140 info2
.buffer_size
= server
->buffer_size
;
141 info2
.volume_number
= NCP_FINFO(inode
)->volNumber
;
142 info2
.directory_id
= NCP_FINFO(inode
)->DosDirNum
;
143 info2
.dummy1
= info2
.dummy2
= info2
.dummy3
= 0;
145 if (copy_to_user(arg
, &info2
, sizeof(info2
)))
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
156 /* Here we are select the iocharset and the codepage for NLS.
157 * Thanks Petr Vandrovec for idea and many hints.
160 ncp_set_charsets(struct ncp_server
* server
, struct ncp_nls_ioctl __user
*arg
)
162 struct ncp_nls_ioctl user
;
163 struct nls_table
*codepage
;
164 struct nls_table
*iocharset
;
165 struct nls_table
*oldset_io
;
166 struct nls_table
*oldset_cp
;
170 if (copy_from_user(&user
, arg
, sizeof(user
)))
174 user
.codepage
[NCP_IOCSNAME_LEN
] = 0;
175 if (!user
.codepage
[0] || !strcmp(user
.codepage
, "default"))
176 codepage
= load_nls_default();
178 codepage
= load_nls(user
.codepage
);
185 user
.iocharset
[NCP_IOCSNAME_LEN
] = 0;
186 if (!user
.iocharset
[0] || !strcmp(user
.iocharset
, "default")) {
187 iocharset
= load_nls_default();
189 } else if (!strcmp(user
.iocharset
, "utf8")) {
190 iocharset
= load_nls_default();
193 iocharset
= load_nls(user
.iocharset
);
195 unload_nls(codepage
);
201 mutex_lock(&server
->root_setup_lock
);
202 if (server
->root_setuped
) {
203 oldset_cp
= codepage
;
204 oldset_io
= iocharset
;
208 NCP_SET_FLAG(server
, NCP_FLAG_UTF8
);
210 NCP_CLR_FLAG(server
, NCP_FLAG_UTF8
);
211 oldset_cp
= server
->nls_vol
;
212 server
->nls_vol
= codepage
;
213 oldset_io
= server
->nls_io
;
214 server
->nls_io
= iocharset
;
217 mutex_unlock(&server
->root_setup_lock
);
218 unload_nls(oldset_cp
);
219 unload_nls(oldset_io
);
225 ncp_get_charsets(struct ncp_server
* server
, struct ncp_nls_ioctl __user
*arg
)
227 struct ncp_nls_ioctl user
;
230 memset(&user
, 0, sizeof(user
));
231 mutex_lock(&server
->root_setup_lock
);
232 if (server
->nls_vol
&& server
->nls_vol
->charset
) {
233 len
= strlen(server
->nls_vol
->charset
);
234 if (len
> NCP_IOCSNAME_LEN
)
235 len
= NCP_IOCSNAME_LEN
;
236 strncpy(user
.codepage
, server
->nls_vol
->charset
, len
);
237 user
.codepage
[len
] = 0;
240 if (NCP_IS_FLAG(server
, NCP_FLAG_UTF8
))
241 strcpy(user
.iocharset
, "utf8");
242 else if (server
->nls_io
&& server
->nls_io
->charset
) {
243 len
= strlen(server
->nls_io
->charset
);
244 if (len
> NCP_IOCSNAME_LEN
)
245 len
= NCP_IOCSNAME_LEN
;
246 strncpy(user
.iocharset
, server
->nls_io
->charset
, len
);
247 user
.iocharset
[len
] = 0;
249 mutex_unlock(&server
->root_setup_lock
);
251 if (copy_to_user(arg
, &user
, sizeof(user
)))
255 #endif /* CONFIG_NCPFS_NLS */
257 static long __ncp_ioctl(struct inode
*inode
, unsigned int cmd
, unsigned long arg
)
259 struct ncp_server
*server
= NCP_SERVER(inode
);
261 struct ncp_ioctl_request request
;
263 void __user
*argp
= (void __user
*)arg
;
267 case NCP_IOC_NCPREQUEST_32
:
269 case NCP_IOC_NCPREQUEST
:
271 if (cmd
== NCP_IOC_NCPREQUEST_32
) {
272 struct compat_ncp_ioctl_request request32
;
273 if (copy_from_user(&request32
, argp
, sizeof(request32
)))
275 request
.function
= request32
.function
;
276 request
.size
= request32
.size
;
277 request
.data
= compat_ptr(request32
.data
);
280 if (copy_from_user(&request
, argp
, sizeof(request
)))
283 if ((request
.function
> 255)
285 NCP_PACKET_SIZE
- sizeof(struct ncp_request_header
))) {
288 bouncebuffer
= vmalloc(NCP_PACKET_SIZE_INTERNAL
);
291 if (copy_from_user(bouncebuffer
, request
.data
, request
.size
)) {
295 ncp_lock_server(server
);
297 /* FIXME: We hack around in the server's structures
298 here to be able to use ncp_request */
300 server
->has_subfunction
= 0;
301 server
->current_size
= request
.size
;
302 memcpy(server
->packet
, bouncebuffer
, request
.size
);
304 result
= ncp_request2(server
, request
.function
,
305 bouncebuffer
, NCP_PACKET_SIZE_INTERNAL
);
309 result
= server
->reply_size
;
310 ncp_unlock_server(server
);
311 ncp_dbg(1, "copy %d bytes\n", result
);
313 if (copy_to_user(request
.data
, bouncebuffer
, result
))
318 case NCP_IOC_CONN_LOGGED_IN
:
320 if (!(server
->m
.int_flags
& NCP_IMOUNT_LOGGEDIN_POSSIBLE
))
322 mutex_lock(&server
->root_setup_lock
);
323 if (server
->root_setuped
)
326 result
= ncp_conn_logged_in(inode
->i_sb
);
328 server
->root_setuped
= 1;
330 mutex_unlock(&server
->root_setup_lock
);
333 case NCP_IOC_GET_FS_INFO
:
334 return ncp_get_fs_info(server
, inode
, argp
);
336 case NCP_IOC_GET_FS_INFO_V2
:
337 return ncp_get_fs_info_v2(server
, inode
, argp
);
340 case NCP_IOC_GET_FS_INFO_V2_32
:
341 return ncp_get_compat_fs_info_v2(server
, inode
, argp
);
343 /* we have too many combinations of CONFIG_COMPAT,
344 * CONFIG_64BIT and CONFIG_UID16, so just handle
345 * any of the possible ioctls */
346 case NCP_IOC_GETMOUNTUID16
:
350 SET_UID(uid
, from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
));
351 if (put_user(uid
, (u16 __user
*)argp
))
355 case NCP_IOC_GETMOUNTUID32
:
357 uid_t uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
358 if (put_user(uid
, (u32 __user
*)argp
))
362 case NCP_IOC_GETMOUNTUID64
:
364 uid_t uid
= from_kuid_munged(current_user_ns(), server
->m
.mounted_uid
);
365 if (put_user(uid
, (u64 __user
*)argp
))
369 case NCP_IOC_GETROOT
:
371 struct ncp_setroot_ioctl sr
;
374 mutex_lock(&server
->root_setup_lock
);
375 if (server
->m
.mounted_vol
[0]) {
376 struct dentry
* dentry
= inode
->i_sb
->s_root
;
379 struct inode
* s_inode
= d_inode(dentry
);
382 sr
.volNumber
= NCP_FINFO(s_inode
)->volNumber
;
383 sr
.dirEntNum
= NCP_FINFO(s_inode
)->dirEntNum
;
384 sr
.namespace = server
->name_space
[sr
.volNumber
];
387 ncp_dbg(1, "d_inode(s_root)==NULL\n");
389 ncp_dbg(1, "s_root==NULL\n");
396 mutex_unlock(&server
->root_setup_lock
);
397 if (!result
&& copy_to_user(argp
, &sr
, sizeof(sr
)))
402 case NCP_IOC_SETROOT
:
404 struct ncp_setroot_ioctl sr
;
408 struct dentry
* dentry
;
410 if (copy_from_user(&sr
, argp
, sizeof(sr
)))
412 mutex_lock(&server
->root_setup_lock
);
413 if (server
->root_setuped
)
416 if (sr
.volNumber
< 0) {
417 server
->m
.mounted_vol
[0] = 0;
418 vnum
= NCP_NUMBER_OF_VOLUMES
;
422 } else if (sr
.volNumber
>= NCP_NUMBER_OF_VOLUMES
) {
424 } else if (ncp_mount_subdir(server
, sr
.volNumber
,
425 sr
.namespace, sr
.dirEntNum
,
426 &vnum
, &de
, &dosde
)) {
432 dentry
= inode
->i_sb
->s_root
;
434 struct inode
* s_inode
= d_inode(dentry
);
437 NCP_FINFO(s_inode
)->volNumber
= vnum
;
438 NCP_FINFO(s_inode
)->dirEntNum
= de
;
439 NCP_FINFO(s_inode
)->DosDirNum
= dosde
;
440 server
->root_setuped
= 1;
442 ncp_dbg(1, "d_inode(s_root)==NULL\n");
446 ncp_dbg(1, "s_root==NULL\n");
451 mutex_unlock(&server
->root_setup_lock
);
456 #ifdef CONFIG_NCPFS_PACKET_SIGNING
457 case NCP_IOC_SIGN_INIT
:
459 struct ncp_sign_init sign
;
462 if (copy_from_user(&sign
, argp
, sizeof(sign
)))
464 ncp_lock_server(server
);
465 mutex_lock(&server
->rcv
.creq_mutex
);
467 if (server
->sign_wanted
) {
468 memcpy(server
->sign_root
,sign
.sign_root
,8);
469 memcpy(server
->sign_last
,sign
.sign_last
,16);
470 server
->sign_active
= 1;
472 /* ignore when signatures not wanted */
474 server
->sign_active
= 0;
476 mutex_unlock(&server
->rcv
.creq_mutex
);
477 ncp_unlock_server(server
);
481 case NCP_IOC_SIGN_WANTED
:
485 ncp_lock_server(server
);
486 state
= server
->sign_wanted
;
487 ncp_unlock_server(server
);
488 if (put_user(state
, (int __user
*)argp
))
493 case NCP_IOC_SET_SIGN_WANTED
:
497 /* get only low 8 bits... */
498 if (get_user(newstate
, (unsigned char __user
*)argp
))
501 ncp_lock_server(server
);
502 if (server
->sign_active
) {
503 /* cannot turn signatures OFF when active */
507 server
->sign_wanted
= newstate
!= 0;
509 ncp_unlock_server(server
);
513 #endif /* CONFIG_NCPFS_PACKET_SIGNING */
515 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
516 case NCP_IOC_LOCKUNLOCK
:
518 struct ncp_lock_ioctl rqdata
;
520 if (copy_from_user(&rqdata
, argp
, sizeof(rqdata
)))
522 if (rqdata
.origin
!= 0)
525 switch (rqdata
.cmd
) {
528 if (rqdata
.timeout
== 0)
529 rqdata
.timeout
= NCP_LOCK_DEFAULT_TIMEOUT
;
530 else if (rqdata
.timeout
> NCP_LOCK_MAX_TIMEOUT
)
531 rqdata
.timeout
= NCP_LOCK_MAX_TIMEOUT
;
534 rqdata
.timeout
= NCP_LOCK_DEFAULT_TIMEOUT
; /* has no effect */
540 /* locking needs both read and write access */
541 if ((result
= ncp_make_open(inode
, O_RDWR
)) != 0)
546 if (!S_ISREG(inode
->i_mode
))
548 if (rqdata
.cmd
== NCP_LOCK_CLEAR
)
550 result
= ncp_ClearPhysicalRecord(NCP_SERVER(inode
),
551 NCP_FINFO(inode
)->file_handle
,
554 if (result
> 0) result
= 0; /* no such lock */
562 case NCP_LOCK_EX
: lockcmd
=1; break;
563 case NCP_LOCK_SH
: lockcmd
=3; break;
564 default: lockcmd
=0; break;
566 result
= ncp_LogPhysicalRecord(NCP_SERVER(inode
),
567 NCP_FINFO(inode
)->file_handle
,
572 if (result
> 0) result
= -EAGAIN
;
575 ncp_inode_close(inode
);
578 #endif /* CONFIG_NCPFS_IOCTL_LOCKING */
581 case NCP_IOC_GETOBJECTNAME_32
:
583 struct compat_ncp_objectname_ioctl user
;
586 if (copy_from_user(&user
, argp
, sizeof(user
)))
588 down_read(&server
->auth_rwsem
);
589 user
.auth_type
= server
->auth
.auth_type
;
590 outl
= user
.object_name_len
;
591 user
.object_name_len
= server
->auth
.object_name_len
;
592 if (outl
> user
.object_name_len
)
593 outl
= user
.object_name_len
;
596 if (copy_to_user(compat_ptr(user
.object_name
),
597 server
->auth
.object_name
,
601 up_read(&server
->auth_rwsem
);
602 if (!result
&& copy_to_user(argp
, &user
, sizeof(user
)))
608 case NCP_IOC_GETOBJECTNAME
:
610 struct ncp_objectname_ioctl user
;
613 if (copy_from_user(&user
, argp
, sizeof(user
)))
615 down_read(&server
->auth_rwsem
);
616 user
.auth_type
= server
->auth
.auth_type
;
617 outl
= user
.object_name_len
;
618 user
.object_name_len
= server
->auth
.object_name_len
;
619 if (outl
> user
.object_name_len
)
620 outl
= user
.object_name_len
;
623 if (copy_to_user(user
.object_name
,
624 server
->auth
.object_name
,
628 up_read(&server
->auth_rwsem
);
629 if (!result
&& copy_to_user(argp
, &user
, sizeof(user
)))
635 case NCP_IOC_SETOBJECTNAME_32
:
637 case NCP_IOC_SETOBJECTNAME
:
639 struct ncp_objectname_ioctl user
;
644 size_t oldprivatelen
;
647 if (cmd
== NCP_IOC_SETOBJECTNAME_32
) {
648 struct compat_ncp_objectname_ioctl user32
;
649 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
651 user
.auth_type
= user32
.auth_type
;
652 user
.object_name_len
= user32
.object_name_len
;
653 user
.object_name
= compat_ptr(user32
.object_name
);
656 if (copy_from_user(&user
, argp
, sizeof(user
)))
659 if (user
.object_name_len
> NCP_OBJECT_NAME_MAX_LEN
)
661 if (user
.object_name_len
) {
662 newname
= memdup_user(user
.object_name
,
663 user
.object_name_len
);
665 return PTR_ERR(newname
);
669 down_write(&server
->auth_rwsem
);
670 oldname
= server
->auth
.object_name
;
671 oldnamelen
= server
->auth
.object_name_len
;
672 oldprivate
= server
->priv
.data
;
673 oldprivatelen
= server
->priv
.len
;
674 server
->auth
.auth_type
= user
.auth_type
;
675 server
->auth
.object_name_len
= user
.object_name_len
;
676 server
->auth
.object_name
= newname
;
677 server
->priv
.len
= 0;
678 server
->priv
.data
= NULL
;
679 up_write(&server
->auth_rwsem
);
686 case NCP_IOC_GETPRIVATEDATA_32
:
688 case NCP_IOC_GETPRIVATEDATA
:
690 struct ncp_privatedata_ioctl user
;
694 if (cmd
== NCP_IOC_GETPRIVATEDATA_32
) {
695 struct compat_ncp_privatedata_ioctl user32
;
696 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
698 user
.len
= user32
.len
;
699 user
.data
= compat_ptr(user32
.data
);
702 if (copy_from_user(&user
, argp
, sizeof(user
)))
705 down_read(&server
->auth_rwsem
);
707 user
.len
= server
->priv
.len
;
708 if (outl
> user
.len
) outl
= user
.len
;
711 if (copy_to_user(user
.data
,
716 up_read(&server
->auth_rwsem
);
720 if (cmd
== NCP_IOC_GETPRIVATEDATA_32
) {
721 struct compat_ncp_privatedata_ioctl user32
;
722 user32
.len
= user
.len
;
723 user32
.data
= (unsigned long) user
.data
;
724 if (copy_to_user(argp
, &user32
, sizeof(user32
)))
728 if (copy_to_user(argp
, &user
, sizeof(user
)))
735 case NCP_IOC_SETPRIVATEDATA_32
:
737 case NCP_IOC_SETPRIVATEDATA
:
739 struct ncp_privatedata_ioctl user
;
745 if (cmd
== NCP_IOC_SETPRIVATEDATA_32
) {
746 struct compat_ncp_privatedata_ioctl user32
;
747 if (copy_from_user(&user32
, argp
, sizeof(user32
)))
749 user
.len
= user32
.len
;
750 user
.data
= compat_ptr(user32
.data
);
753 if (copy_from_user(&user
, argp
, sizeof(user
)))
756 if (user
.len
> NCP_PRIVATE_DATA_MAX_LEN
)
759 new = memdup_user(user
.data
, user
.len
);
765 down_write(&server
->auth_rwsem
);
766 old
= server
->priv
.data
;
767 oldlen
= server
->priv
.len
;
768 server
->priv
.len
= user
.len
;
769 server
->priv
.data
= new;
770 up_write(&server
->auth_rwsem
);
775 #ifdef CONFIG_NCPFS_NLS
776 case NCP_IOC_SETCHARSETS
:
777 return ncp_set_charsets(server
, argp
);
779 case NCP_IOC_GETCHARSETS
:
780 return ncp_get_charsets(server
, argp
);
782 #endif /* CONFIG_NCPFS_NLS */
784 case NCP_IOC_SETDENTRYTTL
:
788 if (copy_from_user(&user
, argp
, sizeof(user
)))
790 /* 20 secs at most... */
793 user
= (user
* HZ
) / 1000;
794 atomic_set(&server
->dentry_ttl
, user
);
798 case NCP_IOC_GETDENTRYTTL
:
800 u_int32_t user
= (atomic_read(&server
->dentry_ttl
) * 1000) / HZ
;
801 if (copy_to_user(argp
, &user
, sizeof(user
)))
810 long ncp_ioctl(struct file
*filp
, unsigned int cmd
, unsigned long arg
)
812 struct inode
*inode
= file_inode(filp
);
813 struct ncp_server
*server
= NCP_SERVER(inode
);
814 kuid_t uid
= current_uid();
815 int need_drop_write
= 0;
819 case NCP_IOC_SETCHARSETS
:
820 case NCP_IOC_CONN_LOGGED_IN
:
821 case NCP_IOC_SETROOT
:
822 if (!capable(CAP_SYS_ADMIN
)) {
828 if (!uid_eq(server
->m
.mounted_uid
, uid
)) {
831 * Only mount owner can issue these ioctls. Information
832 * necessary to authenticate to other NDS servers are
835 case NCP_IOC_GETOBJECTNAME
:
836 case NCP_IOC_SETOBJECTNAME
:
837 case NCP_IOC_GETPRIVATEDATA
:
838 case NCP_IOC_SETPRIVATEDATA
:
840 case NCP_IOC_GETOBJECTNAME_32
:
841 case NCP_IOC_SETOBJECTNAME_32
:
842 case NCP_IOC_GETPRIVATEDATA_32
:
843 case NCP_IOC_SETPRIVATEDATA_32
:
848 * These require write access on the inode if user id
849 * does not match. Note that they do not write to the
850 * file... But old code did mnt_want_write, so I keep
851 * it as is. Of course not for mountpoint owner, as
852 * that breaks read-only mounts altogether as ncpmount
853 * needs working NCP_IOC_NCPREQUEST and
854 * NCP_IOC_GET_FS_INFO. Some of these codes (setdentryttl,
855 * signinit, setsignwanted) should be probably restricted
856 * to owner only, or even more to CAP_SYS_ADMIN).
858 case NCP_IOC_GET_FS_INFO
:
859 case NCP_IOC_GET_FS_INFO_V2
:
860 case NCP_IOC_NCPREQUEST
:
861 case NCP_IOC_SETDENTRYTTL
:
862 case NCP_IOC_SIGN_INIT
:
863 case NCP_IOC_LOCKUNLOCK
:
864 case NCP_IOC_SET_SIGN_WANTED
:
866 case NCP_IOC_GET_FS_INFO_V2_32
:
867 case NCP_IOC_NCPREQUEST_32
:
869 ret
= mnt_want_write_file(filp
);
873 ret
= inode_permission(inode
, MAY_WRITE
);
878 * Read access required.
880 case NCP_IOC_GETMOUNTUID16
:
881 case NCP_IOC_GETMOUNTUID32
:
882 case NCP_IOC_GETMOUNTUID64
:
883 case NCP_IOC_GETROOT
:
884 case NCP_IOC_SIGN_WANTED
:
885 ret
= inode_permission(inode
, MAY_READ
);
890 * Anybody can read these.
892 case NCP_IOC_GETCHARSETS
:
893 case NCP_IOC_GETDENTRYTTL
:
895 /* Three codes below are protected by CAP_SYS_ADMIN above. */
896 case NCP_IOC_SETCHARSETS
:
897 case NCP_IOC_CONN_LOGGED_IN
:
898 case NCP_IOC_SETROOT
:
902 ret
= __ncp_ioctl(inode
, cmd
, arg
);
905 mnt_drop_write_file(filp
);
911 long ncp_compat_ioctl(struct file
*file
, unsigned int cmd
, unsigned long arg
)
915 arg
= (unsigned long) compat_ptr(arg
);
916 ret
= ncp_ioctl(file
, cmd
, arg
);