This source file includes following definitions.
- ncp_ioctl
1
2
3
4
5
6
7
8 #include <asm/segment.h>
9 #include <linux/errno.h>
10 #include <linux/fs.h>
11 #include <linux/ncp_fs.h>
12 #include <linux/ioctl.h>
13 #include <linux/sched.h>
14 #include <linux/mm.h>
15 #include <linux/ncp.h>
16
17 int
18 ncp_ioctl (struct inode * inode, struct file * filp,
19 unsigned int cmd, unsigned long arg)
20 {
21 int result;
22 struct ncp_ioctl_request request;
23 struct ncp_fs_info info;
24 struct ncp_server *server = NCP_SERVER(inode);
25
26 switch(cmd) {
27 case NCP_IOC_NCPREQUEST:
28
29 if ( (permission(inode, MAY_WRITE) != 0)
30 && (current->uid != server->m.mounted_uid))
31 {
32 return -EACCES;
33 }
34
35 if ((result = verify_area(VERIFY_READ, (char *)arg,
36 sizeof(request))) != 0)
37 {
38 return result;
39 }
40
41 memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
42 sizeof(request));
43
44 if ( (request.function > 255)
45 || (request.size >
46 NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
47 {
48 return -EINVAL;
49 }
50
51 if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
52 NCP_PACKET_SIZE)) != 0)
53 {
54 return result;
55 }
56
57 ncp_lock_server(server);
58
59
60
61
62 server->has_subfunction = 0;
63 server->current_size = request.size;
64 memcpy_fromfs(server->packet, request.data, request.size);
65
66 ncp_request(server, request.function);
67
68 DPRINTK("ncp_ioctl: copy %d bytes\n",
69 server->reply_size);
70 memcpy_tofs(request.data, server->packet, server->reply_size);
71
72 ncp_unlock_server(server);
73
74 return server->reply_size;
75
76 case NCP_IOC_CONN_LOGGED_IN:
77
78 if ( (permission(inode, MAY_WRITE) != 0)
79 && (current->uid != server->m.mounted_uid))
80 {
81 return -EACCES;
82 }
83
84 return ncp_conn_logged_in(server);
85
86 case NCP_IOC_GET_FS_INFO:
87
88 if ( (permission(inode, MAY_WRITE) != 0)
89 && (current->uid != server->m.mounted_uid))
90 {
91 return -EACCES;
92 }
93
94 if ((result = verify_area(VERIFY_WRITE, (char *)arg,
95 sizeof(info))) != 0)
96 {
97 return result;
98 }
99
100 memcpy_fromfs(&info, (struct ncp_fs_info *)arg,
101 sizeof(info));
102
103 if (info.version != NCP_GET_FS_INFO_VERSION)
104 {
105 DPRINTK("info.version invalid: %d\n", info.version);
106 return -EINVAL;
107 }
108
109 info.addr = server->m.serv_addr;
110 info.mounted_uid = server->m.mounted_uid;
111 info.connection = server->connection;
112 info.buffer_size = server->buffer_size;
113
114 memcpy_tofs((struct ncp_fs_info *)arg, &info, sizeof(info));
115 return 0;
116
117 case NCP_IOC_GETMOUNTUID:
118
119 if ( (permission(inode, MAY_READ) != 0)
120 && (current->uid != server->m.mounted_uid))
121 {
122 return -EACCES;
123 }
124
125 if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
126 sizeof(uid_t))) != 0)
127 {
128 return result;
129 }
130 put_fs_word(server->m.mounted_uid, (uid_t*) arg);
131 return 0;
132
133 default:
134 return -EINVAL;
135 }
136
137 return -EINVAL;
138 }