2 * Copyright (c) 2014 The FreeBSD Foundation
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #define VFSTOAUTOFS(mp) ((struct autofs_mount *)((mp)->mnt_data))
37 MALLOC_DECLARE(M_AUTOFS);
39 extern uma_zone_t autofs_request_zone;
40 extern uma_zone_t autofs_node_zone;
42 extern int autofs_debug;
43 extern int autofs_mount_on_stat;
45 #define AUTOFS_DEBUG(X, ...) \
47 if (autofs_debug > 1) \
48 printf("%s: " X "\n", __func__, ## __VA_ARGS__);\
51 #define AUTOFS_WARN(X, ...) \
53 if (autofs_debug > 0) { \
54 printf("WARNING: %s: " X "\n", \
55 __func__, ## __VA_ARGS__); \
59 #define AUTOFS_SLOCK(X) sx_slock(&X->am_lock)
60 #define AUTOFS_XLOCK(X) sx_xlock(&X->am_lock)
61 #define AUTOFS_SUNLOCK(X) sx_sunlock(&X->am_lock)
62 #define AUTOFS_XUNLOCK(X) sx_xunlock(&X->am_lock)
63 #define AUTOFS_ASSERT_LOCKED(X) sx_assert(&X->am_lock, SA_LOCKED)
64 #define AUTOFS_ASSERT_XLOCKED(X) sx_assert(&X->am_lock, SA_XLOCKED)
65 #define AUTOFS_ASSERT_UNLOCKED(X) sx_assert(&X->am_lock, SA_UNLOCKED)
68 RB_ENTRY(autofs_node) an_link;
71 struct autofs_node *an_parent;
72 RB_HEAD(autofs_node_tree,
73 autofs_node) an_children;
74 struct autofs_mount *an_mount;
75 struct vnode *an_vnode;
76 struct sx an_vnode_lock;
79 struct callout an_callout;
81 struct timespec an_ctime;
85 TAILQ_ENTRY(autofs_mount) am_next;
86 struct autofs_node *am_root;
89 char am_from[MAXPATHLEN];
90 char am_mountpoint[MAXPATHLEN];
91 char am_options[MAXPATHLEN];
92 char am_prefix[MAXPATHLEN];
96 struct autofs_request {
97 TAILQ_ENTRY(autofs_request) ar_next;
98 struct autofs_mount *ar_mount;
104 char ar_from[MAXPATHLEN];
105 char ar_path[MAXPATHLEN];
106 char ar_prefix[MAXPATHLEN];
107 char ar_key[MAXPATHLEN];
108 char ar_options[MAXPATHLEN];
109 struct timeout_task ar_task;
110 volatile u_int ar_refcount;
113 struct autofs_softc {
115 struct cdev *sc_cdev;
118 TAILQ_HEAD(, autofs_request) sc_requests;
121 int sc_last_request_id;
124 int autofs_init(struct vfsconf *vfsp);
125 int autofs_uninit(struct vfsconf *vfsp);
126 int autofs_trigger(struct autofs_node *anp, const char *component,
128 bool autofs_cached(struct autofs_node *anp, const char *component,
130 void autofs_flush(struct autofs_mount *amp);
131 bool autofs_ignore_thread(const struct thread *td);
132 int autofs_node_new(struct autofs_node *parent, struct autofs_mount *amp,
133 const char *name, int namelen, struct autofs_node **anpp);
134 int autofs_node_find(struct autofs_node *parent,
135 const char *name, int namelen, struct autofs_node **anpp);
136 void autofs_node_delete(struct autofs_node *anp);
137 int autofs_node_vn(struct autofs_node *anp, struct mount *mp,
138 int flags, struct vnode **vpp);
140 RB_PROTOTYPE(autofs_node_tree, autofs_node, an_link, autofs_node_cmp);
142 #endif /* !AUTOFS_H */