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