root.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /* -*- linux-c -*- --------------------------------------------------------- *
  2. *
  3. * linux/fs/autofs/root.c
  4. *
  5. * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
  6. *
  7. * This file is part of the Linux kernel and is made available under
  8. * the terms of the GNU General Public License, version 2, or at your
  9. * option, any later version, incorporated herein by reference.
  10. *
  11. * ------------------------------------------------------------------------- */
  12. #include <linux/capability.h>
  13. #include <linux/errno.h>
  14. #include <linux/stat.h>
  15. #include <linux/slab.h>
  16. #include <linux/param.h>
  17. #include <linux/time.h>
  18. #include <linux/compat.h>
  19. #include <linux/smp_lock.h>
  20. #include "autofs_i.h"
  21. static int autofs_root_readdir(struct file *,void *,filldir_t);
  22. static struct dentry *autofs_root_lookup(struct inode *,struct dentry *, struct nameidata *);
  23. static int autofs_root_symlink(struct inode *,struct dentry *,const char *);
  24. static int autofs_root_unlink(struct inode *,struct dentry *);
  25. static int autofs_root_rmdir(struct inode *,struct dentry *);
  26. static int autofs_root_mkdir(struct inode *,struct dentry *,int);
  27. static long autofs_root_ioctl(struct file *,unsigned int,unsigned long);
  28. #ifdef CONFIG_COMPAT
  29. static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long);
  30. #endif
  31. const struct file_operations autofs_root_operations = {
  32. .llseek = generic_file_llseek,
  33. .read = generic_read_dir,
  34. .readdir = autofs_root_readdir,
  35. .unlocked_ioctl = autofs_root_ioctl,
  36. #ifdef CONFIG_COMPAT
  37. .compat_ioctl = autofs_root_compat_ioctl,
  38. #endif
  39. };
  40. const struct inode_operations autofs_root_inode_operations = {
  41. .lookup = autofs_root_lookup,
  42. .unlink = autofs_root_unlink,
  43. .symlink = autofs_root_symlink,
  44. .mkdir = autofs_root_mkdir,
  45. .rmdir = autofs_root_rmdir,
  46. };
  47. static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldir)
  48. {
  49. struct autofs_dir_ent *ent = NULL;
  50. struct autofs_dirhash *dirhash;
  51. struct autofs_sb_info *sbi;
  52. struct inode * inode = filp->f_path.dentry->d_inode;
  53. off_t onr, nr;
  54. lock_kernel();
  55. sbi = autofs_sbi(inode->i_sb);
  56. dirhash = &sbi->dirhash;
  57. nr = filp->f_pos;
  58. switch(nr)
  59. {
  60. case 0:
  61. if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
  62. goto out;
  63. filp->f_pos = ++nr;
  64. /* fall through */
  65. case 1:
  66. if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
  67. goto out;
  68. filp->f_pos = ++nr;
  69. /* fall through */
  70. default:
  71. while (onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent)) {
  72. if (!ent->dentry || d_mountpoint(ent->dentry)) {
  73. if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0)
  74. goto out;
  75. filp->f_pos = nr;
  76. }
  77. }
  78. break;
  79. }
  80. out:
  81. unlock_kernel();
  82. return 0;
  83. }
  84. static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, struct autofs_sb_info *sbi)
  85. {
  86. struct inode * inode;
  87. struct autofs_dir_ent *ent;
  88. int status = 0;
  89. if (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name))) {
  90. do {
  91. if (status && dentry->d_inode) {
  92. if (status != -ENOENT)
  93. printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name);
  94. return 0; /* Try to get the kernel to invalidate this dentry */
  95. }
  96. /* Turn this into a real negative dentry? */
  97. if (status == -ENOENT) {
  98. dentry->d_time = jiffies + AUTOFS_NEGATIVE_TIMEOUT;
  99. dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
  100. return 1;
  101. } else if (status) {
  102. /* Return a negative dentry, but leave it "pending" */
  103. return 1;
  104. }
  105. status = autofs_wait(sbi, &dentry->d_name);
  106. } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)));
  107. }
  108. /* Abuse this field as a pointer to the directory entry, used to
  109. find the expire list pointers */
  110. dentry->d_time = (unsigned long) ent;
  111. if (!dentry->d_inode) {
  112. inode = autofs_iget(sb, ent->ino);
  113. if (IS_ERR(inode)) {
  114. /* Failed, but leave pending for next time */
  115. return 1;
  116. }
  117. dentry->d_inode = inode;
  118. }
  119. /* If this is a directory that isn't a mount point, bitch at the
  120. daemon and fix it in user space */
  121. if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
  122. return !autofs_wait(sbi, &dentry->d_name);
  123. }
  124. /* We don't update the usages for the autofs daemon itself, this
  125. is necessary for recursive autofs mounts */
  126. if (!autofs_oz_mode(sbi)) {
  127. autofs_update_usage(&sbi->dirhash,ent);
  128. }
  129. dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
  130. return 1;
  131. }
  132. /*
  133. * Revalidate is called on every cache lookup. Some of those
  134. * cache lookups may actually happen while the dentry is not
  135. * yet completely filled in, and revalidate has to delay such
  136. * lookups..
  137. */
  138. static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
  139. {
  140. struct inode * dir;
  141. struct autofs_sb_info *sbi;
  142. struct autofs_dir_ent *ent;
  143. int res;
  144. lock_kernel();
  145. dir = dentry->d_parent->d_inode;
  146. sbi = autofs_sbi(dir->i_sb);
  147. /* Pending dentry */
  148. if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
  149. if (autofs_oz_mode(sbi))
  150. res = 1;
  151. else
  152. res = try_to_fill_dentry(dentry, dir->i_sb, sbi);
  153. unlock_kernel();
  154. return res;
  155. }
  156. /* Negative dentry.. invalidate if "old" */
  157. if (!dentry->d_inode) {
  158. unlock_kernel();
  159. return (dentry->d_time - jiffies <= AUTOFS_NEGATIVE_TIMEOUT);
  160. }
  161. /* Check for a non-mountpoint directory */
  162. if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
  163. if (autofs_oz_mode(sbi))
  164. res = 1;
  165. else
  166. res = try_to_fill_dentry(dentry, dir->i_sb, sbi);
  167. unlock_kernel();
  168. return res;
  169. }
  170. /* Update the usage list */
  171. if (!autofs_oz_mode(sbi)) {
  172. ent = (struct autofs_dir_ent *) dentry->d_time;
  173. if (ent)
  174. autofs_update_usage(&sbi->dirhash,ent);
  175. }
  176. unlock_kernel();
  177. return 1;
  178. }
  179. static const struct dentry_operations autofs_dentry_operations = {
  180. .d_revalidate = autofs_revalidate,
  181. };
  182. static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
  183. {
  184. struct autofs_sb_info *sbi;
  185. int oz_mode;
  186. DPRINTK(("autofs_root_lookup: name = "));
  187. lock_kernel();
  188. autofs_say(dentry->d_name.name,dentry->d_name.len);
  189. if (dentry->d_name.len > NAME_MAX) {
  190. unlock_kernel();
  191. return ERR_PTR(-ENAMETOOLONG);/* File name too long to exist */
  192. }
  193. sbi = autofs_sbi(dir->i_sb);
  194. oz_mode = autofs_oz_mode(sbi);
  195. DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, "
  196. "oz_mode = %d\n", task_pid_nr(current),
  197. task_pgrp_nr(current), sbi->catatonic,
  198. oz_mode));
  199. /*
  200. * Mark the dentry incomplete, but add it. This is needed so
  201. * that the VFS layer knows about the dentry, and we can count
  202. * on catching any lookups through the revalidate.
  203. *
  204. * Let all the hard work be done by the revalidate function that
  205. * needs to be able to do this anyway..
  206. *
  207. * We need to do this before we release the directory semaphore.
  208. */
  209. dentry->d_op = &autofs_dentry_operations;
  210. dentry->d_flags |= DCACHE_AUTOFS_PENDING;
  211. d_add(dentry, NULL);
  212. mutex_unlock(&dir->i_mutex);
  213. autofs_revalidate(dentry, nd);
  214. mutex_lock(&dir->i_mutex);
  215. /*
  216. * If we are still pending, check if we had to handle
  217. * a signal. If so we can force a restart..
  218. */
  219. if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
  220. /* See if we were interrupted */
  221. if (signal_pending(current)) {
  222. sigset_t *sigset = &current->pending.signal;
  223. if (sigismember (sigset, SIGKILL) ||
  224. sigismember (sigset, SIGQUIT) ||
  225. sigismember (sigset, SIGINT)) {
  226. unlock_kernel();
  227. return ERR_PTR(-ERESTARTNOINTR);
  228. }
  229. }
  230. }
  231. unlock_kernel();
  232. /*
  233. * If this dentry is unhashed, then we shouldn't honour this
  234. * lookup even if the dentry is positive. Returning ENOENT here
  235. * doesn't do the right thing for all system calls, but it should
  236. * be OK for the operations we permit from an autofs.
  237. */
  238. if (dentry->d_inode && d_unhashed(dentry))
  239. return ERR_PTR(-ENOENT);
  240. return NULL;
  241. }
  242. static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
  243. {
  244. struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
  245. struct autofs_dirhash *dh = &sbi->dirhash;
  246. struct autofs_dir_ent *ent;
  247. unsigned int n;
  248. int slsize;
  249. struct autofs_symlink *sl;
  250. struct inode *inode;
  251. DPRINTK(("autofs_root_symlink: %s <- ", symname));
  252. autofs_say(dentry->d_name.name,dentry->d_name.len);
  253. lock_kernel();
  254. if (!autofs_oz_mode(sbi)) {
  255. unlock_kernel();
  256. return -EACCES;
  257. }
  258. if (autofs_hash_lookup(dh, &dentry->d_name)) {
  259. unlock_kernel();
  260. return -EEXIST;
  261. }
  262. n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS);
  263. if (n >= AUTOFS_MAX_SYMLINKS) {
  264. unlock_kernel();
  265. return -ENOSPC;
  266. }
  267. set_bit(n,sbi->symlink_bitmap);
  268. sl = &sbi->symlink[n];
  269. sl->len = strlen(symname);
  270. sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL);
  271. if (!sl->data) {
  272. clear_bit(n,sbi->symlink_bitmap);
  273. unlock_kernel();
  274. return -ENOSPC;
  275. }
  276. ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
  277. if (!ent) {
  278. kfree(sl->data);
  279. clear_bit(n,sbi->symlink_bitmap);
  280. unlock_kernel();
  281. return -ENOSPC;
  282. }
  283. ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
  284. if (!ent->name) {
  285. kfree(sl->data);
  286. kfree(ent);
  287. clear_bit(n,sbi->symlink_bitmap);
  288. unlock_kernel();
  289. return -ENOSPC;
  290. }
  291. memcpy(sl->data,symname,slsize);
  292. sl->mtime = get_seconds();
  293. ent->ino = AUTOFS_FIRST_SYMLINK + n;
  294. ent->hash = dentry->d_name.hash;
  295. memcpy(ent->name, dentry->d_name.name, 1+(ent->len = dentry->d_name.len));
  296. ent->dentry = NULL; /* We don't keep the dentry for symlinks */
  297. autofs_hash_insert(dh,ent);
  298. inode = autofs_iget(dir->i_sb, ent->ino);
  299. if (IS_ERR(inode))
  300. return PTR_ERR(inode);
  301. d_instantiate(dentry, inode);
  302. unlock_kernel();
  303. return 0;
  304. }
  305. /*
  306. * NOTE!
  307. *
  308. * Normal filesystems would do a "d_delete()" to tell the VFS dcache
  309. * that the file no longer exists. However, doing that means that the
  310. * VFS layer can turn the dentry into a negative dentry, which we
  311. * obviously do not want (we're dropping the entry not because it
  312. * doesn't exist, but because it has timed out).
  313. *
  314. * Also see autofs_root_rmdir()..
  315. */
  316. static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
  317. {
  318. struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
  319. struct autofs_dirhash *dh = &sbi->dirhash;
  320. struct autofs_dir_ent *ent;
  321. unsigned int n;
  322. /* This allows root to remove symlinks */
  323. lock_kernel();
  324. if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) {
  325. unlock_kernel();
  326. return -EACCES;
  327. }
  328. ent = autofs_hash_lookup(dh, &dentry->d_name);
  329. if (!ent) {
  330. unlock_kernel();
  331. return -ENOENT;
  332. }
  333. n = ent->ino - AUTOFS_FIRST_SYMLINK;
  334. if (n >= AUTOFS_MAX_SYMLINKS) {
  335. unlock_kernel();
  336. return -EISDIR; /* It's a directory, dummy */
  337. }
  338. if (!test_bit(n,sbi->symlink_bitmap)) {
  339. unlock_kernel();
  340. return -EINVAL; /* Nonexistent symlink? Shouldn't happen */
  341. }
  342. dentry->d_time = (unsigned long)(struct autofs_dirhash *)NULL;
  343. autofs_hash_delete(ent);
  344. clear_bit(n,sbi->symlink_bitmap);
  345. kfree(sbi->symlink[n].data);
  346. d_drop(dentry);
  347. unlock_kernel();
  348. return 0;
  349. }
  350. static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
  351. {
  352. struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
  353. struct autofs_dirhash *dh = &sbi->dirhash;
  354. struct autofs_dir_ent *ent;
  355. lock_kernel();
  356. if (!autofs_oz_mode(sbi)) {
  357. unlock_kernel();
  358. return -EACCES;
  359. }
  360. ent = autofs_hash_lookup(dh, &dentry->d_name);
  361. if (!ent) {
  362. unlock_kernel();
  363. return -ENOENT;
  364. }
  365. if ((unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO) {
  366. unlock_kernel();
  367. return -ENOTDIR; /* Not a directory */
  368. }
  369. if (ent->dentry != dentry) {
  370. printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name);
  371. }
  372. dentry->d_time = (unsigned long)(struct autofs_dir_ent *)NULL;
  373. autofs_hash_delete(ent);
  374. drop_nlink(dir);
  375. d_drop(dentry);
  376. unlock_kernel();
  377. return 0;
  378. }
  379. static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
  380. {
  381. struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
  382. struct autofs_dirhash *dh = &sbi->dirhash;
  383. struct autofs_dir_ent *ent;
  384. struct inode *inode;
  385. ino_t ino;
  386. lock_kernel();
  387. if (!autofs_oz_mode(sbi)) {
  388. unlock_kernel();
  389. return -EACCES;
  390. }
  391. ent = autofs_hash_lookup(dh, &dentry->d_name);
  392. if (ent) {
  393. unlock_kernel();
  394. return -EEXIST;
  395. }
  396. if (sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO) {
  397. printk("autofs: Out of inode numbers -- what the heck did you do??\n");
  398. unlock_kernel();
  399. return -ENOSPC;
  400. }
  401. ino = sbi->next_dir_ino++;
  402. ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
  403. if (!ent) {
  404. unlock_kernel();
  405. return -ENOSPC;
  406. }
  407. ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
  408. if (!ent->name) {
  409. kfree(ent);
  410. unlock_kernel();
  411. return -ENOSPC;
  412. }
  413. ent->hash = dentry->d_name.hash;
  414. memcpy(ent->name, dentry->d_name.name, 1+(ent->len = dentry->d_name.len));
  415. ent->ino = ino;
  416. ent->dentry = dentry;
  417. autofs_hash_insert(dh,ent);
  418. inc_nlink(dir);
  419. inode = autofs_iget(dir->i_sb, ino);
  420. if (IS_ERR(inode)) {
  421. drop_nlink(dir);
  422. return PTR_ERR(inode);
  423. }
  424. d_instantiate(dentry, inode);
  425. unlock_kernel();
  426. return 0;
  427. }
  428. /* Get/set timeout ioctl() operation */
  429. #ifdef CONFIG_COMPAT
  430. static inline int autofs_compat_get_set_timeout(struct autofs_sb_info *sbi,
  431. unsigned int __user *p)
  432. {
  433. unsigned long ntimeout;
  434. if (get_user(ntimeout, p) ||
  435. put_user(sbi->exp_timeout / HZ, p))
  436. return -EFAULT;
  437. if (ntimeout > UINT_MAX/HZ)
  438. sbi->exp_timeout = 0;
  439. else
  440. sbi->exp_timeout = ntimeout * HZ;
  441. return 0;
  442. }
  443. #endif
  444. static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
  445. unsigned long __user *p)
  446. {
  447. unsigned long ntimeout;
  448. if (get_user(ntimeout, p) ||
  449. put_user(sbi->exp_timeout / HZ, p))
  450. return -EFAULT;
  451. if (ntimeout > ULONG_MAX/HZ)
  452. sbi->exp_timeout = 0;
  453. else
  454. sbi->exp_timeout = ntimeout * HZ;
  455. return 0;
  456. }
  457. /* Return protocol version */
  458. static inline int autofs_get_protover(int __user *p)
  459. {
  460. return put_user(AUTOFS_PROTO_VERSION, p);
  461. }
  462. /* Perform an expiry operation */
  463. static inline int autofs_expire_run(struct super_block *sb,
  464. struct autofs_sb_info *sbi,
  465. struct vfsmount *mnt,
  466. struct autofs_packet_expire __user *pkt_p)
  467. {
  468. struct autofs_dir_ent *ent;
  469. struct autofs_packet_expire pkt;
  470. memset(&pkt,0,sizeof pkt);
  471. pkt.hdr.proto_version = AUTOFS_PROTO_VERSION;
  472. pkt.hdr.type = autofs_ptype_expire;
  473. if (!sbi->exp_timeout || !(ent = autofs_expire(sb,sbi,mnt)))
  474. return -EAGAIN;
  475. pkt.len = ent->len;
  476. memcpy(pkt.name, ent->name, pkt.len);
  477. pkt.name[pkt.len] = '\0';
  478. if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
  479. return -EFAULT;
  480. return 0;
  481. }
  482. /*
  483. * ioctl()'s on the root directory is the chief method for the daemon to
  484. * generate kernel reactions
  485. */
  486. static int autofs_do_root_ioctl(struct inode *inode, struct file *filp,
  487. unsigned int cmd, unsigned long arg)
  488. {
  489. struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
  490. void __user *argp = (void __user *)arg;
  491. DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,task_pgrp_nr(current)));
  492. if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
  493. _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
  494. return -ENOTTY;
  495. if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
  496. return -EPERM;
  497. switch(cmd) {
  498. case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */
  499. return autofs_wait_release(sbi,(autofs_wqt_t)arg,0);
  500. case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */
  501. return autofs_wait_release(sbi,(autofs_wqt_t)arg,-ENOENT);
  502. case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */
  503. autofs_catatonic_mode(sbi);
  504. return 0;
  505. case AUTOFS_IOC_PROTOVER: /* Get protocol version */
  506. return autofs_get_protover(argp);
  507. #ifdef CONFIG_COMPAT
  508. case AUTOFS_IOC_SETTIMEOUT32:
  509. return autofs_compat_get_set_timeout(sbi, argp);
  510. #endif
  511. case AUTOFS_IOC_SETTIMEOUT:
  512. return autofs_get_set_timeout(sbi, argp);
  513. case AUTOFS_IOC_EXPIRE:
  514. return autofs_expire_run(inode->i_sb, sbi, filp->f_path.mnt,
  515. argp);
  516. default:
  517. return -ENOSYS;
  518. }
  519. }
  520. static long autofs_root_ioctl(struct file *filp,
  521. unsigned int cmd, unsigned long arg)
  522. {
  523. int ret;
  524. lock_kernel();
  525. ret = autofs_do_root_ioctl(filp->f_path.dentry->d_inode,
  526. filp, cmd, arg);
  527. unlock_kernel();
  528. return ret;
  529. }
  530. #ifdef CONFIG_COMPAT
  531. static long autofs_root_compat_ioctl(struct file *filp,
  532. unsigned int cmd, unsigned long arg)
  533. {
  534. struct inode *inode = filp->f_path.dentry->d_inode;
  535. int ret;
  536. lock_kernel();
  537. if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
  538. ret = autofs_do_root_ioctl(inode, filp, cmd, arg);
  539. else
  540. ret = autofs_do_root_ioctl(inode, filp, cmd,
  541. (unsigned long)compat_ptr(arg));
  542. unlock_kernel();
  543. return ret;
  544. }
  545. #endif