MacOS needs a ${CACHEDIR}/cores/ for core dumps to work
[arla.git] / arlad / arla_local.h
blob5936db899283ac9f86ccd7a4350dc21a23b9fdc1
1 /*
2 * Copyright (c) 1995 - 2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * 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 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
35 * Include file for whole arlad
36 * $Id$
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <assert.h>
47 #include <ctype.h>
48 #include <time.h>
49 #include <limits.h>
50 #include <errno.h>
51 #include <sys/time.h>
52 #if defined(HAVE_DIRENT_H)
53 #include <dirent.h>
54 #if DIRENT_AND_SYS_DIR_H
55 #ifndef __FreeBSD__
56 /* <sys/dir.h> is for DIRSIZ macro, freebsd uses _GENERIC_DIRSIZ */
57 #include <sys/dir.h>
58 #endif
59 #endif
60 #elif defined(HAVE_SYS_DIR_H)
61 #include <sys/dir.h>
62 #endif
63 #include <unistd.h>
64 #include <sys/types.h>
65 #ifdef HAVE_LINUX_TYPES_H
66 #include <linux/types.h>
67 #endif
68 #include <sys/param.h>
69 #include <sys/socket.h>
70 #include <sys/uio.h>
71 #ifdef HAVE_SYS_MMAN_H
72 #include <sys/mman.h>
73 #endif
74 #ifdef HAVE_SYS_IOCCOM_H
75 #include <sys/ioccom.h>
76 #endif
77 #ifdef HAVE_SYS_STAT_H
78 #include <sys/stat.h>
79 #endif
80 #ifdef HAVE_SYS_MOUNT_H
81 #include <sys/mount.h>
82 #endif
83 #ifdef HAVE_SYS_PRCTL_H
84 #include <sys/prctl.h>
85 #endif
86 #ifdef HAVE_SYS_IOCTL_H
87 #include <sys/ioctl.h>
88 #endif
89 #include <netinet/in.h>
90 #include <arpa/inet.h>
91 #include <netdb.h>
92 #include <fcntl.h>
93 #include <pwd.h>
94 #include <err.h>
95 #include <parse_units.h>
96 #include <roken.h>
98 #include <lwp.h>
99 #include <lock.h>
101 #include <rx/rx.h>
102 #include <rx/rx_null.h>
104 #ifdef HAVE_OPENSSL
105 #include <openssl/des.h>
106 #else
107 #include <des.h>
108 #endif
109 #include <rxkad.h>
111 #include <ifaddrs.h>
113 #include <arla-pioctl.h>
114 #ifdef KERBEROS
115 #include <kafs.h>
116 #endif
118 #include <uae.h>
120 #include "log.h"
122 #include "fs.h"
123 #include "cmcb.h"
124 #include "fs.cs.h"
125 #include "list.h"
126 #include "vldb.h"
127 #include "vldb.cs.h"
128 #include "volcache.h"
129 #include "fbuf.h"
130 #include "bool.h"
131 #include "hash.h"
132 #include "heap.h"
133 #include "afs_dir.h"
134 #include "ports.h"
135 #include "conn.h"
136 #include "poller.h"
137 #include "fcache.h"
138 #include "abuf.h"
139 #include "blocks.h"
140 #include "state.h"
141 #include "inter.h"
142 #include "cred.h"
143 #include "adir.h"
144 #include "service.h"
145 #include "subr.h"
146 #include "fprio.h"
147 #include "disco.h"
148 #include "stats.h"
149 #include "kernel.h"
150 #include "messages.h"
151 #include "fs_errors.h"
152 #include "arladeb.h"
153 #include "ko.h"
154 #include "nnpfs.h"
155 #include "afs_uuid.h"
157 enum connected_mode { CONNECTED = 0,
158 FETCH_ONLY = 1,
159 DISCONNECTED = 2,
160 CONNECTEDLOG = 4};
162 extern enum connected_mode connected_mode;
164 #include "dynroot.h"
166 #define assert_flag(e,f) assert((e)->flags.f)
167 #define assert_not_flag(e,f) assert(!(e)->flags.f)
169 /* for asserts normally disabled */
170 #if 0
171 #define arla_debug_assert(x) assert(x)
172 #else
173 #define arla_debug_assert(x) do { ; } while (0)
174 #endif
176 #define SYSNAMEMAXLEN 2048
177 extern char **sysnamelist;
178 extern int sysnamenum;
181 #define ARLA_NUMCONNS 200
182 #define ARLA_HIGH_VNODES 4000
183 #define ARLA_LOW_VNODES 3000
184 #define ARLA_HIGH_BYTES 40000000
185 #define ARLA_LOW_BYTES 30000000
186 #define ARLA_NUMCREDS 200
187 #define ARLA_NUMVOLS 100
189 /* Block size should be a power of 2. */
190 #ifdef BLOCKS_PARANOIA
191 #define ARLA_BLOCKSIZE 8192
192 #else
193 #define ARLA_BLOCKSIZE 131072
194 #endif
197 * This should be a not used uid in the system,
198 * NNPFS_ANONYMOUSID may be good
201 #define ARLA_NO_AUTH_CRED 4
203 extern int fake_mp;
204 extern char *default_log_file;
205 extern char *default_arla_cachedir;
207 extern int fork_flag; /* if the program should fork */
208 extern int num_workers; /* number of workers program should use */
209 extern int client_port; /* what port the client is using */
210 extern int afs_BusyWaitPeriod; /* number of sec to wait on fs when VBUSY */
211 extern int use_o_largefile; /* turns off largefile cache if set to 0 */
213 void
214 store_state (void);
217 arla_init (void);
219 char *
220 get_default_cache_dir (void);
222 #ifndef O_BINARY
223 #define O_BINARY 0
224 #endif
226 #ifndef O_LARGEFILE
227 #define O_LARGEFILE 0
228 #endif
230 extern const char *conf_file;
231 extern char *log_file;
232 extern char *debug_levels;
233 extern char *connected_mode_string;
234 #ifdef KERBEROS
235 extern const char *rxkad_level_string;
236 #endif
237 extern const char *argv_sysname;
238 extern char *root_volume;
239 extern int cpu_usage;
240 extern int version_flag;
241 extern int help_flag;
242 extern int recover;
243 extern int dynroot_enable;
244 extern int cm_consistency;
245 extern int fake_stat;
246 extern uint64_t fetch_block_size;
248 extern char *cache_dir;
249 extern char *trace_file;