|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <sys/dkio.h> ! 3: #include <signal.h> ! 4: #include <ctype.h> ! 5: ! 6: char buf[64] ; ! 7: char *netfiles = "/dev/dk/dk"; ! 8: ! 9: main(argc, argv) ! 10: char **argv ; ! 11: { ! 12: int f, i; ! 13: int n ; ! 14: int traffic = 2; ! 15: int unit = 'a'; ! 16: extern rdk_ld; ! 17: ! 18: ! 19: signal(SIGINT, SIG_IGN); ! 20: signal(SIGQUIT, SIG_IGN); ! 21: signal(SIGHUP, SIG_IGN); ! 22: signal(SIGTERM, SIG_IGN); ! 23: signal(SIGPIPE, SIG_IGN); ! 24: while (argc > 1) { ! 25: if (strcmp(argv[1], "-t") == 0) ! 26: ; ! 27: else if (isdigit(*argv[1])) ! 28: unit = *argv[1]; ! 29: else if (strcmp(argv[1], "-N") == 0) { ! 30: netfiles = argv[2]; ! 31: argv++; ! 32: argc--; ! 33: } ! 34: else ! 35: printf("dkhup: argument %s ignored\n"); ! 36: argc--; ! 37: argv++; ! 38: } ! 39: if (fork()) ! 40: return(0) ; ! 41: restart: ! 42: if ((f = dkctlchan(traffic, unit)) < 0) { ! 43: printf("dkhup: cannot open ctlr channel for %d\n", traffic); ! 44: exit(1); ! 45: } ! 46: if (argc < 3) { ! 47: ioctl(f, DIOCHUP, 0); ! 48: ioctl(f, DIOCHUP, 0); ! 49: ioctl(f, DIOCHUP, 0); ! 50: } ! 51: OK: ! 52: ioctl(f, DIOCNXCL, 0); ! 53: for (;;) { ! 54: n = read(f, buf, sizeof buf) ; ! 55: if (n <= 0) { ! 56: for (i=0; i < 5; i++) { ! 57: sleep(1); ! 58: n = read(f, buf, sizeof(buf)); ! 59: if (n > 0) ! 60: goto OK; ! 61: } ! 62: printf("dkhup: shutting down kmc %d\n", traffic); ! 63: ioctl(f, KIOCSHUT, (char *)0); ! 64: close(f); ! 65: sleep(45); ! 66: printf("dkhup: reloading kmc %d\n", traffic); ! 67: dumpkmc(traffic); ! 68: loadkmc(traffic); ! 69: sleep(5); ! 70: goto restart; ! 71: } ! 72: /* ! 73: printf("dkhup: read (size %d) = ", n) ; ! 74: for (i=0; i<n; i++) ! 75: printf("%o ", buf[i]&0377) ; ! 76: printf("\n\r") ; ! 77: */ ! 78: } ! 79: } ! 80: ! 81: dumpkmc(traffic) ! 82: { ! 83: ! 84: sprintf(buf, "cd /usr/dk; /etc/kmcdump %d", traffic); ! 85: system(buf); ! 86: } ! 87: ! 88: loadkmc(traffic) ! 89: { ! 90: ! 91: sprintf(buf, "/etc/kdiload %d", traffic); ! 92: system(buf); ! 93: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.