1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2014 The FreeBSD Foundation 5 * 6 * This software was developed by Edward Tomasz Napierala under sponsorship 7 * from the FreeBSD Foundation. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #ifndef AUTOMOUNTD_H 32 #define AUTOMOUNTD_H 33 34 #include <sys/queue.h> 35 #include <stdbool.h> 36 37 #define AUTO_MASTER_PATH "/etc/auto_master" 38 #define AUTO_MAP_PREFIX "/etc" 39 #define AUTO_SPECIAL_PREFIX "/etc/autofs" 40 #define AUTO_INCLUDE_PATH AUTO_SPECIAL_PREFIX "/include" 41 42 struct node { 43 TAILQ_ENTRY(node) n_next; 44 TAILQ_HEAD(nodehead, node) n_children; 45 struct node *n_parent; 46 char *n_key; 47 char *n_options; 48 char *n_location; 49 char *n_map; 50 const char *n_config_file; 51 int n_config_line; 52 }; 53 54 struct defined_value { 55 TAILQ_ENTRY(defined_value) d_next; 56 char *d_name; 57 char *d_value; 58 }; 59 60 void log_init(int level); 61 void log_err(int, const char *, ...) 62 __dead2 __printf0like(2, 3); 63 void log_errx(int, const char *, ...) 64 __dead2 __printf0like(2, 3); 65 void log_warn(const char *, ...) __printf0like(1, 2); 66 void log_warnx(const char *, ...) __printflike(1, 2); 67 void log_debugx(const char *, ...) __printf0like(1, 2); 68 69 char *checked_strdup(const char *); 70 char *concat(const char *s1, char separator, const char *s2); 71 void create_directory(const char *path); 72 73 struct node *node_new_root(void); 74 struct node *node_new(struct node *parent, char *key, char *options, 75 char *location, const char *config_file, int config_line); 76 struct node *node_new_map(struct node *parent, char *key, char *options, 77 char *map, const char *config_file, int config_line); 78 struct node *node_find(struct node *root, const char *mountpoint); 79 bool node_is_direct_map(const struct node *n); 80 bool node_has_wildcards(const struct node *n); 81 char *node_path(const struct node *n); 82 char *node_options(const struct node *n); 83 void node_expand_ampersand(struct node *root, const char *key); 84 void node_expand_wildcard(struct node *root, const char *key); 85 int node_expand_defined(struct node *root); 86 void node_expand_indirect_maps(struct node *n); 87 void node_print(const struct node *n, const char *cmdline_options); 88 void parse_master(struct node *root, const char *path); 89 void parse_map(struct node *parent, const char *map, const char *args, 90 bool *wildcards); 91 char *defined_expand(const char *string); 92 void defined_init(void); 93 void defined_parse_and_add(char *def); 94 void lesser_daemon(void); 95 void rpc_umntall(void); 96 97 int main_automount(int argc, char **argv); 98 int main_automountd(int argc, char **argv); 99 int main_autounmountd(int argc, char **argv); 100 101 FILE *auto_popen(const char *argv0, ...); 102 int auto_pclose(FILE *iop); 103 104 /* 105 * lex(1) stuff. 106 */ 107 extern int lineno; 108 109 #define STR 1 110 #define NEWLINE 2 111 112 #endif /* !AUTOMOUNTD_H */ 113