| File: | afs/afs_call.c |
| Location: | line 1118, column 6 |
| Description: | Value stored to 'code' is never read |
| 1 | /* |
| 2 | * Copyright 2000, International Business Machines Corporation and others. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This software has been released under the terms of the IBM Public |
| 6 | * License. For details, see the LICENSE file in the top-level source |
| 7 | * directory or online at http://www.openafs.org/dl/license10.html |
| 8 | */ |
| 9 | |
| 10 | #include <afsconfig.h> |
| 11 | #include "afs/param.h" |
| 12 | |
| 13 | |
| 14 | #include "afs/sysincludes.h" /* Standard vendor system headers */ |
| 15 | #include "afsincludes.h" /* Afs-based standard headers */ |
| 16 | #include "afs/afs_stats.h" |
| 17 | #include "rx/rx_globals.h" |
| 18 | #if !defined(UKERNEL1) && !defined(AFS_LINUX20_ENV) |
| 19 | #include "net/if.h" |
| 20 | #ifdef AFS_SGI62_ENV |
| 21 | #include "h/hashing.h" |
| 22 | #endif |
| 23 | #if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV) |
| 24 | #include "netinet/in_var.h" |
| 25 | #endif |
| 26 | #endif /* !defined(UKERNEL) */ |
| 27 | #ifdef AFS_SUN510_ENV |
| 28 | #include "h/ksynch.h" |
| 29 | #include "h/sunddi.h" |
| 30 | #endif |
| 31 | |
| 32 | #if defined(AFS_SUN5_ENV) || defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) |
| 33 | #define AFS_MINBUFFERS50 100 |
| 34 | #else |
| 35 | #define AFS_MINBUFFERS50 50 |
| 36 | #endif |
| 37 | |
| 38 | #if (defined(AFS_SUN5_ENV) || (defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H)) || defined(AFS_DARWIN80_ENV)) && !defined(UKERNEL1) |
| 39 | /* If AFS_DAEMONOP_ENV is defined, it indicates we run "daemon" AFS syscalls by |
| 40 | * spawning a kernel thread to do the work, instead of running them in the |
| 41 | * calling process. */ |
| 42 | # define AFS_DAEMONOP_ENV |
| 43 | #endif |
| 44 | |
| 45 | struct afsop_cell { |
| 46 | afs_int32 hosts[AFS_MAXCELLHOSTS8]; |
| 47 | char cellName[100]; |
| 48 | }; |
| 49 | |
| 50 | char afs_zeros[AFS_ZEROS64]; |
| 51 | char afs_rootVolumeName[64] = ""; |
| 52 | afs_uint32 rx_bindhost; |
| 53 | |
| 54 | #ifdef AFS_SUN510_ENV |
| 55 | ddi_taskq_t *afs_taskq; |
| 56 | krwlock_t afsifinfo_lock; |
| 57 | #endif |
| 58 | |
| 59 | afs_int32 afs_initState = 0; |
| 60 | afs_int32 afs_termState = 0; |
| 61 | afs_int32 afs_setTime = 0; |
| 62 | int afs_cold_shutdown = 0; |
| 63 | char afs_SynchronousCloses = '\0'; |
| 64 | static int afs_CB_Running = 0; |
| 65 | static int AFS_Running = 0; |
| 66 | static int afs_CacheInit_Done = 0; |
| 67 | static int afs_Go_Done = 0; |
| 68 | extern struct interfaceAddr afs_cb_interface; |
| 69 | static int afs_RX_Running = 0; |
| 70 | static int afs_InitSetup_done = 0; |
| 71 | afs_int32 afs_numcachefiles = -1; |
| 72 | afs_int32 afs_numfilesperdir = -1; |
| 73 | char afs_cachebasedir[1024]; |
| 74 | |
| 75 | afs_int32 afs_rx_deadtime = AFS_RXDEADTIME50; |
| 76 | afs_int32 afs_rx_harddead = AFS_HARDDEADTIME120; |
| 77 | afs_int32 afs_rx_idledead = AFS_IDLEDEADTIME50; |
| 78 | |
| 79 | static int afscall_set_rxpck_received = 0; |
| 80 | |
| 81 | #if defined(AFS_HPUX_ENV) |
| 82 | extern int afs_vfs_mount(); |
| 83 | #endif /* defined(AFS_HPUX_ENV) */ |
| 84 | |
| 85 | /* This is code which needs to be called once when the first daemon enters |
| 86 | * the client. A non-zero return means an error and AFS should not start. |
| 87 | */ |
| 88 | static int |
| 89 | afs_InitSetup(int preallocs) |
| 90 | { |
| 91 | int code; |
| 92 | |
| 93 | if (afs_InitSetup_done) |
| 94 | return EAGAIN35; |
| 95 | |
| 96 | #ifdef AFS_SUN510_ENV |
| 97 | /* Initialize a RW lock for the ifinfo global array */ |
| 98 | rw_init(&afsifinfo_lock, NULL((void *)0), RW_DRIVER, NULL((void *)0)); |
| 99 | |
| 100 | /* Create a taskq */ |
| 101 | afs_taskq = ddi_taskq_create(NULL((void *)0), "afs_taskq", 2, TASKQ_DEFAULTPRI, 0); |
| 102 | |
| 103 | osi_StartNetIfPoller(); |
| 104 | #endif |
| 105 | |
| 106 | #ifndef AFS_NOSTATS |
| 107 | /* |
| 108 | * Set up all the AFS statistics variables. This should be done |
| 109 | * exactly once, and it should be done here, the first resource-setting |
| 110 | * routine to be called by the CM/RX. |
| 111 | */ |
| 112 | afs_InitStats(); |
| 113 | #endif /* AFS_NOSTATS */ |
| 114 | |
| 115 | memset(afs_zeros, 0, AFS_ZEROS64); |
| 116 | |
| 117 | rx_SetBusyChannelError(RX_CALL_TIMEOUT(-3)); |
| 118 | |
| 119 | /* start RX */ |
| 120 | if(!afscall_set_rxpck_received) |
| 121 | rx_extraPackets = AFS_NRXPACKETS80; /* smaller # of packets */ |
| 122 | code = rx_InitHost(rx_bindhost, htons(7001)(__builtin_constant_p(7001) ? (__uint16_t)(((__uint16_t)(7001 )) << 8 | ((__uint16_t)(7001)) >> 8) : __bswap16_var (7001))); |
| 123 | if (code) { |
| 124 | afs_warn("AFS: RX failed to initialize %d).\n", code); |
| 125 | return code; |
| 126 | } |
| 127 | rx_SetRxDeadTime(afs_rx_deadtime)(rx_connDeadTime = (afs_rx_deadtime)); |
| 128 | /* resource init creates the services */ |
| 129 | afs_ResourceInit(preallocs); |
| 130 | |
| 131 | afs_InitSetup_done = 1; |
| 132 | afs_osi_Wakeup(&afs_InitSetup_done); |
| 133 | |
| 134 | return code; |
| 135 | } |
| 136 | |
| 137 | #ifdef AFS_DAEMONOP_ENV |
| 138 | static int |
| 139 | daemonOp_common(long parm, long parm2, long parm3, long parm4, long parm5, |
| 140 | long parm6) |
| 141 | { |
| 142 | int code; |
| 143 | if (parm == AFSOP_START_RXCALLBACK0) { |
| 144 | if (afs_CB_Running) |
| 145 | return -1; |
| 146 | # ifdef RXK_LISTENER_ENV1 |
| 147 | } else if (parm == AFSOP_RXLISTENER_DAEMON48) { |
| 148 | if (afs_RX_Running) |
| 149 | return -1; |
| 150 | afs_RX_Running = 1; |
| 151 | # endif |
| 152 | code = afs_InitSetup(parm2); |
| 153 | if (parm3) { |
| 154 | rx_enablePeerRPCStats(); |
| 155 | } |
| 156 | if (parm4) { |
| 157 | rx_enableProcessRPCStats(); |
| 158 | } |
| 159 | if (code) |
| 160 | return -1; |
| 161 | } else if (parm == AFSOP_START_AFS1) { |
| 162 | if (AFS_Running) |
| 163 | return -1; |
| 164 | } /* other functions don't need setup in the parent */ |
| 165 | return 0; |
| 166 | } |
| 167 | #endif /* AFS_DAEMONOP_ENV */ |
| 168 | |
| 169 | #if defined(AFS_DARWIN80_ENV) |
| 170 | struct afsd_thread_info { |
| 171 | unsigned long parm; |
| 172 | }; |
| 173 | static int |
| 174 | afsd_thread(int *rock) |
| 175 | { |
| 176 | struct afsd_thread_info *arg = (struct afsd_thread_info *)rock; |
| 177 | unsigned long parm = arg->parm; |
| 178 | |
| 179 | switch (parm) { |
| 180 | case AFSOP_START_RXCALLBACK0: |
| 181 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 181 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 182 | wakeup(arg); |
| 183 | afs_CB_Running = 1; |
| 184 | #ifndef RXK_LISTENER_ENV1 |
| 185 | afs_initState = AFSOP_START_AFS1; |
| 186 | afs_osi_Wakeup(&afs_initState); |
| 187 | #else |
| 188 | while (afs_RX_Running != 2) |
| 189 | afs_osi_Sleep(&afs_RX_Running); |
| 190 | #endif |
| 191 | afs_RXCallBackServer(); |
| 192 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 192);}while(0); } while(0); |
| 193 | thread_terminate(current_thread()); |
| 194 | break; |
| 195 | case AFSOP_START_AFS1: |
| 196 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 196 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 197 | wakeup(arg); |
| 198 | AFS_Running = 1; |
| 199 | while (afs_initState < AFSOP_START_AFS1) |
| 200 | afs_osi_Sleep(&afs_initState); |
| 201 | afs_initState = AFSOP_START_BKG2; |
| 202 | afs_osi_Wakeup(&afs_initState); |
| 203 | afs_Daemon(); |
| 204 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 204);}while(0); } while(0); |
| 205 | thread_terminate(current_thread()); |
| 206 | break; |
| 207 | case AFSOP_START_BKG2: |
| 208 | afs_warn("Install matching afsd! Old background daemons not supported.\n"); |
| 209 | thread_terminate(current_thread()); |
| 210 | break; |
| 211 | case AFSOP_START_TRUNCDAEMON3: |
| 212 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 212 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 213 | wakeup(arg); |
| 214 | while (afs_initState < AFSOP_GO100) |
| 215 | afs_osi_Sleep(&afs_initState); |
| 216 | afs_CacheTruncateDaemon(); |
| 217 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 217);}while(0); } while(0); |
| 218 | thread_terminate(current_thread()); |
| 219 | break; |
| 220 | case AFSOP_START_CS4: |
| 221 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 221 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 222 | wakeup(arg); |
| 223 | afs_CheckServerDaemon(); |
| 224 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 224);}while(0); } while(0); |
| 225 | thread_terminate(current_thread()); |
| 226 | break; |
| 227 | case AFSOP_RXEVENT_DAEMON19: |
| 228 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 228 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 229 | wakeup(arg); |
| 230 | while (afs_initState < AFSOP_START_BKG2) |
| 231 | afs_osi_Sleep(&afs_initState); |
| 232 | afs_rxevent_daemon(); |
| 233 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 233);}while(0); } while(0); |
| 234 | thread_terminate(current_thread()); |
| 235 | break; |
| 236 | #ifdef RXK_LISTENER_ENV1 |
| 237 | case AFSOP_RXLISTENER_DAEMON48: |
| 238 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 238 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 239 | wakeup(arg); |
| 240 | afs_initState = AFSOP_START_AFS1; |
| 241 | afs_osi_Wakeup(&afs_initState); |
| 242 | afs_RX_Running = 2; |
| 243 | afs_osi_Wakeup(&afs_RX_Running); |
| 244 | afs_osi_RxkRegister(); |
| 245 | rxk_Listener(); |
| 246 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 246);}while(0); } while(0); |
| 247 | thread_terminate(current_thread()); |
| 248 | break; |
| 249 | #endif |
| 250 | default: |
| 251 | afs_warn("Unknown op %ld in StartDaemon()\n", (long)parm); |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | void |
| 257 | afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, |
| 258 | long parm6) |
| 259 | { |
| 260 | struct afsd_thread_info info; |
| 261 | thread_t thread; |
| 262 | if (daemonOp_common(parm, parm2, parm3, parm4, parm5, parm6)) { |
| 263 | return; |
| 264 | } |
| 265 | info.parm = parm; |
| 266 | kernel_thread_start((thread_continue_t)afsd_thread, &info, &thread); |
| 267 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 267);}while(0); } while(0); |
| 268 | /* we need to wait cause we passed stack pointers around.... */ |
| 269 | msleep(&info, NULL((void *)0), PVFS, "afs_DaemonOp", NULL((void *)0)); |
| 270 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 270 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 271 | thread_deallocate(thread); |
| 272 | } |
| 273 | #endif |
| 274 | |
| 275 | |
| 276 | #if defined(AFS_LINUX24_ENV) && defined(HAVE_LINUX_COMPLETION_H) |
| 277 | struct afsd_thread_info { |
| 278 | # if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA) |
| 279 | struct work_struct tq; |
| 280 | # endif |
| 281 | unsigned long parm; |
| 282 | struct completion *complete; |
| 283 | }; |
| 284 | |
| 285 | static int |
| 286 | afsd_thread(void *rock) |
| 287 | { |
| 288 | struct afsd_thread_info *arg = rock; |
| 289 | unsigned long parm = arg->parm; |
| 290 | # ifdef SYS_SETPRIORITY_EXPORTED |
| 291 | int (*sys_setpriority) (int, int, int) = sys_call_table[__NR_setpriority]; |
| 292 | # endif |
| 293 | # if defined(AFS_LINUX26_ENV) |
| 294 | daemonize("afsd"); |
| 295 | # else |
| 296 | daemonize(); |
| 297 | # endif |
| 298 | /* doesn't do much, since we were forked from keventd, but |
| 299 | * does call mm_release, which wakes up our parent (since it |
| 300 | * used CLONE_VFORK) */ |
| 301 | # if !defined(AFS_LINUX26_ENV) |
| 302 | reparent_to_init(); |
| 303 | # endif |
| 304 | afs_osi_MaskSignals(); |
| 305 | switch (parm) { |
| 306 | case AFSOP_START_RXCALLBACK0: |
| 307 | sprintf(current->comm, "afs_cbstart"); |
| 308 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 308 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 309 | complete(arg->complete); |
| 310 | afs_CB_Running = 1; |
| 311 | #if !defined(RXK_LISTENER_ENV1) |
| 312 | afs_initState = AFSOP_START_AFS1; |
| 313 | afs_osi_Wakeup(&afs_initState); |
| 314 | #else |
| 315 | while (afs_RX_Running != 2) |
| 316 | afs_osi_Sleep(&afs_RX_Running); |
| 317 | #endif |
| 318 | sprintf(current->comm, "afs_callback"); |
| 319 | afs_RXCallBackServer(); |
| 320 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 320);}while(0); } while(0); |
| 321 | complete_and_exit(0, 0); |
| 322 | break; |
| 323 | case AFSOP_START_AFS1: |
| 324 | sprintf(current->comm, "afs_afsstart"); |
| 325 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 325 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 326 | complete(arg->complete); |
| 327 | AFS_Running = 1; |
| 328 | while (afs_initState < AFSOP_START_AFS1) |
| 329 | afs_osi_Sleep(&afs_initState); |
| 330 | afs_initState = AFSOP_START_BKG2; |
| 331 | afs_osi_Wakeup(&afs_initState); |
| 332 | sprintf(current->comm, "afsd"); |
| 333 | afs_Daemon(); |
| 334 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 334);}while(0); } while(0); |
| 335 | complete_and_exit(0, 0); |
| 336 | break; |
| 337 | case AFSOP_START_BKG2: |
| 338 | sprintf(current->comm, "afs_bkgstart"); |
| 339 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 339 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 340 | complete(arg->complete); |
| 341 | while (afs_initState < AFSOP_START_BKG2) |
| 342 | afs_osi_Sleep(&afs_initState); |
| 343 | if (afs_initState < AFSOP_GO100) { |
| 344 | afs_initState = AFSOP_GO100; |
| 345 | afs_osi_Wakeup(&afs_initState); |
| 346 | } |
| 347 | sprintf(current->comm, "afs_background"); |
| 348 | afs_BackgroundDaemon(); |
| 349 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 349);}while(0); } while(0); |
| 350 | complete_and_exit(0, 0); |
| 351 | break; |
| 352 | case AFSOP_START_TRUNCDAEMON3: |
| 353 | sprintf(current->comm, "afs_trimstart"); |
| 354 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 354 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 355 | complete(arg->complete); |
| 356 | while (afs_initState < AFSOP_GO100) |
| 357 | afs_osi_Sleep(&afs_initState); |
| 358 | sprintf(current->comm, "afs_cachetrim"); |
| 359 | afs_CacheTruncateDaemon(); |
| 360 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 360);}while(0); } while(0); |
| 361 | complete_and_exit(0, 0); |
| 362 | break; |
| 363 | case AFSOP_START_CS4: |
| 364 | sprintf(current->comm, "afs_checkserver"); |
| 365 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 365 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 366 | complete(arg->complete); |
| 367 | afs_CheckServerDaemon(); |
| 368 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 368);}while(0); } while(0); |
| 369 | complete_and_exit(0, 0); |
| 370 | break; |
| 371 | case AFSOP_RXEVENT_DAEMON19: |
| 372 | sprintf(current->comm, "afs_evtstart"); |
| 373 | # ifdef SYS_SETPRIORITY_EXPORTED |
| 374 | sys_setpriority(PRIO_PROCESS, 0, -10); |
| 375 | # else |
| 376 | # ifdef CURRENT_INCLUDES_NICE |
| 377 | current->nice = -10; |
| 378 | # endif |
| 379 | # endif |
| 380 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 380 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 381 | complete(arg->complete); |
| 382 | while (afs_initState < AFSOP_START_BKG2) |
| 383 | afs_osi_Sleep(&afs_initState); |
| 384 | sprintf(current->comm, "afs_rxevent"); |
| 385 | afs_rxevent_daemon(); |
| 386 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 386);}while(0); } while(0); |
| 387 | complete_and_exit(0, 0); |
| 388 | break; |
| 389 | #ifdef RXK_LISTENER_ENV1 |
| 390 | case AFSOP_RXLISTENER_DAEMON48: |
| 391 | sprintf(current->comm, "afs_lsnstart"); |
| 392 | # ifdef SYS_SETPRIORITY_EXPORTED |
| 393 | sys_setpriority(PRIO_PROCESS, 0, -10); |
| 394 | # else |
| 395 | # ifdef CURRENT_INCLUDES_NICE |
| 396 | current->nice = -10; |
| 397 | # endif |
| 398 | # endif |
| 399 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 399 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 400 | complete(arg->complete); |
| 401 | afs_initState = AFSOP_START_AFS1; |
| 402 | afs_osi_Wakeup(&afs_initState); |
| 403 | afs_RX_Running = 2; |
| 404 | afs_osi_Wakeup(&afs_RX_Running); |
| 405 | afs_osi_RxkRegister(); |
| 406 | sprintf(current->comm, "afs_rxlistener"); |
| 407 | rxk_Listener(); |
| 408 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 408);}while(0); } while(0); |
| 409 | complete_and_exit(0, 0); |
| 410 | break; |
| 411 | #endif |
| 412 | default: |
| 413 | afs_warn("Unknown op %ld in StartDaemon()\n", (long)parm); |
| 414 | break; |
| 415 | } |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | void |
| 420 | # if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA) |
| 421 | afsd_launcher(struct work_struct *work) |
| 422 | # else |
| 423 | afsd_launcher(void *rock) |
| 424 | # endif |
| 425 | { |
| 426 | # if defined(AFS_LINUX26_ENV) && !defined(INIT_WORK_HAS_DATA) |
| 427 | struct afsd_thread_info *rock = container_of(work, struct afsd_thread_info, tq); |
| 428 | # endif |
| 429 | |
| 430 | if (!kernel_thread(afsd_thread, (void *)rock, CLONE_VFORK | SIGCHLD20)) |
| 431 | afs_warn("kernel_thread failed. afs startup will not complete\n"); |
| 432 | } |
| 433 | |
| 434 | void |
| 435 | afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, |
| 436 | long parm6) |
| 437 | { |
| 438 | DECLARE_COMPLETION(c); |
| 439 | # if defined(AFS_LINUX26_ENV) |
| 440 | # if defined(INIT_WORK_HAS_DATA) |
| 441 | struct work_struct tq; |
| 442 | # endif |
| 443 | # else |
| 444 | struct tq_struct tq; |
| 445 | # endif |
| 446 | struct afsd_thread_info info; |
| 447 | if (daemonOp_common(parm, parm2, parm3, parm4, parm5, parm6)) { |
| 448 | return; |
| 449 | } |
| 450 | info.complete = &c; |
| 451 | info.parm = parm; |
| 452 | # if defined(AFS_LINUX26_ENV) |
| 453 | # if !defined(INIT_WORK_HAS_DATA) |
| 454 | INIT_WORK(&info.tq, afsd_launcher); |
| 455 | schedule_work(&info.tq); |
| 456 | # else |
| 457 | INIT_WORK(&tq, afsd_launcher, &info); |
| 458 | schedule_work(&tq); |
| 459 | # endif |
| 460 | # else |
| 461 | tq.sync = 0; |
| 462 | INIT_LIST_HEAD(&tq.list); |
| 463 | tq.routine = afsd_launcher; |
| 464 | tq.data = &info; |
| 465 | schedule_task(&tq); |
| 466 | # endif |
| 467 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 467);}while(0); } while(0); |
| 468 | /* we need to wait cause we passed stack pointers around.... */ |
| 469 | wait_for_completion(&c); |
| 470 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 470 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 471 | } |
| 472 | #endif |
| 473 | |
| 474 | #ifdef AFS_SUN5_ENV |
| 475 | struct afs_daemonop_args { |
| 476 | kcondvar_t cv; |
| 477 | long parm; |
| 478 | }; |
| 479 | |
| 480 | static void |
| 481 | afsd_thread(struct afs_daemonop_args *args) |
| 482 | { |
| 483 | long parm = args->parm; |
| 484 | |
| 485 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 485 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 486 | cv_signal(&args->cv); |
| 487 | |
| 488 | switch (parm) { |
| 489 | case AFSOP_START_RXCALLBACK0: |
| 490 | if (afs_CB_Running) |
| 491 | goto out; |
| 492 | afs_CB_Running = 1; |
| 493 | while (afs_RX_Running != 2) |
| 494 | afs_osi_Sleep(&afs_RX_Running); |
| 495 | afs_RXCallBackServer(); |
| 496 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 496);}while(0); } while(0); |
| 497 | return; |
| 498 | case AFSOP_START_AFS1: |
| 499 | if (AFS_Running) |
| 500 | goto out; |
| 501 | AFS_Running = 1; |
| 502 | while (afs_initState < AFSOP_START_AFS1) |
| 503 | afs_osi_Sleep(&afs_initState); |
| 504 | afs_initState = AFSOP_START_BKG2; |
| 505 | afs_osi_Wakeup(&afs_initState); |
| 506 | afs_Daemon(); |
| 507 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 507);}while(0); } while(0); |
| 508 | return; |
| 509 | case AFSOP_START_BKG2: |
| 510 | while (afs_initState < AFSOP_START_BKG2) |
| 511 | afs_osi_Sleep(&afs_initState); |
| 512 | if (afs_initState < AFSOP_GO100) { |
| 513 | afs_initState = AFSOP_GO100; |
| 514 | afs_osi_Wakeup(&afs_initState); |
| 515 | } |
| 516 | afs_BackgroundDaemon(); |
| 517 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 517);}while(0); } while(0); |
| 518 | return; |
| 519 | case AFSOP_START_TRUNCDAEMON3: |
| 520 | while (afs_initState < AFSOP_GO100) |
| 521 | afs_osi_Sleep(&afs_initState); |
| 522 | afs_CacheTruncateDaemon(); |
| 523 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 523);}while(0); } while(0); |
| 524 | return; |
| 525 | case AFSOP_START_CS4: |
| 526 | afs_CheckServerDaemon(); |
| 527 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 527);}while(0); } while(0); |
| 528 | return; |
| 529 | case AFSOP_RXEVENT_DAEMON19: |
| 530 | while (afs_initState < AFSOP_START_BKG2) |
| 531 | afs_osi_Sleep(&afs_initState); |
| 532 | afs_rxevent_daemon(); |
| 533 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 533);}while(0); } while(0); |
| 534 | return; |
| 535 | case AFSOP_RXLISTENER_DAEMON48: |
| 536 | afs_initState = AFSOP_START_AFS1; |
| 537 | afs_osi_Wakeup(&afs_initState); |
| 538 | afs_RX_Running = 2; |
| 539 | afs_osi_Wakeup(&afs_RX_Running); |
| 540 | afs_osi_RxkRegister(); |
| 541 | rxk_Listener(); |
| 542 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 542);}while(0); } while(0); |
| 543 | return; |
| 544 | default: |
| 545 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 545);}while(0); } while(0); |
| 546 | afs_warn("Unknown op %ld in afsd_thread()\n", parm); |
| 547 | return; |
| 548 | } |
| 549 | out: |
| 550 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 550);}while(0); } while(0); |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | static void |
| 555 | afs_DaemonOp(long parm, long parm2, long parm3, long parm4, long parm5, |
| 556 | long parm6) |
| 557 | { |
| 558 | struct afs_daemonop_args args; |
| 559 | |
| 560 | if (daemonOp_common(parm, parm2, parm3, parm4, parm5, parm6)) { |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | args.parm = parm; |
| 565 | |
| 566 | cv_init(&args.cv, "AFS DaemonOp cond var", CV_DEFAULT, NULL((void *)0)); |
| 567 | |
| 568 | if (thread_create(NULL((void *)0), 0, afsd_thread, &args, 0, &p0, TS_RUN, |
| 569 | minclsyspri) == NULL((void *)0)) { |
| 570 | |
| 571 | afs_warn("thread_create failed: AFS startup will not complete\n"); |
| 572 | } |
| 573 | |
| 574 | /* we passed &args to the new thread, which is on the stack. wait until |
| 575 | * it has read the arguments so it doesn't try to read the args after we |
| 576 | * have returned */ |
| 577 | cv_wait(&args.cv, &afs_global_lock); |
| 578 | |
| 579 | cv_destroy(&args.cv); |
| 580 | } |
| 581 | #endif /* AFS_SUN5_ENV */ |
| 582 | |
| 583 | #ifdef AFS_DARWIN100_ENV |
| 584 | # define AFSKPTR(X)((caddr_t)X) k ## X |
| 585 | int |
| 586 | afs_syscall_call(long parm, long parm2, long parm3, |
| 587 | long parm4, long parm5, long parm6) |
| 588 | { |
| 589 | return afs_syscall64_call(CAST_USER_ADDR_T((parm)), |
| 590 | CAST_USER_ADDR_T((parm2)), |
| 591 | CAST_USER_ADDR_T((parm3)), |
| 592 | CAST_USER_ADDR_T((parm4)), |
| 593 | CAST_USER_ADDR_T((parm5)), |
| 594 | CAST_USER_ADDR_T((parm6))); |
| 595 | } |
| 596 | #else |
| 597 | # define AFSKPTR(X)((caddr_t)X) ((caddr_t)X) |
| 598 | #endif |
| 599 | int |
| 600 | #ifdef AFS_DARWIN100_ENV |
| 601 | afs_syscall64_call(user_addr_t kparm, user_addr_t kparm2, user_addr_t kparm3, |
| 602 | user_addr_t kparm4, user_addr_t kparm5, user_addr_t kparm6) |
| 603 | #else |
| 604 | afs_syscall_call(long parm, long parm2, long parm3, |
| 605 | long parm4, long parm5, long parm6) |
| 606 | #endif |
| 607 | { |
| 608 | afs_int32 code = 0; |
| 609 | #if defined(AFS_SGI61_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) |
| 610 | size_t bufferSize; |
| 611 | #else /* AFS_SGI61_ENV */ |
| 612 | u_int bufferSize; |
| 613 | #endif /* AFS_SGI61_ENV */ |
| 614 | #ifdef AFS_DARWIN100_ENV |
| 615 | /* AFSKPTR macro relies on this name format/mapping */ |
| 616 | afs_uint32 parm = (afs_uint32)kparm; |
| 617 | afs_uint32 parm2 = (afs_uint32)kparm2; |
| 618 | afs_uint32 parm3 = (afs_uint32)kparm3; |
| 619 | afs_uint32 parm4 = (afs_uint32)kparm4; |
| 620 | afs_uint32 parm5 = (afs_uint32)kparm5; |
| 621 | afs_uint32 parm6 = (afs_uint32)kparm6; |
| 622 | #endif |
| 623 | |
| 624 | AFS_STATCNT(afs_syscall_call)((afs_cmstats.callInfo.C_afs_syscall_call)++); |
| 625 | if ( |
| 626 | #ifdef AFS_SUN5_ENV |
| 627 | !afs_suser(CRED()) |
| 628 | #else |
| 629 | !afs_suser(NULL((void *)0)) |
| 630 | #endif |
| 631 | && (parm != AFSOP_GETMTU20) && (parm != AFSOP_GETMASK42)) { |
| 632 | /* only root can run this code */ |
| 633 | #if defined(AFS_SUN5_ENV) || defined(KERNEL_HAVE_UERROR) |
| 634 | # if defined(KERNEL_HAVE_UERROR) |
| 635 | setuerror(EACCES)get_user_struct()->u_error = (13); |
| 636 | # endif |
| 637 | code = EACCES13; |
| 638 | #else |
| 639 | code = EPERM1; |
| 640 | #endif |
| 641 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 641 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 642 | #ifdef AFS_DARWIN80_ENV |
| 643 | put_vfs_context(); |
| 644 | #endif |
| 645 | goto out; |
| 646 | } |
| 647 | AFS_GLOCK()do { do{if (!(pthread_mutex_lock(&afs_global_lock) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c", 647 );}while(0); afs_global_owner = pthread_self(); } while(0); |
| 648 | #ifdef AFS_DARWIN80_ENV |
| 649 | put_vfs_context(); |
| 650 | #endif |
| 651 | #ifdef AFS_DAEMONOP_ENV |
| 652 | # if defined(AFS_DARWIN80_ENV) |
| 653 | if (parm == AFSOP_BKG_HANDLER41) { |
| 654 | /* if afs_uspc_param grows this should be checked */ |
| 655 | struct afs_uspc_param *mvParam = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 656 | void *param2; |
| 657 | void *param1; |
| 658 | int namebufsz; |
| 659 | |
| 660 | AFS_COPYIN(AFSKPTR(parm2), (caddr_t)mvParam,do { code = (memcpy((void *)((caddr_t)mvParam),(void *)((((caddr_t )parm2))),(sizeof(struct afs_uspc_param))), 0); } while(0) |
| 661 | sizeof(struct afs_uspc_param), code)do { code = (memcpy((void *)((caddr_t)mvParam),(void *)((((caddr_t )parm2))),(sizeof(struct afs_uspc_param))), 0); } while(0); |
| 662 | namebufsz = mvParam->bufSz; |
| 663 | param1 = afs_osi_Alloc(namebufsz); |
| 664 | osi_Assert(param1 != NULL)(void)((param1 != ((void *)0)) || (osi_AssertFailK( "param1 != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 664), 0)); |
| 665 | param2 = afs_osi_Alloc(namebufsz); |
| 666 | osi_Assert(param2 != NULL)(void)((param2 != ((void *)0)) || (osi_AssertFailK( "param2 != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 666), 0)); |
| 667 | |
| 668 | while (afs_initState < AFSOP_START_BKG2) |
| 669 | afs_osi_Sleep(&afs_initState); |
| 670 | if (afs_initState < AFSOP_GO100) { |
| 671 | afs_initState = AFSOP_GO100; |
| 672 | afs_osi_Wakeup(&afs_initState); |
| 673 | } |
| 674 | |
| 675 | code = afs_BackgroundDaemon(mvParam, param1, param2); |
| 676 | |
| 677 | if (!code) { |
| 678 | mvParam->retval = 0; |
| 679 | /* for reqs where pointers are strings: */ |
| 680 | if (mvParam->reqtype == AFS_USPC_UMV1) { |
| 681 | /* don't copy out random kernel memory */ |
| 682 | AFS_COPYOUT(param2, AFSKPTR(parm4),do { code = (memcpy((void *)((((caddr_t)parm4))),(void *)(param2 ),((((namebufsz)<(strlen((char *)param2)+1))?(namebufsz):( strlen((char *)param2)+1)))), 0); } while(0) |
| 683 | MIN(namebufsz, strlen((char *)param2)+1), code)do { code = (memcpy((void *)((((caddr_t)parm4))),(void *)(param2 ),((((namebufsz)<(strlen((char *)param2)+1))?(namebufsz):( strlen((char *)param2)+1)))), 0); } while(0); |
| 684 | AFS_COPYOUT(param1, AFSKPTR(parm3),do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)(param1 ),((((namebufsz)<(strlen((char *)param1)+1))?(namebufsz):( strlen((char *)param1)+1)))), 0); } while(0) |
| 685 | MIN(namebufsz, strlen((char *)param1)+1), code)do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)(param1 ),((((namebufsz)<(strlen((char *)param1)+1))?(namebufsz):( strlen((char *)param1)+1)))), 0); } while(0); |
| 686 | } |
| 687 | AFS_COPYOUT((caddr_t)mvParam, AFSKPTR(parm2),do { code = (memcpy((void *)((((caddr_t)parm2))),(void *)((caddr_t )mvParam),(sizeof(struct afs_uspc_param))), 0); } while(0) |
| 688 | sizeof(struct afs_uspc_param), code)do { code = (memcpy((void *)((((caddr_t)parm2))),(void *)((caddr_t )mvParam),(sizeof(struct afs_uspc_param))), 0); } while(0); |
| 689 | } |
| 690 | |
| 691 | afs_osi_Free(param1, namebufsz); |
| 692 | afs_osi_Free(param2, namebufsz); |
| 693 | osi_FreeSmallSpace(mvParam); |
| 694 | } else |
| 695 | # endif /* DARWIN80 */ |
| 696 | if (parm < AFSOP_ADDCELL5 || parm == AFSOP_RXEVENT_DAEMON19 |
| 697 | || parm == AFSOP_RXLISTENER_DAEMON48) { |
| 698 | afs_DaemonOp(parm, parm2, parm3, parm4, parm5, parm6); |
| 699 | } |
| 700 | #else /* !AFS_DAEMONOP_ENV */ |
| 701 | if (parm == AFSOP_START_RXCALLBACK0) { |
| 702 | if (afs_CB_Running) |
| 703 | goto out; |
| 704 | afs_CB_Running = 1; |
| 705 | # ifndef RXK_LISTENER_ENV1 |
| 706 | code = afs_InitSetup(parm2); |
| 707 | if (!code) |
| 708 | # endif /* !RXK_LISTENER_ENV */ |
| 709 | { |
| 710 | # ifdef RXK_LISTENER_ENV1 |
| 711 | while (afs_RX_Running != 2) |
| 712 | afs_osi_Sleep(&afs_RX_Running); |
| 713 | # else /* !RXK_LISTENER_ENV */ |
| 714 | if (parm3) { |
| 715 | rx_enablePeerRPCStats(); |
| 716 | } |
| 717 | if (parm4) { |
| 718 | rx_enableProcessRPCStats(); |
| 719 | } |
| 720 | afs_initState = AFSOP_START_AFS1; |
| 721 | afs_osi_Wakeup(&afs_initState); |
| 722 | # endif /* RXK_LISTENER_ENV */ |
| 723 | afs_osi_Invisible(); |
| 724 | afs_RXCallBackServer(); |
| 725 | afs_osi_Visible(); |
| 726 | } |
| 727 | # ifdef AFS_SGI_ENV |
| 728 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 728);}while(0); } while(0); |
| 729 | exit(CLD_EXITED1, code); |
| 730 | # endif /* AFS_SGI_ENV */ |
| 731 | } |
| 732 | # ifdef RXK_LISTENER_ENV1 |
| 733 | else if (parm == AFSOP_RXLISTENER_DAEMON48) { |
| 734 | if (afs_RX_Running) |
| 735 | goto out; |
| 736 | afs_RX_Running = 1; |
| 737 | code = afs_InitSetup(parm2); |
| 738 | if (parm3) { |
| 739 | rx_enablePeerRPCStats(); |
| 740 | } |
| 741 | if (parm4) { |
| 742 | rx_enableProcessRPCStats(); |
| 743 | } |
| 744 | if (!code) { |
| 745 | afs_initState = AFSOP_START_AFS1; |
| 746 | afs_osi_Wakeup(&afs_initState); |
| 747 | afs_osi_Invisible(); |
| 748 | afs_RX_Running = 2; |
| 749 | afs_osi_Wakeup(&afs_RX_Running); |
| 750 | # ifndef UKERNEL1 |
| 751 | afs_osi_RxkRegister(); |
| 752 | # endif /* !UKERNEL */ |
| 753 | rxk_Listener(); |
| 754 | afs_osi_Visible(); |
| 755 | } |
| 756 | # ifdef AFS_SGI_ENV |
| 757 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 757);}while(0); } while(0); |
| 758 | exit(CLD_EXITED1, code); |
| 759 | # endif /* AFS_SGI_ENV */ |
| 760 | } |
| 761 | # endif /* RXK_LISTENER_ENV */ |
| 762 | else if (parm == AFSOP_START_AFS1) { |
| 763 | /* afs daemon */ |
| 764 | if (AFS_Running) |
| 765 | goto out; |
| 766 | AFS_Running = 1; |
| 767 | while (afs_initState < AFSOP_START_AFS1) |
| 768 | afs_osi_Sleep(&afs_initState); |
| 769 | |
| 770 | afs_initState = AFSOP_START_BKG2; |
| 771 | afs_osi_Wakeup(&afs_initState); |
| 772 | afs_osi_Invisible(); |
| 773 | afs_Daemon(); |
| 774 | afs_osi_Visible(); |
| 775 | # ifdef AFS_SGI_ENV |
| 776 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 776);}while(0); } while(0); |
| 777 | exit(CLD_EXITED1, 0); |
| 778 | # endif /* AFS_SGI_ENV */ |
| 779 | } else if (parm == AFSOP_START_CS4) { |
| 780 | afs_osi_Invisible(); |
| 781 | afs_CheckServerDaemon(); |
| 782 | afs_osi_Visible(); |
| 783 | # ifdef AFS_SGI_ENV |
| 784 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 784);}while(0); } while(0); |
| 785 | exit(CLD_EXITED1, 0); |
| 786 | # endif /* AFS_SGI_ENV */ |
| 787 | # ifndef AFS_DARWIN80_ENV |
| 788 | } else if (parm == AFSOP_START_BKG2) { |
| 789 | while (afs_initState < AFSOP_START_BKG2) |
| 790 | afs_osi_Sleep(&afs_initState); |
| 791 | if (afs_initState < AFSOP_GO100) { |
| 792 | afs_initState = AFSOP_GO100; |
| 793 | afs_osi_Wakeup(&afs_initState); |
| 794 | } |
| 795 | /* start the bkg daemon */ |
| 796 | afs_osi_Invisible(); |
| 797 | # ifdef AFS_AIX32_ENV |
| 798 | if (parm2) |
| 799 | afs_BioDaemon(parm2); |
| 800 | else |
| 801 | # endif /* AFS_AIX32_ENV */ |
| 802 | afs_BackgroundDaemon(); |
| 803 | afs_osi_Visible(); |
| 804 | # ifdef AFS_SGI_ENV |
| 805 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 805);}while(0); } while(0); |
| 806 | exit(CLD_EXITED1, 0); |
| 807 | # endif /* AFS_SGI_ENV */ |
| 808 | # endif /* ! AFS_DARWIN80_ENV */ |
| 809 | } else if (parm == AFSOP_START_TRUNCDAEMON3) { |
| 810 | while (afs_initState < AFSOP_GO100) |
| 811 | afs_osi_Sleep(&afs_initState); |
| 812 | /* start the bkg daemon */ |
| 813 | afs_osi_Invisible(); |
| 814 | afs_CacheTruncateDaemon(); |
| 815 | afs_osi_Visible(); |
| 816 | # ifdef AFS_SGI_ENV |
| 817 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 817);}while(0); } while(0); |
| 818 | exit(CLD_EXITED1, 0); |
| 819 | # endif /* AFS_SGI_ENV */ |
| 820 | } |
| 821 | # if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV1) || defined(RXK_UPCALL_ENV) |
| 822 | else if (parm == AFSOP_RXEVENT_DAEMON19) { |
| 823 | while (afs_initState < AFSOP_START_BKG2) |
| 824 | afs_osi_Sleep(&afs_initState); |
| 825 | afs_osi_Invisible(); |
| 826 | afs_rxevent_daemon(); |
| 827 | afs_osi_Visible(); |
| 828 | # ifdef AFS_SGI_ENV |
| 829 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 829);}while(0); } while(0); |
| 830 | exit(CLD_EXITED1, 0); |
| 831 | # endif /* AFS_SGI_ENV */ |
| 832 | } |
| 833 | # endif /* AFS_SUN5_ENV || RXK_LISTENER_ENV || RXK_UPCALL_ENV */ |
| 834 | #endif /* AFS_DAEMONOP_ENV */ |
| 835 | else if (parm == AFSOP_BASIC_INIT36) { |
| 836 | afs_int32 temp; |
| 837 | |
| 838 | while (!afs_InitSetup_done) |
| 839 | afs_osi_Sleep(&afs_InitSetup_done); |
| 840 | |
| 841 | #if defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_SUN5_ENV) |
| 842 | temp = AFS_MINBUFFERS50; /* Should fix this soon */ |
| 843 | #else |
| 844 | /* number of 2k buffers we could get from all of the buffer space */ |
| 845 | temp = ((afs_bufferpages * NBPG4096) >> 11); |
| 846 | temp = temp >> 2; /* don't take more than 25% (our magic parameter) */ |
| 847 | if (temp < AFS_MINBUFFERS50) |
| 848 | temp = AFS_MINBUFFERS50; /* though we really should have this many */ |
| 849 | #endif |
| 850 | DInit(temp); |
| 851 | afs_rootFid.Fid.Volume = 0; |
| 852 | code = 0; |
| 853 | } else if (parm == AFSOP_BUCKETPCT39) { |
| 854 | /* need to enable this now, will disable again before GO |
| 855 | if we don't have 100% */ |
| 856 | splitdcache = 1; |
| 857 | switch (parm2) { |
| 858 | case 1: |
| 859 | afs_tpct1 = parm3; |
| 860 | break; |
| 861 | case 2: |
| 862 | afs_tpct2 = parm3; |
| 863 | break; |
| 864 | } |
| 865 | } else if (parm == AFSOP_ADDCELL5) { |
| 866 | /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated |
| 867 | * name. Parameter 4 is the length of the name, including the null. Parm 5 is the |
| 868 | * home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */ |
| 869 | struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell)); |
| 870 | |
| 871 | osi_Assert(tcell != NULL)(void)((tcell != ((void *)0)) || (osi_AssertFailK( "tcell != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 871), 0)); |
| 872 | code = afs_InitDynroot(); |
| 873 | if (!code) { |
| 874 | AFS_COPYIN(AFSKPTR(parm2), (caddr_t)tcell->hosts, sizeof(tcell->hosts),do { code = (memcpy((void *)((caddr_t)tcell->hosts),(void * )((((caddr_t)parm2))),(sizeof(tcell->hosts))), 0); } while (0) |
| 875 | code)do { code = (memcpy((void *)((caddr_t)tcell->hosts),(void * )((((caddr_t)parm2))),(sizeof(tcell->hosts))), 0); } while (0); |
| 876 | } |
| 877 | if (!code) { |
| 878 | if (parm4 > sizeof(tcell->cellName)) |
| 879 | code = EFAULT14; |
| 880 | else { |
| 881 | AFS_COPYIN(AFSKPTR(parm3), (caddr_t)tcell->cellName, parm4, code)do { code = (memcpy((void *)((caddr_t)tcell->cellName),(void *)((((caddr_t)parm3))),(parm4)), 0); } while(0); |
| 882 | if (!code) |
| 883 | afs_NewCell(tcell->cellName, tcell->hosts, parm5, NULL((void *)0), 0, |
| 884 | 0, 0); |
| 885 | } |
| 886 | } |
| 887 | afs_osi_Free(tcell, sizeof(struct afsop_cell)); |
| 888 | } else if (parm == AFSOP_ADDCELL229) { |
| 889 | struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell)); |
| 890 | char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))), *lcnamep = 0; |
| 891 | char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 892 | int cflags = parm4; |
| 893 | |
| 894 | osi_Assert(tcell != NULL)(void)((tcell != ((void *)0)) || (osi_AssertFailK( "tcell != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 894), 0)); |
| 895 | osi_Assert(tbuffer != NULL)(void)((tbuffer != ((void *)0)) || (osi_AssertFailK( "tbuffer != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 895), 0)); |
| 896 | osi_Assert(tbuffer1 != NULL)(void)((tbuffer1 != ((void *)0)) || (osi_AssertFailK( "tbuffer1 != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 896), 0)); |
| 897 | code = afs_InitDynroot(); |
| 898 | if (!code) { |
| 899 | #if 0 |
| 900 | /* wait for basic init - XXX can't find any reason we need this? */ |
| 901 | while (afs_initState < AFSOP_START_BKG2) |
| 902 | afs_osi_Sleep(&afs_initState); |
| 903 | #endif |
| 904 | |
| 905 | AFS_COPYIN(AFSKPTR(parm2), (caddr_t)tcell->hosts, sizeof(tcell->hosts),do { code = (memcpy((void *)((caddr_t)tcell->hosts),(void * )((((caddr_t)parm2))),(sizeof(tcell->hosts))), 0); } while (0) |
| 906 | code)do { code = (memcpy((void *)((caddr_t)tcell->hosts),(void * )((((caddr_t)parm2))),(sizeof(tcell->hosts))), 0); } while (0); |
| 907 | } |
| 908 | if (!code) { |
| 909 | AFS_COPYINSTR(AFSKPTR(parm3), tbuffer1, AFS_SMALLOCSIZ,do { code = (strncpy((tbuffer1),((((caddr_t)parm3))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer1)), 0); } while (0) |
| 910 | &bufferSize, code)do { code = (strncpy((tbuffer1),((((caddr_t)parm3))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer1)), 0); } while (0); |
| 911 | if (!code) { |
| 912 | if (parm4 & 4) { |
| 913 | AFS_COPYINSTR(AFSKPTR(parm5), tbuffer, AFS_SMALLOCSIZ,do { code = (strncpy((tbuffer),((((caddr_t)parm5))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer)), 0); } while (0) |
| 914 | &bufferSize, code)do { code = (strncpy((tbuffer),((((caddr_t)parm5))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer)), 0); } while (0); |
| 915 | if (!code) { |
| 916 | lcnamep = tbuffer; |
| 917 | cflags |= CLinkedCell0x20; |
| 918 | } |
| 919 | } |
| 920 | if (parm4 & 8) { |
| 921 | cflags |= CHush0x40; |
| 922 | } |
| 923 | if (!code) |
| 924 | code = |
| 925 | afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep, |
| 926 | 0, 0, 0); |
| 927 | } |
| 928 | } |
| 929 | afs_osi_Free(tcell, sizeof(struct afsop_cell)); |
| 930 | osi_FreeSmallSpace(tbuffer); |
| 931 | osi_FreeSmallSpace(tbuffer1); |
| 932 | } else if (parm == AFSOP_ADDCELLALIAS32) { |
| 933 | /* |
| 934 | * Call arguments: |
| 935 | * parm2 is the alias name |
| 936 | * parm3 is the real cell name |
| 937 | */ |
| 938 | char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 939 | char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 940 | |
| 941 | code = afs_InitDynroot(); |
| 942 | if (!code) { |
| 943 | AFS_COPYINSTR(AFSKPTR(parm2), aliasName, AFS_SMALLOCSIZ, &bufferSize,do { code = (strncpy((aliasName),((((caddr_t)parm2))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((aliasName)), 0); } while (0) |
| 944 | code)do { code = (strncpy((aliasName),((((caddr_t)parm2))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((aliasName)), 0); } while (0); |
| 945 | } |
| 946 | if (!code) |
| 947 | AFS_COPYINSTR(AFSKPTR(parm3), cellName, AFS_SMALLOCSIZ,do { code = (strncpy((cellName),((((caddr_t)parm3))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((cellName)), 0); } while (0) |
| 948 | &bufferSize, code)do { code = (strncpy((cellName),((((caddr_t)parm3))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((cellName)), 0); } while (0); |
| 949 | if (!code) |
| 950 | afs_NewCellAlias(aliasName, cellName); |
| 951 | osi_FreeSmallSpace(aliasName); |
| 952 | osi_FreeSmallSpace(cellName); |
| 953 | } else if (parm == AFSOP_SET_THISCELL35) { |
| 954 | /* |
| 955 | * Call arguments: |
| 956 | * parm2 is the primary cell name |
| 957 | */ |
| 958 | char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 959 | |
| 960 | afs_CellInit(); |
| 961 | AFS_COPYINSTR(AFSKPTR(parm2), cell, AFS_SMALLOCSIZ, &bufferSize, code)do { code = (strncpy((cell),((((caddr_t)parm2))),((64*sizeof( void *)))),(*(&bufferSize))=strlen((cell)), 0); } while(0 ); |
| 962 | if (!code) |
| 963 | afs_SetPrimaryCell(cell); |
| 964 | osi_FreeSmallSpace(cell); |
| 965 | if (!code) { |
| 966 | code = afs_InitDynroot(); |
| 967 | } |
| 968 | } else if (parm == AFSOP_CACHEINIT6) { |
| 969 | struct afs_cacheParams cparms; |
| 970 | |
| 971 | if (afs_CacheInit_Done) |
| 972 | goto out; |
| 973 | |
| 974 | AFS_COPYIN(AFSKPTR(parm2), (caddr_t) & cparms, sizeof(cparms), code)do { code = (memcpy((void *)((caddr_t) & cparms),(void *) ((((caddr_t)parm2))),(sizeof(cparms))), 0); } while(0); |
| 975 | if (code) { |
| 976 | #if defined(KERNEL_HAVE_UERROR) |
| 977 | setuerror(code)get_user_struct()->u_error = (code); |
| 978 | code = -1; |
| 979 | #endif |
| 980 | goto out; |
| 981 | } |
| 982 | afs_CacheInit_Done = 1; |
| 983 | code = afs_icl_InitLogs(); |
| 984 | afs_setTime = cparms.setTimeFlag; |
| 985 | |
| 986 | code = |
| 987 | afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles, |
| 988 | cparms.cacheBlocks, cparms.cacheDcaches, |
| 989 | cparms.cacheVolumes, cparms.chunkSize, |
| 990 | cparms.memCacheFlag, cparms.inodes, cparms.users, |
| 991 | cparms.dynamic_vcaches); |
| 992 | |
| 993 | } else if (parm == AFSOP_CACHEINODE10) { |
| 994 | ino_tusr_ino_t ainode = parm2; |
| 995 | /* wait for basic init */ |
| 996 | while (afs_initState < AFSOP_START_BKG2) |
| 997 | afs_osi_Sleep(&afs_initState); |
| 998 | |
| 999 | #ifdef AFS_DARWIN80_ENV |
| 1000 | get_vfs_context(); |
| 1001 | #endif |
| 1002 | /* do it by inode */ |
| 1003 | #ifdef AFS_SGI62_ENV |
| 1004 | ainode = (ainode << 32) | (parm3 & 0xffffffff); |
| 1005 | #endif |
| 1006 | code = afs_InitCacheFile(NULL((void *)0), ainode); |
| 1007 | #ifdef AFS_DARWIN80_ENV |
| 1008 | put_vfs_context(); |
| 1009 | #endif |
| 1010 | } else if (parm == AFSOP_CACHEDIRS51) { |
| 1011 | afs_numfilesperdir = parm2; |
| 1012 | afs_osi_Wakeup(&afs_initState); |
| 1013 | } else if (parm == AFSOP_CACHEFILES52) { |
| 1014 | afs_numcachefiles = parm2; |
| 1015 | afs_osi_Wakeup(&afs_initState); |
| 1016 | } else if (parm == AFSOP_ROOTVOLUME12) { |
| 1017 | /* wait for basic init */ |
| 1018 | while (afs_initState < AFSOP_START_BKG2) |
| 1019 | afs_osi_Sleep(&afs_initState); |
| 1020 | |
| 1021 | if (parm2) { |
| 1022 | AFS_COPYINSTR(AFSKPTR(parm2), afs_rootVolumeName,do { code = (strncpy((afs_rootVolumeName),((((caddr_t)parm2)) ),(sizeof(afs_rootVolumeName))),(*(&bufferSize))=strlen(( afs_rootVolumeName)), 0); } while(0) |
| 1023 | sizeof(afs_rootVolumeName), &bufferSize, code)do { code = (strncpy((afs_rootVolumeName),((((caddr_t)parm2)) ),(sizeof(afs_rootVolumeName))),(*(&bufferSize))=strlen(( afs_rootVolumeName)), 0); } while(0); |
| 1024 | afs_rootVolumeName[sizeof(afs_rootVolumeName) - 1] = 0; |
| 1025 | } else |
| 1026 | code = 0; |
| 1027 | } else if (parm == AFSOP_CACHEFILE9 || parm == AFSOP_CACHEINFO7 |
| 1028 | || parm == AFSOP_VOLUMEINFO8 || parm == AFSOP_CELLINFO34) { |
| 1029 | char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ(64*sizeof(void *))); |
| 1030 | |
| 1031 | code = 0; |
| 1032 | AFS_COPYINSTR(AFSKPTR(parm2), tbuffer, AFS_SMALLOCSIZ, &bufferSize,do { code = (strncpy((tbuffer),((((caddr_t)parm2))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer)), 0); } while (0) |
| 1033 | code)do { code = (strncpy((tbuffer),((((caddr_t)parm2))),((64*sizeof (void *)))),(*(&bufferSize))=strlen((tbuffer)), 0); } while (0); |
| 1034 | if (code) { |
| 1035 | osi_FreeSmallSpace(tbuffer); |
| 1036 | goto out; |
| 1037 | } |
| 1038 | if (!code) { |
| 1039 | tbuffer[AFS_SMALLOCSIZ(64*sizeof(void *)) - 1] = '\0'; /* null-terminate the name */ |
| 1040 | /* We have the cache dir copied in. Call the cache init routine */ |
| 1041 | #ifdef AFS_DARWIN80_ENV |
| 1042 | get_vfs_context(); |
| 1043 | #endif |
| 1044 | if (parm == AFSOP_CACHEFILE9) { |
| 1045 | code = afs_InitCacheFile(tbuffer, 0); |
| 1046 | } else if (parm == AFSOP_CACHEINFO7) { |
| 1047 | code = afs_InitCacheInfo(tbuffer); |
| 1048 | } else if (parm == AFSOP_VOLUMEINFO8) { |
| 1049 | code = afs_InitVolumeInfo(tbuffer); |
| 1050 | } else if (parm == AFSOP_CELLINFO34) { |
| 1051 | code = afs_InitCellInfo(tbuffer); |
| 1052 | } |
| 1053 | #ifdef AFS_DARWIN80_ENV |
| 1054 | put_vfs_context(); |
| 1055 | #endif |
| 1056 | } |
| 1057 | osi_FreeSmallSpace(tbuffer); |
| 1058 | } else if (parm == AFSOP_GO100) { |
| 1059 | /* the generic initialization calls come here. One parameter: should we do the |
| 1060 | * set-time operation on this workstation */ |
| 1061 | if (afs_Go_Done) |
| 1062 | goto out; |
| 1063 | afs_Go_Done = 1; |
| 1064 | while (afs_initState < AFSOP_GO100) |
| 1065 | afs_osi_Sleep(&afs_initState); |
| 1066 | afs_initState = 101; |
| 1067 | afs_setTime = parm2; |
| 1068 | if (afs_tpct1 + afs_tpct2 != 100) { |
| 1069 | afs_tpct1 = 0; |
| 1070 | afs_tpct2 = 0; |
| 1071 | splitdcache = 0; |
| 1072 | } else { |
| 1073 | splitdcache = 1; |
| 1074 | } |
| 1075 | afs_osi_Wakeup(&afs_initState); |
| 1076 | #if (!defined(AFS_NONFSTRANS1)) || defined(AFS_AIX_IAUTH_ENV) |
| 1077 | afs_nfsclient_init(); |
| 1078 | #endif |
| 1079 | afs_uuid_create(&afs_cb_interface.uuid); |
| 1080 | printf("found %d non-empty cache files (%d%%).\n", |
| 1081 | afs_stats_cmperf.cacheFilesReused, |
| 1082 | (100 * afs_stats_cmperf.cacheFilesReused) / |
| 1083 | (afs_stats_cmperf.cacheNumEntries ? afs_stats_cmperf. |
| 1084 | cacheNumEntries : 1)); |
| 1085 | } else if (parm == AFSOP_ADVISEADDR17) { |
| 1086 | /* pass in the host address to the rx package */ |
| 1087 | int rxbind = 0; |
| 1088 | int refresh = 0; |
| 1089 | |
| 1090 | afs_int32 count = parm2; |
| 1091 | afs_int32 *buffer = |
| 1092 | afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1093 | afs_int32 *maskbuffer = |
| 1094 | afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1095 | afs_int32 *mtubuffer = |
| 1096 | afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1097 | int i; |
| 1098 | |
| 1099 | osi_Assert(buffer != NULL)(void)((buffer != ((void *)0)) || (osi_AssertFailK( "buffer != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 1099), 0)); |
| 1100 | osi_Assert(maskbuffer != NULL)(void)((maskbuffer != ((void *)0)) || (osi_AssertFailK( "maskbuffer != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 1100), 0)); |
| 1101 | osi_Assert(mtubuffer != NULL)(void)((mtubuffer != ((void *)0)) || (osi_AssertFailK( "mtubuffer != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 1101), 0)); |
| 1102 | /* This is a refresh */ |
| 1103 | if (count & 0x40000000) { |
| 1104 | count &= ~0x40000000; |
| 1105 | /* Can't bind after we start. Fix? */ |
| 1106 | count &= ~0x80000000; |
| 1107 | refresh = 1; |
| 1108 | } |
| 1109 | |
| 1110 | /* Bind, but only if there's only one address configured */ |
| 1111 | if ( count & 0x80000000) { |
| 1112 | count &= ~0x80000000; |
| 1113 | if (count == 1) |
| 1114 | rxbind=1; |
| 1115 | } |
| 1116 | |
| 1117 | if (count > AFS_MAX_INTERFACE_ADDR32) { |
| 1118 | code = ENOMEM12; |
Value stored to 'code' is never read | |
| 1119 | count = AFS_MAX_INTERFACE_ADDR32; |
| 1120 | } |
| 1121 | |
| 1122 | AFS_COPYIN(AFSKPTR(parm3), (caddr_t)buffer, count * sizeof(afs_int32),do { code = (memcpy((void *)((caddr_t)buffer),(void *)((((caddr_t )parm3))),(count * sizeof(afs_int32))), 0); } while(0) |
| 1123 | code)do { code = (memcpy((void *)((caddr_t)buffer),(void *)((((caddr_t )parm3))),(count * sizeof(afs_int32))), 0); } while(0); |
| 1124 | if (parm4 && !code) |
| 1125 | AFS_COPYIN(AFSKPTR(parm4), (caddr_t)maskbuffer,do { code = (memcpy((void *)((caddr_t)maskbuffer),(void *)((( (caddr_t)parm4))),(count * sizeof(afs_int32))), 0); } while(0 ) |
| 1126 | count * sizeof(afs_int32), code)do { code = (memcpy((void *)((caddr_t)maskbuffer),(void *)((( (caddr_t)parm4))),(count * sizeof(afs_int32))), 0); } while(0 ); |
| 1127 | if (parm5 && !code) |
| 1128 | AFS_COPYIN(AFSKPTR(parm5), (caddr_t)mtubuffer,do { code = (memcpy((void *)((caddr_t)mtubuffer),(void *)(((( caddr_t)parm5))),(count * sizeof(afs_int32))), 0); } while(0) |
| 1129 | count * sizeof(afs_int32), code)do { code = (memcpy((void *)((caddr_t)mtubuffer),(void *)(((( caddr_t)parm5))),(count * sizeof(afs_int32))), 0); } while(0); |
| 1130 | |
| 1131 | if (!code) { |
| 1132 | afs_cb_interface.numberOfInterfaces = count; |
| 1133 | for (i = 0; i < count; i++) { |
| 1134 | afs_cb_interface.addr_in[i] = buffer[i]; |
| 1135 | #ifdef AFS_USERSPACE_IP_ADDR1 |
| 1136 | /* AFS_USERSPACE_IP_ADDR means we have no way of finding the |
| 1137 | * machines IP addresses when in the kernel (the in_ifaddr |
| 1138 | * struct is not available), so we pass the info in at |
| 1139 | * startup. We also pass in the subnetmask and mtu size. The |
| 1140 | * subnetmask is used when setting the rank: |
| 1141 | * afsi_SetServerIPRank(); and the mtu size is used when |
| 1142 | * finding the best mtu size. rxi_FindIfnet() is replaced |
| 1143 | * with rxi_Findcbi(). |
| 1144 | */ |
| 1145 | afs_cb_interface.subnetmask[i] = |
| 1146 | (parm4 ? maskbuffer[i] : 0xffffffff); |
| 1147 | afs_cb_interface.mtu[i] = (parm5 ? mtubuffer[i] : htonl(1500)(__builtin_constant_p(1500) ? ((((__uint32_t)(1500)) >> 24) | ((((__uint32_t)(1500)) & (0xff << 16)) >> 8) | ((((__uint32_t)(1500)) & (0xff << 8)) << 8) | (((__uint32_t)(1500)) << 24)) : __bswap32_var(1500 ))); |
| 1148 | #endif |
| 1149 | } |
| 1150 | rxi_setaddr(buffer[0]); |
| 1151 | if (!refresh) { |
| 1152 | if (rxbind) |
| 1153 | rx_bindhost = buffer[0]; |
| 1154 | else |
| 1155 | rx_bindhost = htonl(INADDR_ANY)(__builtin_constant_p((u_int32_t)0x00000000) ? ((((__uint32_t )((u_int32_t)0x00000000)) >> 24) | ((((__uint32_t)((u_int32_t )0x00000000)) & (0xff << 16)) >> 8) | ((((__uint32_t )((u_int32_t)0x00000000)) & (0xff << 8)) << 8 ) | (((__uint32_t)((u_int32_t)0x00000000)) << 24)) : __bswap32_var ((u_int32_t)0x00000000)); |
| 1156 | } |
| 1157 | } else { |
| 1158 | refresh = 0; |
| 1159 | } |
| 1160 | |
| 1161 | afs_osi_Free(buffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1162 | afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1163 | afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR32); |
| 1164 | |
| 1165 | if (refresh) { |
| 1166 | afs_CheckServers(1, NULL((void *)0)); /* check down servers */ |
| 1167 | afs_CheckServers(0, NULL((void *)0)); /* check up servers */ |
| 1168 | } |
| 1169 | } |
| 1170 | #ifdef AFS_SGI53_ENV |
| 1171 | else if (parm == AFSOP_NFSSTATICADDR) { |
| 1172 | extern int (*nfs_rfsdisptab_v2) (); |
| 1173 | nfs_rfsdisptab_v2 = (int (*)())parm2; |
| 1174 | } else if (parm == AFSOP_NFSSTATICADDR2) { |
| 1175 | extern int (*nfs_rfsdisptab_v2) (); |
| 1176 | # ifdef _K64U64 |
| 1177 | nfs_rfsdisptab_v2 = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff)); |
| 1178 | # else /* _K64U64 */ |
| 1179 | nfs_rfsdisptab_v2 = (int (*)())(parm3 & 0xffffffff); |
| 1180 | # endif /* _K64U64 */ |
| 1181 | } |
| 1182 | # if defined(AFS_SGI62_ENV) && !defined(AFS_SGI65_ENV) |
| 1183 | else if (parm == AFSOP_SBLOCKSTATICADDR2) { |
| 1184 | extern int (*afs_sblockp) (); |
| 1185 | extern void (*afs_sbunlockp) (); |
| 1186 | # ifdef _K64U64 |
| 1187 | afs_sblockp = (int (*)())((parm2 << 32) | (parm3 & 0xffffffff)); |
| 1188 | afs_sbunlockp = (void (*)())((parm4 << 32) | (parm5 & 0xffffffff)); |
| 1189 | # else |
| 1190 | afs_sblockp = (int (*)())(parm3 & 0xffffffff); |
| 1191 | afs_sbunlockp = (void (*)())(parm5 & 0xffffffff); |
| 1192 | # endif /* _K64U64 */ |
| 1193 | } |
| 1194 | # endif /* AFS_SGI62_ENV && !AFS_SGI65_ENV */ |
| 1195 | #endif /* AFS_SGI53_ENV */ |
| 1196 | else if (parm == AFSOP_SHUTDOWN201) { |
| 1197 | afs_cold_shutdown = 0; |
| 1198 | if (parm2 == 1) |
| 1199 | afs_cold_shutdown = 1; |
| 1200 | if (afs_globalVFS != 0) { |
| 1201 | afs_warn("AFS isn't unmounted yet! Call aborted\n"); |
| 1202 | code = EACCES13; |
| 1203 | } else |
| 1204 | afs_shutdown(); |
| 1205 | } else if (parm == AFSOP_AFS_VFSMOUNT16) { |
| 1206 | #ifdef AFS_HPUX_ENV |
| 1207 | vfsmount(parm2, parm3, parm4, parm5); |
| 1208 | #else /* defined(AFS_HPUX_ENV) */ |
| 1209 | # if defined(KERNEL_HAVE_UERROR) |
| 1210 | setuerror(EINVAL)get_user_struct()->u_error = (22); |
| 1211 | # else |
| 1212 | code = EINVAL22; |
| 1213 | # endif |
| 1214 | #endif /* defined(AFS_HPUX_ENV) */ |
| 1215 | } else if (parm == AFSOP_CLOSEWAIT18) { |
| 1216 | afs_SynchronousCloses = 'S'; |
| 1217 | } else if (parm == AFSOP_GETMTU20) { |
| 1218 | afs_uint32 mtu = 0; |
| 1219 | #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) |
| 1220 | # ifdef AFS_USERSPACE_IP_ADDR1 |
| 1221 | afs_int32 i; |
| 1222 | i = rxi_Findcbi(parm2); |
| 1223 | mtu = ((i == -1) ? htonl(1500)(__builtin_constant_p(1500) ? ((((__uint32_t)(1500)) >> 24) | ((((__uint32_t)(1500)) & (0xff << 16)) >> 8) | ((((__uint32_t)(1500)) & (0xff << 8)) << 8) | (((__uint32_t)(1500)) << 24)) : __bswap32_var(1500 )) : afs_cb_interface.mtu[i]); |
| 1224 | # else /* AFS_USERSPACE_IP_ADDR */ |
| 1225 | rx_ifnet_tstruct usr_ifnet * tifnp; |
| 1226 | |
| 1227 | tifnp = rxi_FindIfnet(parm2, NULL((void *)0)); /* make iterative */ |
| 1228 | mtu = (tifnp ? rx_ifnet_mtu(tifnp)(tifnp)->if_mtu : htonl(1500)(__builtin_constant_p(1500) ? ((((__uint32_t)(1500)) >> 24) | ((((__uint32_t)(1500)) & (0xff << 16)) >> 8) | ((((__uint32_t)(1500)) & (0xff << 8)) << 8) | (((__uint32_t)(1500)) << 24)) : __bswap32_var(1500 ))); |
| 1229 | # endif /* else AFS_USERSPACE_IP_ADDR */ |
| 1230 | #endif /* !AFS_SUN5_ENV */ |
| 1231 | if (!code) |
| 1232 | AFS_COPYOUT((caddr_t) & mtu, AFSKPTR(parm3),do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)((caddr_t ) & mtu),(sizeof(afs_int32))), 0); } while(0) |
| 1233 | sizeof(afs_int32), code)do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)((caddr_t ) & mtu),(sizeof(afs_int32))), 0); } while(0); |
| 1234 | #ifdef AFS_AIX32_ENV |
| 1235 | /* this is disabled for now because I can't figure out how to get access |
| 1236 | * to these kernel variables. It's only for supporting user-mode rx |
| 1237 | * programs -- it makes a huge difference on the 220's in my testbed, |
| 1238 | * though I don't know why. The bosserver does this with /etc/no, so it's |
| 1239 | * being handled a different way for the servers right now. */ |
| 1240 | /* { |
| 1241 | static adjusted = 0; |
| 1242 | extern u_long sb_max_dflt; |
| 1243 | if (!adjusted) { |
| 1244 | adjusted = 1; |
| 1245 | if (sb_max_dflt < 131072) sb_max_dflt = 131072; |
| 1246 | if (sb_max < 131072) sb_max = 131072; |
| 1247 | } |
| 1248 | } */ |
| 1249 | #endif /* AFS_AIX32_ENV */ |
| 1250 | } else if (parm == AFSOP_GETMASK42) { /* parm2 == addr in net order */ |
| 1251 | afs_uint32 mask = 0; |
| 1252 | #if !defined(AFS_SUN5_ENV) |
| 1253 | # ifdef AFS_USERSPACE_IP_ADDR1 |
| 1254 | afs_int32 i; |
| 1255 | i = rxi_Findcbi(parm2); |
| 1256 | if (i != -1) { |
| 1257 | mask = afs_cb_interface.subnetmask[i]; |
| 1258 | } else { |
| 1259 | code = -1; |
| 1260 | } |
| 1261 | # else /* AFS_USERSPACE_IP_ADDR */ |
| 1262 | rx_ifnet_tstruct usr_ifnet * tifnp; |
| 1263 | |
| 1264 | tifnp = rxi_FindIfnet(parm2, &mask); /* make iterative */ |
| 1265 | if (!tifnp) |
| 1266 | code = -1; |
| 1267 | # endif /* else AFS_USERSPACE_IP_ADDR */ |
| 1268 | #endif /* !AFS_SUN5_ENV */ |
| 1269 | if (!code) |
| 1270 | AFS_COPYOUT((caddr_t) & mask, AFSKPTR(parm3),do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)((caddr_t ) & mask),(sizeof(afs_int32))), 0); } while(0) |
| 1271 | sizeof(afs_int32), code)do { code = (memcpy((void *)((((caddr_t)parm3))),(void *)((caddr_t ) & mask),(sizeof(afs_int32))), 0); } while(0); |
| 1272 | } |
| 1273 | else if (parm == AFSOP_AFSDB_HANDLER30) { |
| 1274 | int sizeArg = (int)parm4; |
| 1275 | int kmsgLen = sizeArg & 0xffff; |
| 1276 | int cellLen = (sizeArg & 0xffff0000) >> 16; |
| 1277 | afs_int32 *kmsg = afs_osi_Alloc(kmsgLen); |
| 1278 | char *cellname = afs_osi_Alloc(cellLen); |
| 1279 | |
| 1280 | osi_Assert(kmsg != NULL)(void)((kmsg != ((void *)0)) || (osi_AssertFailK( "kmsg != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 1280), 0)); |
| 1281 | osi_Assert(cellname != NULL)(void)((cellname != ((void *)0)) || (osi_AssertFailK( "cellname != NULL" , "/home/wollman/openafs/src/afs/afs_call.c", 1281), 0)); |
| 1282 | #ifndef UKERNEL1 |
| 1283 | afs_osi_MaskUserLoop(); |
| 1284 | #endif |
| 1285 | AFS_COPYIN(AFSKPTR(parm2), cellname, cellLen, code)do { code = (memcpy((void *)(cellname),(void *)((((caddr_t)parm2 ))),(cellLen)), 0); } while(0); |
| 1286 | AFS_COPYIN(AFSKPTR(parm3), kmsg, kmsgLen, code)do { code = (memcpy((void *)(kmsg),(void *)((((caddr_t)parm3) )),(kmsgLen)), 0); } while(0); |
| 1287 | if (!code) { |
| 1288 | code = afs_AFSDBHandler(cellname, cellLen, kmsg); |
| 1289 | if (*cellname == 1) |
| 1290 | *cellname = 0; |
| 1291 | if (code == -2) { /* Shutting down? */ |
| 1292 | *cellname = 1; |
| 1293 | code = 0; |
| 1294 | } |
| 1295 | } |
| 1296 | if (!code) |
| 1297 | AFS_COPYOUT(cellname, AFSKPTR(parm2), cellLen, code)do { code = (memcpy((void *)((((caddr_t)parm2))),(void *)(cellname ),(cellLen)), 0); } while(0); |
| 1298 | afs_osi_Free(kmsg, kmsgLen); |
| 1299 | afs_osi_Free(cellname, cellLen); |
| 1300 | } |
| 1301 | else if (parm == AFSOP_SET_DYNROOT31) { |
| 1302 | code = afs_SetDynrootEnable(parm2); |
| 1303 | } else if (parm == AFSOP_SET_FAKESTAT33) { |
| 1304 | afs_fakestat_enable = parm2; |
| 1305 | code = 0; |
| 1306 | } else if (parm == AFSOP_SET_BACKUPTREE37) { |
| 1307 | afs_bkvolpref = parm2; |
| 1308 | } else if (parm == AFSOP_SET_RXPCK38) { |
| 1309 | rx_extraPackets = parm2; |
| 1310 | afscall_set_rxpck_received = 1; |
| 1311 | } else if (parm == AFSOP_SET_RXMAXMTU40) { |
| 1312 | rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = parm2; |
| 1313 | } else if (parm == AFSOP_SET_RXMAXFRAGS43) { |
| 1314 | rxi_nSendFrags = rxi_nRecvFrags = parm2; |
| 1315 | } else { |
| 1316 | code = EINVAL22; |
| 1317 | } |
| 1318 | |
| 1319 | out: |
| 1320 | AFS_GUNLOCK()do { do { if (!(pthread_self() == afs_global_owner)) { osi_Panic ("afs global lock not held"); } } while(0); memset(&afs_global_owner , 0, sizeof(pthread_t)); do{if (!(pthread_mutex_unlock(&afs_global_lock ) == 0)) AssertionFailed("/home/wollman/openafs/src/afs/afs_call.c" , 1320);}while(0); } while(0); |
| 1321 | #ifdef AFS_LINUX20_ENV |
| 1322 | return -code; |
| 1323 | #else |
| 1324 | return code; |
| 1325 | #endif |
| 1326 | } |
| 1327 | |
| 1328 | /* |
| 1329 | * Initstate in the range 0 < x < 100 are early initialization states. |
| 1330 | * Initstate of 100 means a AFSOP_START operation has been done. After this, |
| 1331 | * the cache may be initialized. |
| 1332 | * Initstate of 101 means a AFSOP_GO operation has been done. This operation |
| 1333 | * is done after all the cache initialization has been done. |
| 1334 | * Initstate of 200 means that the volume has been looked up once, possibly |
| 1335 | * incorrectly. |
| 1336 | * Initstate of 300 means that the volume has been *successfully* looked up. |
| 1337 | */ |
| 1338 | int |
| 1339 | afs_CheckInit(void) |
| 1340 | { |
| 1341 | int code = 0; |
| 1342 | |
| 1343 | AFS_STATCNT(afs_CheckInit)((afs_cmstats.callInfo.C_afs_CheckInit)++); |
| 1344 | if (afs_initState <= 100) |
| 1345 | code = ENXIO6; /* never finished init phase */ |
| 1346 | else if (afs_initState == 101) { /* init done, wait for afs_daemon */ |
| 1347 | while (afs_initState < 200) |
| 1348 | afs_osi_Sleep(&afs_initState); |
| 1349 | } else if (afs_initState == 200) |
| 1350 | code = ETIMEDOUT60; /* didn't find root volume */ |
| 1351 | return code; |
| 1352 | } |
| 1353 | |
| 1354 | int afs_shuttingdown = 0; |
| 1355 | void |
| 1356 | afs_shutdown(void) |
| 1357 | { |
| 1358 | extern short afs_brsDaemons; |
| 1359 | extern afs_int32 afs_CheckServerDaemonStarted; |
| 1360 | extern struct afs_osi_WaitHandle AFS_WaitHandler, AFS_CSWaitHandler; |
| 1361 | extern struct osi_file *afs_cacheInodep; |
| 1362 | |
| 1363 | AFS_STATCNT(afs_shutdown)((afs_cmstats.callInfo.C_afs_shutdown)++); |
| 1364 | if (afs_initState == 0) { |
| 1365 | afs_warn("AFS not initialized - not shutting down\n"); |
| 1366 | return; |
| 1367 | } |
| 1368 | |
| 1369 | if (afs_shuttingdown) |
| 1370 | return; |
| 1371 | |
| 1372 | /* Give up all of our callbacks if we can. This must be done before setting |
| 1373 | * afs_shuttingdown, since it calls afs_InitReq, which will fail if |
| 1374 | * afs_shuttingdown is set. */ |
| 1375 | afs_FlushVCBs(2); |
| 1376 | |
| 1377 | afs_shuttingdown = 1; |
| 1378 | |
| 1379 | if (afs_cold_shutdown) |
| 1380 | afs_warn("afs: COLD "); |
| 1381 | else |
| 1382 | afs_warn("afs: WARM "); |
| 1383 | afs_warn("shutting down of: vcaches... "); |
| 1384 | |
| 1385 | #if !defined(AFS_FBSD_ENV) |
| 1386 | /* The FBSD afs_unmount() calls vflush(), which reclaims all vnodes |
| 1387 | * on the mountpoint, flushing them in the process. In the presence |
| 1388 | * of bugs, flushing again here can cause panics. */ |
| 1389 | afs_FlushAllVCaches(); |
| 1390 | #endif |
| 1391 | |
| 1392 | afs_warn("CB... "); |
| 1393 | |
| 1394 | afs_termState = AFSOP_STOP_RXCALLBACK210; |
| 1395 | rx_WakeupServerProcs(); |
| 1396 | #ifdef AFS_AIX51_ENV |
| 1397 | shutdown_rxkernel(); |
| 1398 | #endif |
| 1399 | /* close rx server connections here? */ |
| 1400 | while (afs_termState == AFSOP_STOP_RXCALLBACK210) |
| 1401 | afs_osi_Sleep(&afs_termState); |
| 1402 | |
| 1403 | afs_warn("afs... "); |
| 1404 | while (afs_termState == AFSOP_STOP_AFS211) { |
| 1405 | afs_osi_CancelWait(&AFS_WaitHandler); |
| 1406 | afs_osi_Sleep(&afs_termState); |
| 1407 | } |
| 1408 | if (afs_CheckServerDaemonStarted) { |
| 1409 | while (afs_termState == AFSOP_STOP_CS216) { |
| 1410 | afs_osi_CancelWait(&AFS_CSWaitHandler); |
| 1411 | afs_osi_Sleep(&afs_termState); |
| 1412 | } |
| 1413 | } |
| 1414 | afs_warn("BkG... "); |
| 1415 | /* Wake-up afs_brsDaemons so that we don't have to wait for a bkg job! */ |
| 1416 | while (afs_termState == AFSOP_STOP_BKG212) { |
| 1417 | afs_osi_Wakeup(&afs_brsDaemons); |
| 1418 | afs_osi_Sleep(&afs_termState); |
| 1419 | } |
| 1420 | afs_warn("CTrunc... "); |
| 1421 | /* Cancel cache truncate daemon. */ |
| 1422 | while (afs_termState == AFSOP_STOP_TRUNCDAEMON213) { |
| 1423 | afs_osi_Wakeup((char *)&afs_CacheTruncateDaemon); |
| 1424 | afs_osi_Sleep(&afs_termState); |
| 1425 | } |
| 1426 | afs_warn("AFSDB... "); |
| 1427 | afs_StopAFSDB(); |
| 1428 | while (afs_termState == AFSOP_STOP_AFSDB218) |
| 1429 | afs_osi_Sleep(&afs_termState); |
| 1430 | #if defined(AFS_SUN5_ENV) || defined(RXK_LISTENER_ENV1) |
| 1431 | afs_warn("RxEvent... "); |
| 1432 | /* cancel rx event daemon */ |
| 1433 | while (afs_termState == AFSOP_STOP_RXEVENT214) |
| 1434 | afs_osi_Sleep(&afs_termState); |
| 1435 | # if defined(RXK_LISTENER_ENV1) |
| 1436 | # ifndef UKERNEL1 |
| 1437 | afs_warn("UnmaskRxkSignals... "); |
| 1438 | afs_osi_UnmaskRxkSignals(); |
| 1439 | # endif |
| 1440 | /* cancel rx listener */ |
| 1441 | afs_warn("RxListener... "); |
| 1442 | osi_StopListener(); /* This closes rx_socket. */ |
| 1443 | while (afs_termState == AFSOP_STOP_RXK_LISTENER217) { |
| 1444 | afs_warn("Sleep... "); |
| 1445 | afs_osi_Sleep(&afs_termState); |
| 1446 | } |
| 1447 | # endif |
| 1448 | #endif |
| 1449 | |
| 1450 | #if defined(AFS_SUN510_ENV) || defined(RXK_UPCALL_ENV) |
| 1451 | afs_warn("NetIfPoller... "); |
| 1452 | osi_StopNetIfPoller(); |
| 1453 | #endif |
| 1454 | |
| 1455 | afs_termState = AFSOP_STOP_COMPLETE215; |
| 1456 | |
| 1457 | #ifdef AFS_AIX51_ENV |
| 1458 | shutdown_daemons(); |
| 1459 | #endif |
| 1460 | shutdown_CB(); |
| 1461 | shutdown_bufferpackage(); |
| 1462 | shutdown_cache(); |
| 1463 | shutdown_osi(); |
| 1464 | /* |
| 1465 | * Close file only after daemons which can write to it are stopped. |
| 1466 | * Need to close before the osinet shutdown to avoid failing check |
| 1467 | * for dangling memory allocations. |
| 1468 | */ |
| 1469 | if (afs_cacheInodep) { /* memcache won't set this */ |
| 1470 | osi_UFSClose(afs_cacheInodep); /* Since we always leave it open */ |
| 1471 | afs_cacheInodep = 0; |
| 1472 | } |
| 1473 | /* |
| 1474 | * Shutdown the ICL logs - needed to free allocated memory space and avoid |
| 1475 | * warnings from shutdown_osinet |
| 1476 | */ |
| 1477 | shutdown_icl(); |
| 1478 | shutdown_osinet(); |
| 1479 | shutdown_osifile(); |
| 1480 | shutdown_vnodeops(); |
| 1481 | shutdown_memcache(); |
| 1482 | shutdown_xscache(); |
| 1483 | #if (!defined(AFS_NONFSTRANS1) || defined(AFS_AIX_IAUTH_ENV)) |
| 1484 | shutdown_exporter(); |
| 1485 | shutdown_nfsclnt(); |
| 1486 | #endif |
| 1487 | shutdown_afstest(); |
| 1488 | shutdown_AFS(); |
| 1489 | /* The following hold the cm stats */ |
| 1490 | memset(&afs_cmstats, 0, sizeof(struct afs_CMStats)); |
| 1491 | memset(&afs_stats_cmperf, 0, sizeof(struct afs_stats_CMPerf)); |
| 1492 | memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf)); |
| 1493 | afs_warn(" ALL allocated tables... "); |
| 1494 | |
| 1495 | afs_shuttingdown = 0; |
| 1496 | afs_warn("done\n"); |
| 1497 | |
| 1498 | return; /* Just kill daemons for now */ |
| 1499 | } |
| 1500 | |
| 1501 | void |
| 1502 | shutdown_afstest(void) |
| 1503 | { |
| 1504 | AFS_STATCNT(shutdown_afstest)((afs_cmstats.callInfo.C_shutdown_afstest)++); |
| 1505 | afs_initState = afs_termState = afs_setTime = 0; |
| 1506 | AFS_Running = afs_CB_Running = 0; |
| 1507 | afs_CacheInit_Done = afs_Go_Done = 0; |
| 1508 | if (afs_cold_shutdown) { |
| 1509 | *afs_rootVolumeName = 0; |
| 1510 | } |
| 1511 | } |