root.c 16 KB

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