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"
41 struct cfg_load cload;
47 * The following signal action for AIX is necessary so that in case of a
48 * crash (i.e. core is generated) we can include the user's data section
49 * in the core dump. Unfortunately, by default, only a partial core is
50 * generated which, in many cases, isn't too useful.
54 sigemptyset(&nsa.sa_mask);
55 nsa.sa_handler = SIG_DFL;
56 nsa.sa_flags = SA_FULLDUMP;
57 sigaction(SIGSEGV, &nsa, NULL);
61 while ((c = getopt(argc, argv, "a:d:")) != EOF) {
93 res = sysconfig(SYS_KLOAD, &cload, sizeof(cload));
96 loadquery(L_GETMESSAGES, &buf[2], sizeof buf - 8);
97 execvp("/etc/execerror", buf);
101 cmod.kmid = cload.kmid;
106 res = sysconfig(SYS_CFGKMOD, &cmod, sizeof(cmod));
108 perror("SYS_CFGKMOD");
109 cload.kmid = cload.kmid;
110 sysconfig(SYS_KULOAD, &cload, sizeof(cload));
114 printf("cfgafs -d 0x%x # to remove AFS\n", cload.kmid);
116 strcpy(PidFile, file);
117 strcat(PidFile, ".kmid");
118 fp = fopen(PidFile, "w");
120 (void) fprintf(fp, "%d\n", cload.kmid);
123 printf("Can't open for write file %s (error=%d); ignored\n", PidFile, errno);
129 strcpy(PidFile, file);
130 strcat(PidFile, ".kmid");
131 fp = fopen(PidFile, "r");
133 printf("Can't read %s file (error=%d); aborting\n", PidFile, errno);
136 (void) fscanf(fp, "%d\n", &kmid);
144 if (sysconfig(SYS_CFGKMOD, &cmod, sizeof(cmod)) == -1) {
145 perror("SYS_CFGKMOD");
150 if (sysconfig(SYS_KULOAD, &cload, sizeof(cload)) == -1) {
151 perror("SYS_KULOAD");
160 fprintf(stderr, "usage: cfgafs [-a mod_file] [-d mod_file]\n");