2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2016 The DragonFly Project
5 * Copyright (c) 2014 The FreeBSD Foundation
8 * This software was developed by Edward Tomasz Napierala under sponsorship
9 * from the FreeBSD Foundation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include <sys/types.h>
39 #include <sys/queue.h>
43 #define AUTO_MASTER_PATH "/etc/auto_master"
44 #define AUTO_MAP_PREFIX "/etc"
45 #define AUTO_SPECIAL_PREFIX "/etc/autofs"
46 #define AUTO_INCLUDE_PATH AUTO_SPECIAL_PREFIX "/include"
49 * DragonFly has no _SAFE macros (see 085ff963).
51 #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
52 for ((var) = TAILQ_FIRST((head)); \
53 (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
56 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
57 for ((var) = TAILQ_LAST((head), headname); \
58 (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
62 TAILQ_ENTRY(node) n_next;
63 TAILQ_HEAD(nodehead, node) n_children;
64 struct node *n_parent;
69 const char *n_config_file;
73 struct defined_value {
74 TAILQ_ENTRY(defined_value) d_next;
79 void log_init(int level);
80 void log_set_peer_name(const char *name);
81 void log_set_peer_addr(const char *addr);
82 void log_err(int, const char *, ...)
83 __dead2 __printf0like(2, 3);
84 void log_errx(int, const char *, ...)
85 __dead2 __printf0like(2, 3);
86 void log_warn(const char *, ...) __printf0like(1, 2);
87 void log_warnx(const char *, ...) __printflike(1, 2);
88 void log_debugx(const char *, ...) __printf0like(1, 2);
90 char *checked_strdup(const char *);
91 char *concat(const char *s1, char separator, const char *s2);
92 void create_directory(const char *path);
94 struct node *node_new_root(void);
95 struct node *node_new(struct node *parent, char *key, char *options,
96 char *location, const char *config_file, int config_line);
97 struct node *node_new_map(struct node *parent, char *key, char *options,
98 char *map, const char *config_file, int config_line);
99 struct node *node_find(struct node *root, const char *mountpoint);
100 bool node_is_direct_map(const struct node *n);
101 bool node_has_wildcards(const struct node *n);
102 char *node_path(const struct node *n);
103 char *node_options(const struct node *n);
104 void node_expand_ampersand(struct node *root, const char *key);
105 void node_expand_wildcard(struct node *root, const char *key);
106 int node_expand_defined(struct node *root);
107 void node_expand_indirect_maps(struct node *n);
108 void node_print(const struct node *n, const char *cmdline_options);
109 void parse_master(struct node *root, const char *path);
110 void parse_map(struct node *parent, const char *map, const char *args,
112 char *defined_expand(const char *string);
113 void defined_init(void);
114 void defined_parse_and_add(char *def);
115 void lesser_daemon(void);
117 int main_automount(int argc, char **argv);
118 void main_automountd(int argc, char **argv) __dead2;
119 void main_autounmountd(int argc, char **argv) __dead2;
121 FILE *auto_popen(const char *argv0, ...);
122 int auto_pclose(FILE *iop);
132 #endif /* !AUTOMOUNTD_H */