ioctl.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * ioctl.c
  3. *
  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
  7. *
  8. */
  9. #include <linux/config.h>
  10. #include <asm/uaccess.h>
  11. #include <linux/errno.h>
  12. #include <linux/fs.h>
  13. #include <linux/ioctl.h>
  14. #include <linux/time.h>
  15. #include <linux/mm.h>
  16. #include <linux/highuid.h>
  17. #include <linux/vmalloc.h>
  18. #include <linux/ncp_fs.h>
  19. #include "ncplib_kernel.h"
  20. /* maximum limit for ncp_objectname_ioctl */
  21. #define NCP_OBJECT_NAME_MAX_LEN 4096
  22. /* maximum limit for ncp_privatedata_ioctl */
  23. #define NCP_PRIVATE_DATA_MAX_LEN 8192
  24. /* maximum negotiable packet size */
  25. #define NCP_PACKET_SIZE_INTERNAL 65536
  26. static int
  27. ncp_get_fs_info(struct ncp_server* server, struct inode* inode, struct ncp_fs_info __user *arg)
  28. {
  29. struct ncp_fs_info info;
  30. if ((permission(inode, MAY_WRITE, NULL) != 0)
  31. && (current->uid != server->m.mounted_uid)) {
  32. return -EACCES;
  33. }
  34. if (copy_from_user(&info, arg, sizeof(info)))
  35. return -EFAULT;
  36. if (info.version != NCP_GET_FS_INFO_VERSION) {
  37. DPRINTK("info.version invalid: %d\n", info.version);
  38. return -EINVAL;
  39. }
  40. /* TODO: info.addr = server->m.serv_addr; */
  41. SET_UID(info.mounted_uid, server->m.mounted_uid);
  42. info.connection = server->connection;
  43. info.buffer_size = server->buffer_size;
  44. info.volume_number = NCP_FINFO(inode)->volNumber;
  45. info.directory_id = NCP_FINFO(inode)->DosDirNum;
  46. if (copy_to_user(arg, &info, sizeof(info)))
  47. return -EFAULT;
  48. return 0;
  49. }
  50. static int
  51. ncp_get_fs_info_v2(struct ncp_server* server, struct inode* inode, struct ncp_fs_info_v2 __user * arg)
  52. {
  53. struct ncp_fs_info_v2 info2;
  54. if ((permission(inode, MAY_WRITE, NULL) != 0)
  55. && (current->uid != server->m.mounted_uid)) {
  56. return -EACCES;
  57. }
  58. if (copy_from_user(&info2, arg, sizeof(info2)))
  59. return -EFAULT;
  60. if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
  61. DPRINTK("info.version invalid: %d\n", info2.version);
  62. return -EINVAL;
  63. }
  64. info2.mounted_uid = server->m.mounted_uid;
  65. info2.connection = server->connection;
  66. info2.buffer_size = server->buffer_size;
  67. info2.volume_number = NCP_FINFO(inode)->volNumber;
  68. info2.directory_id = NCP_FINFO(inode)->DosDirNum;
  69. info2.dummy1 = info2.dummy2 = info2.dummy3 = 0;
  70. if (copy_to_user(arg, &info2, sizeof(info2)))
  71. return -EFAULT;
  72. return 0;
  73. }
  74. #ifdef CONFIG_NCPFS_NLS
  75. /* Here we are select the iocharset and the codepage for NLS.
  76. * Thanks Petr Vandrovec for idea and many hints.
  77. */
  78. static int
  79. ncp_set_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
  80. {
  81. struct ncp_nls_ioctl user;
  82. struct nls_table *codepage;
  83. struct nls_table *iocharset;
  84. struct nls_table *oldset_io;
  85. struct nls_table *oldset_cp;
  86. if (!capable(CAP_SYS_ADMIN))
  87. return -EACCES;
  88. if (server->root_setuped)
  89. return -EBUSY;
  90. if (copy_from_user(&user, arg, sizeof(user)))
  91. return -EFAULT;
  92. codepage = NULL;
  93. user.codepage[NCP_IOCSNAME_LEN] = 0;
  94. if (!user.codepage[0] || !strcmp(user.codepage, "default"))
  95. codepage = load_nls_default();
  96. else {
  97. codepage = load_nls(user.codepage);
  98. if (!codepage) {
  99. return -EBADRQC;
  100. }
  101. }
  102. iocharset = NULL;
  103. user.iocharset[NCP_IOCSNAME_LEN] = 0;
  104. if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) {
  105. iocharset = load_nls_default();
  106. NCP_CLR_FLAG(server, NCP_FLAG_UTF8);
  107. } else if (!strcmp(user.iocharset, "utf8")) {
  108. iocharset = load_nls_default();
  109. NCP_SET_FLAG(server, NCP_FLAG_UTF8);
  110. } else {
  111. iocharset = load_nls(user.iocharset);
  112. if (!iocharset) {
  113. unload_nls(codepage);
  114. return -EBADRQC;
  115. }
  116. NCP_CLR_FLAG(server, NCP_FLAG_UTF8);
  117. }
  118. oldset_cp = server->nls_vol;
  119. server->nls_vol = codepage;
  120. oldset_io = server->nls_io;
  121. server->nls_io = iocharset;
  122. if (oldset_cp)
  123. unload_nls(oldset_cp);
  124. if (oldset_io)
  125. unload_nls(oldset_io);
  126. return 0;
  127. }
  128. static int
  129. ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
  130. {
  131. struct ncp_nls_ioctl user;
  132. int len;
  133. memset(&user, 0, sizeof(user));
  134. if (server->nls_vol && server->nls_vol->charset) {
  135. len = strlen(server->nls_vol->charset);
  136. if (len > NCP_IOCSNAME_LEN)
  137. len = NCP_IOCSNAME_LEN;
  138. strncpy(user.codepage, server->nls_vol->charset, len);
  139. user.codepage[len] = 0;
  140. }
  141. if (NCP_IS_FLAG(server, NCP_FLAG_UTF8))
  142. strcpy(user.iocharset, "utf8");
  143. else if (server->nls_io && server->nls_io->charset) {
  144. len = strlen(server->nls_io->charset);
  145. if (len > NCP_IOCSNAME_LEN)
  146. len = NCP_IOCSNAME_LEN;
  147. strncpy(user.iocharset, server->nls_io->charset, len);
  148. user.iocharset[len] = 0;
  149. }
  150. if (copy_to_user(arg, &user, sizeof(user)))
  151. return -EFAULT;
  152. return 0;
  153. }
  154. #endif /* CONFIG_NCPFS_NLS */
  155. int ncp_ioctl(struct inode *inode, struct file *filp,
  156. unsigned int cmd, unsigned long arg)
  157. {
  158. struct ncp_server *server = NCP_SERVER(inode);
  159. int result;
  160. struct ncp_ioctl_request request;
  161. char* bouncebuffer;
  162. void __user *argp = (void __user *)arg;
  163. switch (cmd) {
  164. case NCP_IOC_NCPREQUEST:
  165. if ((permission(inode, MAY_WRITE, NULL) != 0)
  166. && (current->uid != server->m.mounted_uid)) {
  167. return -EACCES;
  168. }
  169. if (copy_from_user(&request, argp, sizeof(request)))
  170. return -EFAULT;
  171. if ((request.function > 255)
  172. || (request.size >
  173. NCP_PACKET_SIZE - sizeof(struct ncp_request_header))) {
  174. return -EINVAL;
  175. }
  176. bouncebuffer = vmalloc(NCP_PACKET_SIZE_INTERNAL);
  177. if (!bouncebuffer)
  178. return -ENOMEM;
  179. if (copy_from_user(bouncebuffer, request.data, request.size)) {
  180. vfree(bouncebuffer);
  181. return -EFAULT;
  182. }
  183. ncp_lock_server(server);
  184. /* FIXME: We hack around in the server's structures
  185. here to be able to use ncp_request */
  186. server->has_subfunction = 0;
  187. server->current_size = request.size;
  188. memcpy(server->packet, bouncebuffer, request.size);
  189. result = ncp_request2(server, request.function,
  190. bouncebuffer, NCP_PACKET_SIZE_INTERNAL);
  191. if (result < 0)
  192. result = -EIO;
  193. else
  194. result = server->reply_size;
  195. ncp_unlock_server(server);
  196. DPRINTK("ncp_ioctl: copy %d bytes\n",
  197. result);
  198. if (result >= 0)
  199. if (copy_to_user(request.data, bouncebuffer, result))
  200. result = -EFAULT;
  201. vfree(bouncebuffer);
  202. return result;
  203. case NCP_IOC_CONN_LOGGED_IN:
  204. if (!capable(CAP_SYS_ADMIN))
  205. return -EACCES;
  206. if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE))
  207. return -EINVAL;
  208. if (server->root_setuped)
  209. return -EBUSY;
  210. server->root_setuped = 1;
  211. return ncp_conn_logged_in(inode->i_sb);
  212. case NCP_IOC_GET_FS_INFO:
  213. return ncp_get_fs_info(server, inode, argp);
  214. case NCP_IOC_GET_FS_INFO_V2:
  215. return ncp_get_fs_info_v2(server, inode, argp);
  216. case NCP_IOC_GETMOUNTUID2:
  217. {
  218. unsigned long tmp = server->m.mounted_uid;
  219. if ( (permission(inode, MAY_READ, NULL) != 0)
  220. && (current->uid != server->m.mounted_uid))
  221. {
  222. return -EACCES;
  223. }
  224. if (put_user(tmp, (unsigned long __user *)argp))
  225. return -EFAULT;
  226. return 0;
  227. }
  228. case NCP_IOC_GETROOT:
  229. {
  230. struct ncp_setroot_ioctl sr;
  231. if ( (permission(inode, MAY_READ, NULL) != 0)
  232. && (current->uid != server->m.mounted_uid))
  233. {
  234. return -EACCES;
  235. }
  236. if (server->m.mounted_vol[0]) {
  237. struct dentry* dentry = inode->i_sb->s_root;
  238. if (dentry) {
  239. struct inode* inode = dentry->d_inode;
  240. if (inode) {
  241. sr.volNumber = NCP_FINFO(inode)->volNumber;
  242. sr.dirEntNum = NCP_FINFO(inode)->dirEntNum;
  243. sr.namespace = server->name_space[sr.volNumber];
  244. } else
  245. DPRINTK("ncpfs: s_root->d_inode==NULL\n");
  246. } else
  247. DPRINTK("ncpfs: s_root==NULL\n");
  248. } else {
  249. sr.volNumber = -1;
  250. sr.namespace = 0;
  251. sr.dirEntNum = 0;
  252. }
  253. if (copy_to_user(argp, &sr, sizeof(sr)))
  254. return -EFAULT;
  255. return 0;
  256. }
  257. case NCP_IOC_SETROOT:
  258. {
  259. struct ncp_setroot_ioctl sr;
  260. __u32 vnum;
  261. __le32 de;
  262. __le32 dosde;
  263. struct dentry* dentry;
  264. if (!capable(CAP_SYS_ADMIN))
  265. {
  266. return -EACCES;
  267. }
  268. if (server->root_setuped) return -EBUSY;
  269. if (copy_from_user(&sr, argp, sizeof(sr)))
  270. return -EFAULT;
  271. if (sr.volNumber < 0) {
  272. server->m.mounted_vol[0] = 0;
  273. vnum = NCP_NUMBER_OF_VOLUMES;
  274. de = 0;
  275. dosde = 0;
  276. } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) {
  277. return -EINVAL;
  278. } else if (ncp_mount_subdir(server, sr.volNumber,
  279. sr.namespace, sr.dirEntNum,
  280. &vnum, &de, &dosde)) {
  281. return -ENOENT;
  282. }
  283. dentry = inode->i_sb->s_root;
  284. server->root_setuped = 1;
  285. if (dentry) {
  286. struct inode* inode = dentry->d_inode;
  287. if (inode) {
  288. NCP_FINFO(inode)->volNumber = vnum;
  289. NCP_FINFO(inode)->dirEntNum = de;
  290. NCP_FINFO(inode)->DosDirNum = dosde;
  291. } else
  292. DPRINTK("ncpfs: s_root->d_inode==NULL\n");
  293. } else
  294. DPRINTK("ncpfs: s_root==NULL\n");
  295. return 0;
  296. }
  297. #ifdef CONFIG_NCPFS_PACKET_SIGNING
  298. case NCP_IOC_SIGN_INIT:
  299. if ((permission(inode, MAY_WRITE, NULL) != 0)
  300. && (current->uid != server->m.mounted_uid))
  301. {
  302. return -EACCES;
  303. }
  304. if (argp) {
  305. if (server->sign_wanted)
  306. {
  307. struct ncp_sign_init sign;
  308. if (copy_from_user(&sign, argp, sizeof(sign)))
  309. return -EFAULT;
  310. memcpy(server->sign_root,sign.sign_root,8);
  311. memcpy(server->sign_last,sign.sign_last,16);
  312. server->sign_active = 1;
  313. }
  314. /* ignore when signatures not wanted */
  315. } else {
  316. server->sign_active = 0;
  317. }
  318. return 0;
  319. case NCP_IOC_SIGN_WANTED:
  320. if ( (permission(inode, MAY_READ, NULL) != 0)
  321. && (current->uid != server->m.mounted_uid))
  322. {
  323. return -EACCES;
  324. }
  325. if (put_user(server->sign_wanted, (int __user *)argp))
  326. return -EFAULT;
  327. return 0;
  328. case NCP_IOC_SET_SIGN_WANTED:
  329. {
  330. int newstate;
  331. if ( (permission(inode, MAY_WRITE, NULL) != 0)
  332. && (current->uid != server->m.mounted_uid))
  333. {
  334. return -EACCES;
  335. }
  336. /* get only low 8 bits... */
  337. if (get_user(newstate, (unsigned char __user *)argp))
  338. return -EFAULT;
  339. if (server->sign_active) {
  340. /* cannot turn signatures OFF when active */
  341. if (!newstate) return -EINVAL;
  342. } else {
  343. server->sign_wanted = newstate != 0;
  344. }
  345. return 0;
  346. }
  347. #endif /* CONFIG_NCPFS_PACKET_SIGNING */
  348. #ifdef CONFIG_NCPFS_IOCTL_LOCKING
  349. case NCP_IOC_LOCKUNLOCK:
  350. if ( (permission(inode, MAY_WRITE, NULL) != 0)
  351. && (current->uid != server->m.mounted_uid))
  352. {
  353. return -EACCES;
  354. }
  355. {
  356. struct ncp_lock_ioctl rqdata;
  357. int result;
  358. if (copy_from_user(&rqdata, argp, sizeof(rqdata)))
  359. return -EFAULT;
  360. if (rqdata.origin != 0)
  361. return -EINVAL;
  362. /* check for cmd */
  363. switch (rqdata.cmd) {
  364. case NCP_LOCK_EX:
  365. case NCP_LOCK_SH:
  366. if (rqdata.timeout == 0)
  367. rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT;
  368. else if (rqdata.timeout > NCP_LOCK_MAX_TIMEOUT)
  369. rqdata.timeout = NCP_LOCK_MAX_TIMEOUT;
  370. break;
  371. case NCP_LOCK_LOG:
  372. rqdata.timeout = NCP_LOCK_DEFAULT_TIMEOUT; /* has no effect */
  373. case NCP_LOCK_CLEAR:
  374. break;
  375. default:
  376. return -EINVAL;
  377. }
  378. /* locking needs both read and write access */
  379. if ((result = ncp_make_open(inode, O_RDWR)) != 0)
  380. {
  381. return result;
  382. }
  383. result = -EIO;
  384. if (!ncp_conn_valid(server))
  385. goto outrel;
  386. result = -EISDIR;
  387. if (!S_ISREG(inode->i_mode))
  388. goto outrel;
  389. if (rqdata.cmd == NCP_LOCK_CLEAR)
  390. {
  391. result = ncp_ClearPhysicalRecord(NCP_SERVER(inode),
  392. NCP_FINFO(inode)->file_handle,
  393. rqdata.offset,
  394. rqdata.length);
  395. if (result > 0) result = 0; /* no such lock */
  396. }
  397. else
  398. {
  399. int lockcmd;
  400. switch (rqdata.cmd)
  401. {
  402. case NCP_LOCK_EX: lockcmd=1; break;
  403. case NCP_LOCK_SH: lockcmd=3; break;
  404. default: lockcmd=0; break;
  405. }
  406. result = ncp_LogPhysicalRecord(NCP_SERVER(inode),
  407. NCP_FINFO(inode)->file_handle,
  408. lockcmd,
  409. rqdata.offset,
  410. rqdata.length,
  411. rqdata.timeout);
  412. if (result > 0) result = -EAGAIN;
  413. }
  414. outrel:
  415. ncp_inode_close(inode);
  416. return result;
  417. }
  418. #endif /* CONFIG_NCPFS_IOCTL_LOCKING */
  419. case NCP_IOC_GETOBJECTNAME:
  420. if (current->uid != server->m.mounted_uid) {
  421. return -EACCES;
  422. }
  423. {
  424. struct ncp_objectname_ioctl user;
  425. size_t outl;
  426. if (copy_from_user(&user, argp, sizeof(user)))
  427. return -EFAULT;
  428. user.auth_type = server->auth.auth_type;
  429. outl = user.object_name_len;
  430. user.object_name_len = server->auth.object_name_len;
  431. if (outl > user.object_name_len)
  432. outl = user.object_name_len;
  433. if (outl) {
  434. if (copy_to_user(user.object_name,
  435. server->auth.object_name,
  436. outl)) return -EFAULT;
  437. }
  438. if (copy_to_user(argp, &user, sizeof(user)))
  439. return -EFAULT;
  440. return 0;
  441. }
  442. case NCP_IOC_SETOBJECTNAME:
  443. if (current->uid != server->m.mounted_uid) {
  444. return -EACCES;
  445. }
  446. {
  447. struct ncp_objectname_ioctl user;
  448. void* newname;
  449. void* oldname;
  450. size_t oldnamelen;
  451. void* oldprivate;
  452. size_t oldprivatelen;
  453. if (copy_from_user(&user, argp, sizeof(user)))
  454. return -EFAULT;
  455. if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
  456. return -ENOMEM;
  457. if (user.object_name_len) {
  458. newname = ncp_kmalloc(user.object_name_len, GFP_USER);
  459. if (!newname) return -ENOMEM;
  460. if (copy_from_user(newname, user.object_name, user.object_name_len)) {
  461. ncp_kfree_s(newname, user.object_name_len);
  462. return -EFAULT;
  463. }
  464. } else {
  465. newname = NULL;
  466. }
  467. /* enter critical section */
  468. /* maybe that kfree can sleep so do that this way */
  469. /* it is at least more SMP friendly (in future...) */
  470. oldname = server->auth.object_name;
  471. oldnamelen = server->auth.object_name_len;
  472. oldprivate = server->priv.data;
  473. oldprivatelen = server->priv.len;
  474. server->auth.auth_type = user.auth_type;
  475. server->auth.object_name_len = user.object_name_len;
  476. server->auth.object_name = newname;
  477. server->priv.len = 0;
  478. server->priv.data = NULL;
  479. /* leave critical section */
  480. if (oldprivate) ncp_kfree_s(oldprivate, oldprivatelen);
  481. if (oldname) ncp_kfree_s(oldname, oldnamelen);
  482. return 0;
  483. }
  484. case NCP_IOC_GETPRIVATEDATA:
  485. if (current->uid != server->m.mounted_uid) {
  486. return -EACCES;
  487. }
  488. {
  489. struct ncp_privatedata_ioctl user;
  490. size_t outl;
  491. if (copy_from_user(&user, argp, sizeof(user)))
  492. return -EFAULT;
  493. outl = user.len;
  494. user.len = server->priv.len;
  495. if (outl > user.len) outl = user.len;
  496. if (outl) {
  497. if (copy_to_user(user.data,
  498. server->priv.data,
  499. outl)) return -EFAULT;
  500. }
  501. if (copy_to_user(argp, &user, sizeof(user)))
  502. return -EFAULT;
  503. return 0;
  504. }
  505. case NCP_IOC_SETPRIVATEDATA:
  506. if (current->uid != server->m.mounted_uid) {
  507. return -EACCES;
  508. }
  509. {
  510. struct ncp_privatedata_ioctl user;
  511. void* new;
  512. void* old;
  513. size_t oldlen;
  514. if (copy_from_user(&user, argp, sizeof(user)))
  515. return -EFAULT;
  516. if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
  517. return -ENOMEM;
  518. if (user.len) {
  519. new = ncp_kmalloc(user.len, GFP_USER);
  520. if (!new) return -ENOMEM;
  521. if (copy_from_user(new, user.data, user.len)) {
  522. ncp_kfree_s(new, user.len);
  523. return -EFAULT;
  524. }
  525. } else {
  526. new = NULL;
  527. }
  528. /* enter critical section */
  529. old = server->priv.data;
  530. oldlen = server->priv.len;
  531. server->priv.len = user.len;
  532. server->priv.data = new;
  533. /* leave critical section */
  534. if (old) ncp_kfree_s(old, oldlen);
  535. return 0;
  536. }
  537. #ifdef CONFIG_NCPFS_NLS
  538. case NCP_IOC_SETCHARSETS:
  539. return ncp_set_charsets(server, argp);
  540. case NCP_IOC_GETCHARSETS:
  541. return ncp_get_charsets(server, argp);
  542. #endif /* CONFIG_NCPFS_NLS */
  543. case NCP_IOC_SETDENTRYTTL:
  544. if ((permission(inode, MAY_WRITE, NULL) != 0) &&
  545. (current->uid != server->m.mounted_uid))
  546. return -EACCES;
  547. {
  548. u_int32_t user;
  549. if (copy_from_user(&user, argp, sizeof(user)))
  550. return -EFAULT;
  551. /* 20 secs at most... */
  552. if (user > 20000)
  553. return -EINVAL;
  554. user = (user * HZ) / 1000;
  555. server->dentry_ttl = user;
  556. return 0;
  557. }
  558. case NCP_IOC_GETDENTRYTTL:
  559. {
  560. u_int32_t user = (server->dentry_ttl * 1000) / HZ;
  561. if (copy_to_user(argp, &user, sizeof(user)))
  562. return -EFAULT;
  563. return 0;
  564. }
  565. }
  566. /* #ifdef CONFIG_UID16 */
  567. /* NCP_IOC_GETMOUNTUID may be same as NCP_IOC_GETMOUNTUID2,
  568. so we have this out of switch */
  569. if (cmd == NCP_IOC_GETMOUNTUID) {
  570. __kernel_uid_t uid = 0;
  571. if ((permission(inode, MAY_READ, NULL) != 0)
  572. && (current->uid != server->m.mounted_uid)) {
  573. return -EACCES;
  574. }
  575. SET_UID(uid, server->m.mounted_uid);
  576. if (put_user(uid, (__kernel_uid_t __user *)argp))
  577. return -EFAULT;
  578. return 0;
  579. }
  580. /* #endif */
  581. return -EINVAL;
  582. }