blob: 990c28da5aecec59a81e7fab256a3bf0cbfc7f6c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* -*- 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
13/* Internal header file for autofs */
14
15#include <linux/auto_fs.h>
16
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
20
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 <linux/sched.h>
30
31#include <asm/current.h>
32#include <asm/uaccess.h>
33
34#ifdef DEBUG
35#define DPRINTK(D) (printk D)
36#else
37#define DPRINTK(D) ((void)0)
38#endif
39
40#define AUTOFS_SUPER_MAGIC 0x0187
41
42/*
43 * If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
44 * kernel will keep the negative response cached for up to the time given
45 * here, although the time can be shorter if the kernel throws the dcache
46 * entry away. This probably should be settable from user space.
47 */
48#define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
49
50/* Structures associated with the root directory hash table */
51
52#define AUTOFS_HASH_SIZE 67
53
54struct autofs_dir_ent {
55 int hash;
56 char *name;
57 int len;
58 ino_t ino;
59 struct dentry *dentry;
60 /* Linked list of entries */
61 struct autofs_dir_ent *next;
62 struct autofs_dir_ent **back;
63 /* The following entries are for the expiry system */
64 unsigned long last_usage;
65 struct list_head exp;
66};
67
68struct autofs_dirhash {
69 struct autofs_dir_ent *h[AUTOFS_HASH_SIZE];
70 struct list_head expiry_head;
71};
72
73struct autofs_wait_queue {
74 wait_queue_head_t queue;
75 struct autofs_wait_queue *next;
76 autofs_wqt_t wait_queue_token;
77 /* We use the following to see what we are waiting for */
78 int hash;
79 int len;
80 char *name;
81 /* This is for status reporting upon return */
82 int status;
83 int wait_ctr;
84};
85
86struct autofs_symlink {
87 char *data;
88 int len;
89 time_t mtime;
90};
91
92#define AUTOFS_MAX_SYMLINKS 256
93
94#define AUTOFS_ROOT_INO 1
95#define AUTOFS_FIRST_SYMLINK 2
96#define AUTOFS_FIRST_DIR_INO (AUTOFS_FIRST_SYMLINK+AUTOFS_MAX_SYMLINKS)
97
98#define AUTOFS_SYMLINK_BITMAP_LEN \
99 ((AUTOFS_MAX_SYMLINKS+((sizeof(long)*1)-1))/(sizeof(long)*8))
100
101#define AUTOFS_SBI_MAGIC 0x6d4a556d
102
103struct autofs_sb_info {
104 u32 magic;
105 struct file *pipe;
106 pid_t oz_pgrp;
107 int catatonic;
Alexander Krizhanovskyf76baf92005-09-09 13:01:59 -0700108 struct super_block *sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 unsigned long exp_timeout;
110 ino_t next_dir_ino;
111 struct autofs_wait_queue *queues; /* Wait queue pointer */
112 struct autofs_dirhash dirhash; /* Root directory hash */
113 struct autofs_symlink symlink[AUTOFS_MAX_SYMLINKS];
114 unsigned long symlink_bitmap[AUTOFS_SYMLINK_BITMAP_LEN];
115};
116
117static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
118{
119 return (struct autofs_sb_info *)(sb->s_fs_info);
120}
121
122/* autofs_oz_mode(): do we see the man behind the curtain? (The
123 processes which do manipulations for us in user space sees the raw
124 filesystem without "magic".) */
125
126static inline int autofs_oz_mode(struct autofs_sb_info *sbi) {
127 return sbi->catatonic || process_group(current) == sbi->oz_pgrp;
128}
129
130/* Hash operations */
131
132void autofs_initialize_hash(struct autofs_dirhash *);
133struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *,struct qstr *);
134void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *);
135void autofs_hash_delete(struct autofs_dir_ent *);
136struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *);
137void autofs_hash_dputall(struct autofs_dirhash *);
Alexander Krizhanovskyf76baf92005-09-09 13:01:59 -0700138void autofs_hash_nuke(struct autofs_sb_info *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140/* Expiration-handling functions */
141
142void autofs_update_usage(struct autofs_dirhash *,struct autofs_dir_ent *);
143struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info *, struct vfsmount *mnt);
144
145/* Operations structures */
146
147extern struct inode_operations autofs_root_inode_operations;
148extern struct inode_operations autofs_symlink_inode_operations;
149extern struct file_operations autofs_root_operations;
150
151/* Initializing function */
152
153int autofs_fill_super(struct super_block *, void *, int);
154
155/* Queue management functions */
156
157int autofs_wait(struct autofs_sb_info *,struct qstr *);
158int autofs_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
159void autofs_catatonic_mode(struct autofs_sb_info *);
160
161#ifdef DEBUG
162void autofs_say(const char *name, int len);
163#else
164#define autofs_say(n,l) ((void)0)
165#endif