| 1 |
/* ----------------------------------------------------------------------- * |
| 2 |
* |
| 3 |
* master.h - header file for master map parser utility routines. |
| 4 |
* |
| 5 |
* Copyright 2006 Ian Kent <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, |
| 10 |
* USA; either version 2 of the License, or (at your option) any later |
| 11 |
* version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* ----------------------------------------------------------------------- */ |
| 19 |
|
| 20 |
#ifndef MASTER_H |
| 21 |
#define MASTER_H |
| 22 |
|
| 23 |
#define MAP_FLAG_FORMAT_AMD 0x0001 |
| 24 |
|
| 25 |
struct map_source { |
| 26 |
unsigned int ref; |
| 27 |
unsigned int flags; |
| 28 |
char *type; |
| 29 |
char *format; |
| 30 |
char *name; |
| 31 |
time_t exp_timeout; /* Timeout for expiring mounts */ |
| 32 |
time_t age; |
| 33 |
unsigned int master_line; |
| 34 |
struct mapent_cache *mc; |
| 35 |
unsigned int stale; |
| 36 |
unsigned int recurse; |
| 37 |
unsigned int depth; |
| 38 |
pthread_rwlock_t module_lock; |
| 39 |
struct lookup_mod *lookup; |
| 40 |
int argc; |
| 41 |
const char **argv; |
| 42 |
struct map_source *instance; |
| 43 |
struct map_source *next; |
| 44 |
}; |
| 45 |
|
| 46 |
struct master_mapent { |
| 47 |
char *path; |
| 48 |
size_t len; |
| 49 |
time_t age; |
| 50 |
struct master *master; |
| 51 |
pthread_rwlock_t source_lock; |
| 52 |
struct map_source *current; |
| 53 |
struct map_source *maps; |
| 54 |
struct autofs_point *ap; |
| 55 |
struct list_head list; |
| 56 |
struct list_head join; |
| 57 |
}; |
| 58 |
|
| 59 |
struct master { |
| 60 |
char *name; |
| 61 |
unsigned int recurse; |
| 62 |
unsigned int depth; |
| 63 |
unsigned int reading; |
| 64 |
unsigned int read_fail; |
| 65 |
unsigned int readall; |
| 66 |
unsigned int default_ghost; |
| 67 |
unsigned int default_logging; |
| 68 |
unsigned int default_timeout; |
| 69 |
unsigned int logopt; |
| 70 |
struct mapent_cache *nc; |
| 71 |
struct list_head mounts; |
| 72 |
struct list_head completed; |
| 73 |
}; |
| 74 |
|
| 75 |
/* From the yacc master map parser */ |
| 76 |
|
| 77 |
void master_init_scan(void); |
| 78 |
int master_parse_entry(const char *, unsigned int, unsigned int, time_t); |
| 79 |
|
| 80 |
/* From master.c master parser utility routines */ |
| 81 |
|
| 82 |
void master_mutex_lock(void); |
| 83 |
void master_mutex_unlock(void); |
| 84 |
void master_mutex_lock_cleanup(void *); |
| 85 |
void master_set_default_timeout(void); |
| 86 |
void master_set_default_ghost_mode(void); |
| 87 |
int master_add_autofs_point(struct master_mapent *, unsigned, unsigned, unsigned, int); |
| 88 |
void master_free_autofs_point(struct autofs_point *); |
| 89 |
struct map_source * |
| 90 |
master_add_map_source(struct master_mapent *, char *, char *, time_t, int, const char **); |
| 91 |
struct map_source * |
| 92 |
master_find_map_source(struct master_mapent *, const char *, const char *, int, const char **); |
| 93 |
struct map_source * |
| 94 |
master_get_map_source(struct master_mapent *, const char *, const char *, int, const char **); |
| 95 |
void master_free_map_source(struct map_source *, unsigned int); |
| 96 |
struct map_source * |
| 97 |
master_find_source_instance(struct map_source *, const char *, const char *, int, const char **); |
| 98 |
struct map_source * |
| 99 |
master_add_source_instance(struct map_source *, const char *, const char *, time_t, int, const char **); |
| 100 |
int check_stale_instances(struct map_source *); |
| 101 |
void clear_stale_instances(struct map_source *); |
| 102 |
void send_map_update_request(struct autofs_point *); |
| 103 |
void master_source_writelock(struct master_mapent *); |
| 104 |
void master_source_readlock(struct master_mapent *); |
| 105 |
void master_source_unlock(struct master_mapent *); |
| 106 |
void master_source_lock_cleanup(void *); |
| 107 |
struct master_mapent *master_find_mapent(struct master *, const char *); |
| 108 |
struct autofs_point *master_find_mapent_by_devid(struct master *master, dev_t devid); |
| 109 |
struct master_mapent *master_new_mapent(struct master *, const char *, time_t); |
| 110 |
void master_add_mapent(struct master *, struct master_mapent *); |
| 111 |
void master_remove_mapent(struct master_mapent *); |
| 112 |
void master_free_mapent_sources(struct master_mapent *, unsigned int); |
| 113 |
void master_free_mapent(struct master_mapent *); |
| 114 |
struct master *master_new(const char *, unsigned int, unsigned int); |
| 115 |
int master_read_master(struct master *, time_t); |
| 116 |
int master_notify_submount(struct autofs_point *, const char *path, enum states); |
| 117 |
void master_notify_state_change(struct master *, int); |
| 118 |
int master_mount_mounts(struct master *, time_t); |
| 119 |
int dump_map(struct master *, const char *, const char *); |
| 120 |
int master_show_mounts(struct master *); |
| 121 |
unsigned int master_get_logopt(void); |
| 122 |
int __master_list_empty(struct master *); |
| 123 |
int master_list_empty(struct master *); |
| 124 |
int master_done(struct master *); |
| 125 |
int master_kill(struct master *); |
| 126 |
void map_module_writelock(struct map_source *map); |
| 127 |
int map_module_try_writelock(struct map_source *map); |
| 128 |
void map_module_readlock(struct map_source *map); |
| 129 |
void map_module_unlock(struct map_source *map); |
| 130 |
void map_module_lock_cleanup(void *arg); |
| 131 |
|
| 132 |
#endif |