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