autofs_i.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* -*- linux-c -*- ------------------------------------------------------- *
  2. *
  3. * linux/fs/autofs/autofs_i.h
  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. /* Internal header file for autofs */
  13. #include <linux/auto_fs.h>
  14. /* This is the range of ioctl() numbers we claim as ours */
  15. #define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
  16. #define AUTOFS_IOC_COUNT 32
  17. #include <linux/kernel.h>
  18. #include <linux/slab.h>
  19. #include <linux/time.h>
  20. #include <linux/string.h>
  21. #include <linux/wait.h>
  22. #include <linux/dcache.h>
  23. #include <linux/namei.h>
  24. #include <linux/mount.h>
  25. #include <linux/sched.h>
  26. #include <asm/current.h>
  27. #include <asm/uaccess.h>
  28. #ifdef DEBUG
  29. #define DPRINTK(D) (printk D)
  30. #else
  31. #define DPRINTK(D) ((void)0)
  32. #endif
  33. /*
  34. * If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
  35. * kernel will keep the negative response cached for up to the time given
  36. * here, although the time can be shorter if the kernel throws the dcache
  37. * entry away. This probably should be settable from user space.
  38. */
  39. #define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
  40. /* Structures associated with the root directory hash table */
  41. #define AUTOFS_HASH_SIZE 67
  42. struct autofs_dir_ent {
  43. int hash;
  44. char *name;
  45. int len;
  46. ino_t ino;
  47. struct dentry *dentry;
  48. /* Linked list of entries */
  49. struct autofs_dir_ent *next;
  50. struct autofs_dir_ent **back;
  51. /* The following entries are for the expiry system */
  52. unsigned long last_usage;
  53. struct list_head exp;
  54. };
  55. struct autofs_dirhash {
  56. struct autofs_dir_ent *h[AUTOFS_HASH_SIZE];
  57. struct list_head expiry_head;
  58. };
  59. struct autofs_wait_queue {
  60. wait_queue_head_t queue;
  61. struct autofs_wait_queue *next;
  62. autofs_wqt_t wait_queue_token;
  63. /* We use the following to see what we are waiting for */
  64. int hash;
  65. int len;
  66. char *name;
  67. /* This is for status reporting upon return */
  68. int status;
  69. int wait_ctr;
  70. };
  71. struct autofs_symlink {
  72. char *data;
  73. int len;
  74. time_t mtime;
  75. };
  76. #define AUTOFS_MAX_SYMLINKS 256
  77. #define AUTOFS_ROOT_INO 1
  78. #define AUTOFS_FIRST_SYMLINK 2
  79. #define AUTOFS_FIRST_DIR_INO (AUTOFS_FIRST_SYMLINK+AUTOFS_MAX_SYMLINKS)
  80. #define AUTOFS_SYMLINK_BITMAP_LEN \
  81. ((AUTOFS_MAX_SYMLINKS+((sizeof(long)*1)-1))/(sizeof(long)*8))
  82. #define AUTOFS_SBI_MAGIC 0x6d4a556d
  83. struct autofs_sb_info {
  84. u32 magic;
  85. struct file *pipe;
  86. pid_t oz_pgrp;
  87. int catatonic;
  88. struct super_block *sb;
  89. unsigned long exp_timeout;
  90. ino_t next_dir_ino;
  91. struct autofs_wait_queue *queues; /* Wait queue pointer */
  92. struct autofs_dirhash dirhash; /* Root directory hash */
  93. struct autofs_symlink symlink[AUTOFS_MAX_SYMLINKS];
  94. unsigned long symlink_bitmap[AUTOFS_SYMLINK_BITMAP_LEN];
  95. };
  96. static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
  97. {
  98. return (struct autofs_sb_info *)(sb->s_fs_info);
  99. }
  100. /* autofs_oz_mode(): do we see the man behind the curtain? (The
  101. processes which do manipulations for us in user space sees the raw
  102. filesystem without "magic".) */
  103. static inline int autofs_oz_mode(struct autofs_sb_info *sbi) {
  104. return sbi->catatonic || process_group(current) == sbi->oz_pgrp;
  105. }
  106. /* Hash operations */
  107. void autofs_initialize_hash(struct autofs_dirhash *);
  108. struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *,struct qstr *);
  109. void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *);
  110. void autofs_hash_delete(struct autofs_dir_ent *);
  111. struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *);
  112. void autofs_hash_dputall(struct autofs_dirhash *);
  113. void autofs_hash_nuke(struct autofs_sb_info *);
  114. /* Expiration-handling functions */
  115. void autofs_update_usage(struct autofs_dirhash *,struct autofs_dir_ent *);
  116. struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info *, struct vfsmount *mnt);
  117. /* Operations structures */
  118. extern const struct inode_operations autofs_root_inode_operations;
  119. extern const struct inode_operations autofs_symlink_inode_operations;
  120. extern const struct file_operations autofs_root_operations;
  121. /* Initializing function */
  122. int autofs_fill_super(struct super_block *, void *, int);
  123. void autofs_kill_sb(struct super_block *sb);
  124. /* Queue management functions */
  125. int autofs_wait(struct autofs_sb_info *,struct qstr *);
  126. int autofs_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
  127. void autofs_catatonic_mode(struct autofs_sb_info *);
  128. #ifdef DEBUG
  129. void autofs_say(const char *name, int len);
  130. #else
  131. #define autofs_say(n,l) ((void)0)
  132. #endif