2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * cfgafs - load/configure the AFS kernel extension
13 #include <afsconfig.h>
14 #include <afs/param.h>
20 #include <sys/types.h>
21 #include <sys/device.h>
22 #include <sys/sysconfig.h>
28 extern char *malloc(), *optarg;
30 extern int sysconfig(int cmd, void *arg, int len);
32 #include "AFS_component_version_number.c"
42 struct cfg_load cload;
48 * The following signal action for AIX is necessary so that in case of a
49 * crash (i.e. core is generated) we can include the user's data section
50 * in the core dump. Unfortunately, by default, only a partial core is
51 * generated which, in many cases, isn't too useful.
55 sigemptyset(&nsa.sa_mask);
56 nsa.sa_handler = SIG_DFL;
57 nsa.sa_flags = SA_FULLDUMP;
58 sigaction(SIGSEGV, &nsa, NULL);
62 while ((c = getopt(argc, argv, "a:d:")) != EOF) {
94 res = sysconfig(SYS_KLOAD, &cload, sizeof(cload));
97 loadquery(L_GETMESSAGES, &buf[2], sizeof buf - 8);
98 execvp("/etc/execerror", buf);
102 cmod.kmid = cload.kmid;
107 res = sysconfig(SYS_CFGKMOD, &cmod, sizeof(cmod));
109 perror("SYS_CFGKMOD");
110 cload.kmid = cload.kmid;
111 sysconfig(SYS_KULOAD, &cload, sizeof(cload));
115 printf("cfgafs -d 0x%x # to remove AFS\n", cload.kmid);
117 strcpy(PidFile, file);
118 strcat(PidFile, ".kmid");
119 fp = fopen(PidFile, "w");
121 (void)fprintf(fp, "%d\n", cload.kmid);
124 printf("Can't open for write file %s (error=%d); ignored\n",
131 strcpy(PidFile, file);
132 strcat(PidFile, ".kmid");
133 fp = fopen(PidFile, "r");
135 printf("Can't read %s file (error=%d); aborting\n", PidFile,
139 (void)fscanf(fp, "%d\n", &kmid);
147 if (sysconfig(SYS_CFGKMOD, &cmod, sizeof(cmod)) == -1) {
148 perror("SYS_CFGKMOD");
153 if (sysconfig(SYS_KULOAD, &cload, sizeof(cload)) == -1) {
154 perror("SYS_KULOAD");
164 fprintf(stderr, "usage: cfgafs [-a mod_file] [-d mod_file]\n");