/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
* -rxmaxmtu Set the max mtu to help with VPN issues.
* -verbose Be chatty.
* -disable-dynamic-vcaches Disable the use of -stat value as the starting size of
- * the size of the vcache/stat cache pool,
+ * the size of the vcache/stat cache pool,
* but increase that pool dynamically as needed.
* -debug Print out additional debugging info.
* -kerndev [OBSOLETE] The kernel device for AFS.
* -dontfork [OBSOLETE] Don't fork off as a new process.
* -daemons The number of background daemons to start (Default: 2).
* -rmtsys Also fires up an afs remote sys call (e.g. pioctl, setpag)
- * support daemon
+ * support daemon
* -chunksize [n] 2^n is the chunksize to be used. 0 is default.
* -dcache The number of data cache entries.
* -biods Number of bkg I/O daemons (AIX3.1 only)
#include "afsd.h"
-#include <assert.h>
-#include <potpourri.h>
+#include <afs/afs_assert.h>
#include <afs/afsutil.h>
#include <stdlib.h>
#include <stdio.h>
} S_un_w;
afs_uint32 S_addr;
} S_un;
-#define s_host S_un.S_un_b.s_b2 /* host on imp */
-#define s_net S_un.S_un_b.s_b1 /* network */
-#define s_imp S_un.S_un_w.s_w2 /* imp */
-#define s_impno S_un.S_un_b.s_b4 /* imp # */
-#define s_lh S_un.S_un_b.s_b3 /* logical host */
};
#define mPrintIPAddr(ipaddr) printf("[%d.%d.%d.%d] ", \
static int sawCacheStatEntries = 0;
char afsd_cacheMountDir[1024]; /*Mount directory for AFS */
static char rootVolume[64] = "root.afs"; /*AFS root volume name */
-static afs_int32 cacheSetTime = FALSE; /*Keep checking time to avoid drift? */
+static afs_int32 cacheSetTime = 0; /*Keep checking time to avoid drift? */
#ifdef AFS_XBSD_ENV
static int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC; /*Create & truncate on open */
#else
#if defined(AFS_DARWIN_ENV) && !defined(AFS_ARM_DARWIN_ENV)
static void
-afsd_sleep_callback(void * refCon, io_service_t service,
+afsd_sleep_callback(void * refCon, io_service_t service,
natural_t messageType, void * messageArgument )
{
switch (messageType) {
case kIOMessageCanSystemSleep:
- /* Idle sleep is about to kick in; can
- prevent sleep by calling IOCancelPowerChange, otherwise
+ /* Idle sleep is about to kick in; can
+ prevent sleep by calling IOCancelPowerChange, otherwise
if we don't ack in 30s the system sleeps anyway */
-
+
/* allow it */
IOAllowPowerChange(root_port, (long)messageArgument);
break;
-
+
case kIOMessageSystemWillSleep:
/* The system WILL go to sleep. Ack or suffer delay */
-
+
IOAllowPowerChange(root_port, (long)messageArgument);
break;
-
+
case kIOMessageSystemWillRestart:
/* The system WILL restart. Ack or suffer delay */
-
+
IOAllowPowerChange(root_port, (long)messageArgument);
break;
-
+
case kIOMessageSystemWillPowerOn:
case kIOMessageSystemHasPoweredOn:
/* coming back from sleep */
-
+
IOAllowPowerChange(root_port, (long)messageArgument);
break;
-
+
default:
IOAllowPowerChange(root_port, (long)messageArgument);
break;
} else
printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
reason);
+
+ /* Since it's likely this means our DNS server changed, reinit now */
+ if (enable_afsdb)
+ res_init();
}
/* This function is called when the system's ip addresses may have changed. */
CFRelease (timer);
}
-static void
+static void
afsd_event_cleanup(int signo) {
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
#ifndef AFS_ARM_DARWIN_ENV
root_port = IORegisterForSystemPower(0,¬ify,afsd_sleep_callback,&iterator);
-
+
if (root_port) {
CFRunLoopAddSource(CFRunLoopGetCurrent(),
IONotificationPortGetRunLoopSource(notify),
kCFRunLoopDefaultMode);
}
-
-
+
+
store = SCDynamicStoreCreate (NULL,
CFSTR ("AddIPAddressListChangeCallbackSCF"),
afsd_ipaddr_callback, &ctx);
-
+
if (store) {
const void *keys[1];
-
+
/* Request IPV4 address change notification */
keys[0] = (SCDynamicStoreKeyCreateNetworkServiceEntity
(NULL, kSCDynamicStoreDomainState,
kSCCompAnyRegex, kSCEntNetIPv4));
-
+
#if 0
/* This should tell us when the hostname(s) change. do we care? */
keys[N] = SCDynamicStoreKeyCreateHostNames (NULL);
#endif
-
+
if (keys[0] != NULL) {
CFArrayRef pattern_array;
-
+
pattern_array = CFArrayCreate (NULL, keys, 1,
&kCFTypeArrayCallBacks);
-
+
if (pattern_array != NULL)
{
SCDynamicStoreSetNotificationKeys (store, NULL, pattern_array);
source = SCDynamicStoreCreateRunLoopSource (NULL, store, 0);
-
+
CFRelease (pattern_array);
}
-
+
if (keys[0] != NULL)
CFRelease (keys[0]);
}
-
- CFRelease (store);
+
+ CFRelease (store);
}
#endif
-
+
if (source != NULL) {
CFRunLoopAddSource (CFRunLoopGetCurrent(),
source, kCFRunLoopDefaultMode);
}
-
+
signal(SIGTERM, afsd_event_cleanup);
CFRunLoopRun();
}
/*
- * All failures to open the partition are ignored. Also if the cache dir
- * isn't a mounted partition it's also ignored since we can't guarantee
+ * All failures to open the partition are ignored. Also if the cache dir
+ * isn't a mounted partition it's also ignored since we can't guarantee
* what will be stored afterwards. Too many if's. This is now purely
* advisory. ODS with over 2G partition also gives warning message.
*
}
static int
-MoveCacheFile(char *basename, int fromDir, int toDir, int cacheFile,
+MoveCacheFile(char *basename, int fromDir, int toDir, int cacheFile,
int maxDir)
{
static char rn[] = "MoveCacheFile";
static int
-doSweepAFSCache(int *vFilesFound,
+doSweepAFSCache(int *vFilesFound,
char *directory, /* /path/to/cache/directory */
int dirNum, /* current directory number */
int maxDir) /* maximum directory number */
#if defined(AFS_SGI62_ENV) || defined(AFS_DARWIN90_ENV)
printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n", currp->d_ino,
currp->d_reclen, currp->d_name);
-#elif defined(AFS_DFBSD_ENV)
+#elif defined(AFS_DFBSD_ENV) || defined(AFS_USR_DFBSD_ENV)
printf("\tinode=%ld, name='%s'\n", (long)currp->d_ino, currp->d_name);
#else
printf("\tinode=%ld, reclen=%d, name='%s'\n", (long)currp->d_ino,
}
if (as->parms[8].items) {
/* -nosettime */
- cacheSetTime = FALSE;
+ cacheSetTime = 0;
}
if (as->parms[9].items) {
/* -verbose */
if (as->parms[20].items) {
/* -shutdown */
afs_shutdown = 1;
- /*
+ /*
* Cold shutdown is the default
*/
printf("afsd: Shutting down all afs processes and afs state\n");
}
if (as->parms[32].items) {
/* -settime */
- cacheSetTime = TRUE;
+ cacheSetTime = 1;
}
/* set rx_extraPackets */
if (as->parms[35].items) {
#ifdef AFS_MAXVCOUNT_ENV
/* -disable-dynamic-vcaches */
- afsd_dynamic_vcaches = FALSE;
+ afsd_dynamic_vcaches = 0;
#else
printf("afsd: Error toggling flag, dynamically allocated vcaches not supported on your platform\n");
exit(1);
#ifdef AFS_MAXVCOUNT_ENV
else {
/* -dynamic-vcaches */
- afsd_dynamic_vcaches = TRUE;
+ afsd_dynamic_vcaches = 1;
}
if (afsd_verbose)
int vFilesFound; /*How many data cache files were found in sweep */
int currVFile; /*Current AFS cache file number passed in */
- /*
+ /*
* Pull out all the configuration info for the workstation's AFS cache and
* the cellular community we're willing to let our users see.
*/
/* Disk cache:
* Compute the number of cache files based on cache size,
* but only if -files isn't given on the command line.
- * Don't let # files be so small as to prevent full utilization
+ * Don't let # files be so small as to prevent full utilization
* of the cache unless user has explicitly asked for it.
*/
if (chunkSize == 0) {
cacheFiles = max(cacheFiles, 1000);
- /* Always allow more files than chunks. Presume average V-file
+ /* Always allow more files than chunks. Presume average V-file
* is ~67% of a chunk... (another guess, perhaps Honeyman will
* have a grad student write a paper). i is KILOBYTES.
*/
/* This actually needs to
1) use powers of 2
2) not second-guess when a chunksize comes from the command line
- 3) be less, um, small. 2^2??
+ 3) be less, um, small. 2^2??
*/
/* Sanity check chunkSize */
i = max(cacheBlocks / 1000, cacheBlocks / cacheFiles);
if (code > 0) {
if (enable_rxbind)
code = code | 0x80000000;
- afsd_call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
+ afsd_call_syscall(AFSOP_ADVISEADDR, code, addrbuf, maskbuf, mtubuf);
} else
printf("ADVISEADDR: Error in specifying interface addresses:%s\n",
reason);
printf("%s: Forking AFSDB lookup handler.\n", rn);
afsd_fork(0, afsdb_thread, NULL);
}
-
code = afsd_call_syscall(AFSOP_BASIC_INIT, 1);
if (code) {
printf("%s: Error %d in basic initialization.\n", rn, code);
cparams.setTimeFlag = cacheSetTime;
cparams.memCacheFlag = cacheFlags;
cparams.dynamic_vcaches = afsd_dynamic_vcaches;
- afsd_call_syscall(AFSOP_CACHEINIT, &cparams);
+ afsd_call_syscall(AFSOP_CACHEINIT, &cparams);
/* do it before we init the cache inodes */
if (enable_splitcache) {
printf("%s: Using memory cache, not swept\n", rn);
/*
- * Pass the kernel the name of the workstation cache file holding the
+ * Pass the kernel the name of the workstation cache file holding the
* dcache entries.
*/
if (afsd_debug)
if (afsd_debug)
printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", rn,
fullpn_CellInfoFile);
- afsd_call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile);
+ afsd_call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile);
if (rxmaxmtu) {
if (afsd_verbose)
if (afsd_debug)
printf("%s: Calling AFSOP_GO with cacheSetTime = %d\n", rn,
cacheSetTime);
- afsd_call_syscall(AFSOP_GO, cacheSetTime);
+ afsd_call_syscall(AFSOP_GO, cacheSetTime);
/*
- * At this point, we have finished passing the kernel all the info
+ * At this point, we have finished passing the kernel all the info
* it needs to set up the AFS. Mount the AFS root.
*/
printf("%s: All AFS daemons started.\n", rn);
"set rx_extraPackets to this value");
cmd_AddParm(ts, "-splitcache", CMD_SINGLE, CMD_OPTIONAL,
"Percentage RW versus RO in cache (specify as 60/40)");
- cmd_AddParm(ts, "-disable-dynamic-vcaches", CMD_FLAG, CMD_OPTIONAL,
+ cmd_AddParm(ts, "-disable-dynamic-vcaches", CMD_FLAG, CMD_OPTIONAL,
"disable stat/vcache cache growing as needed");
cmd_AddParm(ts, "-rxmaxmtu", CMD_SINGLE, CMD_OPTIONAL, "set rx max MTU to use");
cmd_AddParm(ts, "-dynroot-sparse", CMD_FLAG, CMD_OPTIONAL,