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