autofs_i.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. #define AUTOFS_SUPER_MAGIC 0x0187
  34. /*
  35. * If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
  36. * kernel will keep the negative response cached for up to the time given
  37. * here, although the time can be shorter if the kernel throws the dcache
  38. * entry away. This probably should be settable from user space.
  39. */
  40. #define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
  41. /* Structures associated with the root directory hash table */
  42. #define AUTOFS_HASH_SIZE 67
  43. struct autofs_dir_ent {
  44. int hash;
  45. char *name;
  46. int len;
  47. ino_t ino;
  48. struct dentry *dentry;
  49. /* Linked list of entries */
  50. struct autofs_dir_ent *next;
  51. struct autofs_dir_ent **back;
  52. /* The following entries are for the expiry system */
  53. unsigned long last_usage;
  54. struct list_head exp;
  55. };
  56. struct autofs_dirhash {
  57. struct autofs_dir_ent *h[AUTOFS_HASH_SIZE];
  58. struct list_head expiry_head;
  59. };
  60. struct autofs_wait_queue {
  61. wait_queue_head_t queue;
  62. struct autofs_wait_queue *next;
  63. autofs_wqt_t wait_queue_token;
  64. /* We use the following to see what we are waiting for */
  65. int hash;
  66. int len;
  67. char *name;
  68. /* This is for status reporting upon return */
  69. int status;
  70. int wait_ctr;
  71. };
  72. struct autofs_symlink {
  73. char *data;
  74. int len;
  75. time_t mtime;
  76. };
  77. #define AUTOFS_MAX_SYMLINKS 256
  78. #define AUTOFS_ROOT_INO 1
  79. #define AUTOFS_FIRST_SYMLINK 2
  80. #define AUTOFS_FIRST_DIR_INO (AUTOFS_FIRST_SYMLINK+AUTOFS_MAX_SYMLINKS)
  81. #define AUTOFS_SYMLINK_BITMAP_LEN \
  82. ((AUTOFS_MAX_SYMLINKS+((sizeof(long)*1)-1))/(sizeof(long)*8))
  83. #define AUTOFS_SBI_MAGIC 0x6d4a556d
  84. struct autofs_sb_info {
  85. u32 magic;
  86. struct file *pipe;
  87. pid_t oz_pgrp;
  88. int catatonic;
  89. struct super_block *sb;
  90. unsigned long exp_timeout;
  91. ino_t next_dir_ino;
  92. struct autofs_wait_queue *queues; /* Wait queue pointer */
  93. struct autofs_dirhash dirhash; /* Root directory hash */
  94. struct autofs_symlink symlink[AUTOFS_MAX_SYMLINKS];
  95. unsigned long symlink_bitmap[AUTOFS_SYMLINK_BITMAP_LEN];
  96. };
  97. static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
  98. {
  99. return (struct autofs_sb_info *)(sb->s_fs_info);
  100. }
  101. /* autofs_oz_mode(): do we see the man behind the curtain? (The
  102. processes which do manipulations for us in user space sees the raw
  103. filesystem without "magic".) */
  104. static inline int autofs_oz_mode(struct autofs_sb_info *sbi) {
  105. return sbi->catatonic || process_group(current) == sbi->oz_pgrp;
  106. }
  107. /* Hash operations */
  108. void autofs_initialize_hash(struct autofs_dirhash *);
  109. struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *,struct qstr *);
  110. void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *);
  111. void autofs_hash_delete(struct autofs_dir_ent *);
  112. struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *);
  113. void autofs_hash_dputall(struct autofs_dirhash *);
  114. void autofs_hash_nuke(struct autofs_sb_info *);
  115. /* Expiration-handling functions */
  116. void autofs_update_usage(struct autofs_dirhash *,struct autofs_dir_ent *);
  117. struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info *, struct vfsmount *mnt);
  118. /* Operations structures */
  119. extern struct inode_operations autofs_root_inode_operations;
  120. extern struct inode_operations autofs_symlink_inode_operations;
  121. extern const struct file_operations autofs_root_operations;
  122. /* Initializing function */
  123. int autofs_fill_super(struct super_block *, void *, int);
  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