1 /* -*- c -*- ------------------------------------------------------------- *
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_fs4.h>
16 #include <linux/list.h>
18 /* This is the range of ioctl() numbers we claim as ours */
19 #define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
20 #define AUTOFS_IOC_COUNT 32
22 #include <linux/kernel.h>
23 #include <linux/slab.h>
24 #include <linux/time.h>
25 #include <linux/string.h>
26 #include <linux/wait.h>
27 #include <linux/sched.h>
28 #include <asm/current.h>
29 #include <asm/uaccess.h>
34 #define DPRINTK(D) do{ printk("pid %d: ", current->pid); printk D; } while(0)
36 #define DPRINTK(D) do {} while(0)
39 #define AUTOFS_SUPER_MAGIC 0x0187
42 * If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
43 * kernel will keep the negative response cached for up to the time given
44 * here, although the time can be shorter if the kernel throws the dcache
45 * entry away. This probably should be settable from user space.
47 #define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
49 /* Unified info structure. This is pointed to by both the dentry and
50 inode structures. Each file in the filesystem has an instance of this
51 structure. It holds a reference to the dentry, so dentries are never
52 flushed while the file exists. All name lookups are dealt with at the
53 dentry level, although the filesystem can interfere in the validation
54 process. Readdir is implemented by traversing the dentry lists. */
56 struct dentry *dentry;
61 struct autofs_sb_info *sbi;
62 unsigned long last_used;
67 void (*free)(struct autofs_info *);
73 #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */
75 struct autofs_wait_queue {
76 wait_queue_head_t queue;
77 struct autofs_wait_queue *next;
78 autofs_wqt_t wait_queue_token;
79 /* We use the following to see what we are waiting for */
83 /* This is for status reporting upon return */
88 #define AUTOFS_SBI_MAGIC 0x6d4a556d
90 struct autofs_sb_info {
96 unsigned long exp_timeout;
97 struct super_block *sb;
98 struct autofs_wait_queue *queues; /* Wait queue pointer */
101 static inline struct autofs_sb_info *autofs4_sbi(struct super_block *sb)
103 return (struct autofs_sb_info *)(sb->s_fs_info);
106 static inline struct autofs_info *autofs4_dentry_ino(struct dentry *dentry)
108 return (struct autofs_info *)(dentry->d_fsdata);
111 /* autofs4_oz_mode(): do we see the man behind the curtain? (The
112 processes which do manipulations for us in user space sees the raw
113 filesystem without "magic".) */
115 static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
116 return sbi->catatonic || process_group(current) == sbi->oz_pgrp;
119 /* Does a dentry have some pending activity? */
120 static inline int autofs4_ispending(struct dentry *dentry)
122 struct autofs_info *inf = autofs4_dentry_ino(dentry);
124 return (dentry->d_flags & DCACHE_AUTOFS_PENDING) ||
125 (inf != NULL && inf->flags & AUTOFS_INF_EXPIRING);
128 struct inode *autofs4_get_inode(struct super_block *, struct autofs_info *);
129 struct autofs_info *autofs4_init_inf(struct autofs_sb_info *, mode_t mode);
130 void autofs4_free_ino(struct autofs_info *);
133 int is_autofs4_dentry(struct dentry *);
134 int autofs4_expire_run(struct super_block *, struct vfsmount *,
135 struct autofs_sb_info *, struct autofs_packet_expire *);
136 int autofs4_expire_multi(struct super_block *, struct vfsmount *,
137 struct autofs_sb_info *, int *);
139 /* Operations structures */
141 extern struct inode_operations autofs4_symlink_inode_operations;
142 extern struct inode_operations autofs4_dir_inode_operations;
143 extern struct inode_operations autofs4_root_inode_operations;
144 extern struct file_operations autofs4_root_operations;
146 /* Initializing function */
148 int autofs4_fill_super(struct super_block *, void *, int);
149 struct autofs_info *autofs4_init_ino(struct autofs_info *, struct autofs_sb_info *sbi, mode_t mode);
151 /* Queue management functions */
160 int autofs4_wait(struct autofs_sb_info *,struct qstr *, enum autofs_notify);
161 int autofs4_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
162 void autofs4_catatonic_mode(struct autofs_sb_info *);