aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs/root.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/autofs/root.c')
-rw-r--r--fs/autofs/root.c77
1 files changed, 38 insertions, 39 deletions
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index f2597205939d..6fa04dd6d167 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -67,8 +67,8 @@ static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldi
67 filp->f_pos = ++nr; 67 filp->f_pos = ++nr;
68 /* fall through */ 68 /* fall through */
69 default: 69 default:
70 while ( onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent) ) { 70 while (onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent)) {
71 if ( !ent->dentry || d_mountpoint(ent->dentry) ) { 71 if (!ent->dentry || d_mountpoint(ent->dentry)) {
72 if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0) 72 if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0)
73 goto out; 73 goto out;
74 filp->f_pos = nr; 74 filp->f_pos = nr;
@@ -88,10 +88,10 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
88 struct autofs_dir_ent *ent; 88 struct autofs_dir_ent *ent;
89 int status = 0; 89 int status = 0;
90 90
91 if ( !(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)) ) { 91 if (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name))) {
92 do { 92 do {
93 if ( status && dentry->d_inode ) { 93 if (status && dentry->d_inode) {
94 if ( status != -ENOENT ) 94 if (status != -ENOENT)
95 printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name); 95 printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name);
96 return 0; /* Try to get the kernel to invalidate this dentry */ 96 return 0; /* Try to get the kernel to invalidate this dentry */
97 } 97 }
@@ -106,7 +106,7 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
106 return 1; 106 return 1;
107 } 107 }
108 status = autofs_wait(sbi, &dentry->d_name); 108 status = autofs_wait(sbi, &dentry->d_name);
109 } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)) ); 109 } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)));
110 } 110 }
111 111
112 /* Abuse this field as a pointer to the directory entry, used to 112 /* Abuse this field as a pointer to the directory entry, used to
@@ -124,13 +124,13 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
124 124
125 /* If this is a directory that isn't a mount point, bitch at the 125 /* If this is a directory that isn't a mount point, bitch at the
126 daemon and fix it in user space */ 126 daemon and fix it in user space */
127 if ( S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry) ) { 127 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
128 return !autofs_wait(sbi, &dentry->d_name); 128 return !autofs_wait(sbi, &dentry->d_name);
129 } 129 }
130 130
131 /* We don't update the usages for the autofs daemon itself, this 131 /* We don't update the usages for the autofs daemon itself, this
132 is necessary for recursive autofs mounts */ 132 is necessary for recursive autofs mounts */
133 if ( !autofs_oz_mode(sbi) ) { 133 if (!autofs_oz_mode(sbi)) {
134 autofs_update_usage(&sbi->dirhash,ent); 134 autofs_update_usage(&sbi->dirhash,ent);
135 } 135 }
136 136
@@ -157,7 +157,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
157 sbi = autofs_sbi(dir->i_sb); 157 sbi = autofs_sbi(dir->i_sb);
158 158
159 /* Pending dentry */ 159 /* Pending dentry */
160 if ( dentry->d_flags & DCACHE_AUTOFS_PENDING ) { 160 if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
161 if (autofs_oz_mode(sbi)) 161 if (autofs_oz_mode(sbi))
162 res = 1; 162 res = 1;
163 else 163 else
@@ -173,7 +173,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
173 } 173 }
174 174
175 /* Check for a non-mountpoint directory */ 175 /* Check for a non-mountpoint directory */
176 if ( S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry) ) { 176 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
177 if (autofs_oz_mode(sbi)) 177 if (autofs_oz_mode(sbi))
178 res = 1; 178 res = 1;
179 else 179 else
@@ -183,9 +183,9 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
183 } 183 }
184 184
185 /* Update the usage list */ 185 /* Update the usage list */
186 if ( !autofs_oz_mode(sbi) ) { 186 if (!autofs_oz_mode(sbi)) {
187 ent = (struct autofs_dir_ent *) dentry->d_time; 187 ent = (struct autofs_dir_ent *) dentry->d_time;
188 if ( ent ) 188 if (ent)
189 autofs_update_usage(&sbi->dirhash,ent); 189 autofs_update_usage(&sbi->dirhash,ent);
190 } 190 }
191 unlock_kernel(); 191 unlock_kernel();
@@ -258,7 +258,7 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
258 * doesn't do the right thing for all system calls, but it should 258 * doesn't do the right thing for all system calls, but it should
259 * be OK for the operations we permit from an autofs. 259 * be OK for the operations we permit from an autofs.
260 */ 260 */
261 if ( dentry->d_inode && d_unhashed(dentry) ) 261 if (dentry->d_inode && d_unhashed(dentry))
262 return ERR_PTR(-ENOENT); 262 return ERR_PTR(-ENOENT);
263 263
264 return NULL; 264 return NULL;
@@ -277,18 +277,18 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
277 autofs_say(dentry->d_name.name,dentry->d_name.len); 277 autofs_say(dentry->d_name.name,dentry->d_name.len);
278 278
279 lock_kernel(); 279 lock_kernel();
280 if ( !autofs_oz_mode(sbi) ) { 280 if (!autofs_oz_mode(sbi)) {
281 unlock_kernel(); 281 unlock_kernel();
282 return -EACCES; 282 return -EACCES;
283 } 283 }
284 284
285 if ( autofs_hash_lookup(dh, &dentry->d_name) ) { 285 if (autofs_hash_lookup(dh, &dentry->d_name)) {
286 unlock_kernel(); 286 unlock_kernel();
287 return -EEXIST; 287 return -EEXIST;
288 } 288 }
289 289
290 n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS); 290 n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS);
291 if ( n >= AUTOFS_MAX_SYMLINKS ) { 291 if (n >= AUTOFS_MAX_SYMLINKS) {
292 unlock_kernel(); 292 unlock_kernel();
293 return -ENOSPC; 293 return -ENOSPC;
294 } 294 }
@@ -297,14 +297,14 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
297 sl = &sbi->symlink[n]; 297 sl = &sbi->symlink[n];
298 sl->len = strlen(symname); 298 sl->len = strlen(symname);
299 sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL); 299 sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL);
300 if ( !sl->data ) { 300 if (!sl->data) {
301 clear_bit(n,sbi->symlink_bitmap); 301 clear_bit(n,sbi->symlink_bitmap);
302 unlock_kernel(); 302 unlock_kernel();
303 return -ENOSPC; 303 return -ENOSPC;
304 } 304 }
305 305
306 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL); 306 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
307 if ( !ent ) { 307 if (!ent) {
308 kfree(sl->data); 308 kfree(sl->data);
309 clear_bit(n,sbi->symlink_bitmap); 309 clear_bit(n,sbi->symlink_bitmap);
310 unlock_kernel(); 310 unlock_kernel();
@@ -312,7 +312,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
312 } 312 }
313 313
314 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL); 314 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
315 if ( !ent->name ) { 315 if (!ent->name) {
316 kfree(sl->data); 316 kfree(sl->data);
317 kfree(ent); 317 kfree(ent);
318 clear_bit(n,sbi->symlink_bitmap); 318 clear_bit(n,sbi->symlink_bitmap);
@@ -354,23 +354,23 @@ static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
354 354
355 /* This allows root to remove symlinks */ 355 /* This allows root to remove symlinks */
356 lock_kernel(); 356 lock_kernel();
357 if ( !autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) { 357 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) {
358 unlock_kernel(); 358 unlock_kernel();
359 return -EACCES; 359 return -EACCES;
360 } 360 }
361 361
362 ent = autofs_hash_lookup(dh, &dentry->d_name); 362 ent = autofs_hash_lookup(dh, &dentry->d_name);
363 if ( !ent ) { 363 if (!ent) {
364 unlock_kernel(); 364 unlock_kernel();
365 return -ENOENT; 365 return -ENOENT;
366 } 366 }
367 367
368 n = ent->ino - AUTOFS_FIRST_SYMLINK; 368 n = ent->ino - AUTOFS_FIRST_SYMLINK;
369 if ( n >= AUTOFS_MAX_SYMLINKS ) { 369 if (n >= AUTOFS_MAX_SYMLINKS) {
370 unlock_kernel(); 370 unlock_kernel();
371 return -EISDIR; /* It's a directory, dummy */ 371 return -EISDIR; /* It's a directory, dummy */
372 } 372 }
373 if ( !test_bit(n,sbi->symlink_bitmap) ) { 373 if (!test_bit(n,sbi->symlink_bitmap)) {
374 unlock_kernel(); 374 unlock_kernel();
375 return -EINVAL; /* Nonexistent symlink? Shouldn't happen */ 375 return -EINVAL; /* Nonexistent symlink? Shouldn't happen */
376 } 376 }
@@ -392,23 +392,23 @@ static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
392 struct autofs_dir_ent *ent; 392 struct autofs_dir_ent *ent;
393 393
394 lock_kernel(); 394 lock_kernel();
395 if ( !autofs_oz_mode(sbi) ) { 395 if (!autofs_oz_mode(sbi)) {
396 unlock_kernel(); 396 unlock_kernel();
397 return -EACCES; 397 return -EACCES;
398 } 398 }
399 399
400 ent = autofs_hash_lookup(dh, &dentry->d_name); 400 ent = autofs_hash_lookup(dh, &dentry->d_name);
401 if ( !ent ) { 401 if (!ent) {
402 unlock_kernel(); 402 unlock_kernel();
403 return -ENOENT; 403 return -ENOENT;
404 } 404 }
405 405
406 if ( (unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO ) { 406 if ((unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO) {
407 unlock_kernel(); 407 unlock_kernel();
408 return -ENOTDIR; /* Not a directory */ 408 return -ENOTDIR; /* Not a directory */
409 } 409 }
410 410
411 if ( ent->dentry != dentry ) { 411 if (ent->dentry != dentry) {
412 printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name); 412 printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name);
413 } 413 }
414 414
@@ -429,18 +429,18 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
429 ino_t ino; 429 ino_t ino;
430 430
431 lock_kernel(); 431 lock_kernel();
432 if ( !autofs_oz_mode(sbi) ) { 432 if (!autofs_oz_mode(sbi)) {
433 unlock_kernel(); 433 unlock_kernel();
434 return -EACCES; 434 return -EACCES;
435 } 435 }
436 436
437 ent = autofs_hash_lookup(dh, &dentry->d_name); 437 ent = autofs_hash_lookup(dh, &dentry->d_name);
438 if ( ent ) { 438 if (ent) {
439 unlock_kernel(); 439 unlock_kernel();
440 return -EEXIST; 440 return -EEXIST;
441 } 441 }
442 442
443 if ( sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO ) { 443 if (sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO) {
444 printk("autofs: Out of inode numbers -- what the heck did you do??\n"); 444 printk("autofs: Out of inode numbers -- what the heck did you do??\n");
445 unlock_kernel(); 445 unlock_kernel();
446 return -ENOSPC; 446 return -ENOSPC;
@@ -448,13 +448,13 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
448 ino = sbi->next_dir_ino++; 448 ino = sbi->next_dir_ino++;
449 449
450 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL); 450 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
451 if ( !ent ) { 451 if (!ent) {
452 unlock_kernel(); 452 unlock_kernel();
453 return -ENOSPC; 453 return -ENOSPC;
454 } 454 }
455 455
456 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL); 456 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
457 if ( !ent->name ) { 457 if (!ent->name) {
458 kfree(ent); 458 kfree(ent);
459 unlock_kernel(); 459 unlock_kernel();
460 return -ENOSPC; 460 return -ENOSPC;
@@ -483,7 +483,7 @@ static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
483 put_user(sbi->exp_timeout / HZ, p)) 483 put_user(sbi->exp_timeout / HZ, p))
484 return -EFAULT; 484 return -EFAULT;
485 485
486 if ( ntimeout > ULONG_MAX/HZ ) 486 if (ntimeout > ULONG_MAX/HZ)
487 sbi->exp_timeout = 0; 487 sbi->exp_timeout = 0;
488 else 488 else
489 sbi->exp_timeout = ntimeout * HZ; 489 sbi->exp_timeout = ntimeout * HZ;
@@ -511,15 +511,14 @@ static inline int autofs_expire_run(struct super_block *sb,
511 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION; 511 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION;
512 pkt.hdr.type = autofs_ptype_expire; 512 pkt.hdr.type = autofs_ptype_expire;
513 513
514 if ( !sbi->exp_timeout || 514 if (!sbi->exp_timeout || !(ent = autofs_expire(sb,sbi,mnt)))
515 !(ent = autofs_expire(sb,sbi,mnt)) )
516 return -EAGAIN; 515 return -EAGAIN;
517 516
518 pkt.len = ent->len; 517 pkt.len = ent->len;
519 memcpy(pkt.name, ent->name, pkt.len); 518 memcpy(pkt.name, ent->name, pkt.len);
520 pkt.name[pkt.len] = '\0'; 519 pkt.name[pkt.len] = '\0';
521 520
522 if ( copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)) ) 521 if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
523 return -EFAULT; 522 return -EFAULT;
524 523
525 return 0; 524 return 0;
@@ -537,11 +536,11 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
537 536
538 DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,process_group(current))); 537 DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,process_group(current)));
539 538
540 if ( _IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) || 539 if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
541 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT ) 540 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
542 return -ENOTTY; 541 return -ENOTTY;
543 542
544 if ( !autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) 543 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
545 return -EPERM; 544 return -EPERM;
546 545
547 switch(cmd) { 546 switch(cmd) {