static void epic_timer(unsigned long data) { struct net_device *dev = (struct net_device *)data; struct epic_private *ep = dev->priv; long ioaddr = dev->base_addr; int next_tick = 5*HZ; if (debug > 3) { printk(KERN_DEBUG "%s: Media monitor tick, Tx status %8.8x.\n", dev->name, (int)inl(ioaddr + TxSTAT)); printk(KERN_DEBUG "%s: Other registers are IntMask %4.4x " "IntStatus %4.4x RxStatus %4.4x.\n", dev->name, (int)inl(ioaddr + INTMASK), (int)inl(ioaddr + INTSTAT), (int)inl(ioaddr + RxSTAT)); } check_media(dev); ep->timer.expires = jiffies + next_tick; add_timer(&ep->timer); }
int main(int argc, char **argv) { char *config = MHVTL_CONFIG_PATH"/device.conf"; FILE *conf; char b[1024]; int device_type = TYPE_UNKNOWN; long deviceNo, indx; int count; char buf[1024]; char *p; if ((argc < 2) || (argc > 6)) { usage(argv[0]); exit(1); } /* checking several positions of -h/-help */ for (count = 1; count < argc; count++) { if (!strcmp(argv[count], "-h")) { usage(argv[0]); exit(1); } if (!strcmp(argv[count], "/h")) { usage(argv[0]); exit(1); } if (!strcmp(argv[count], "-help")) { usage(argv[0]); exit(1); } if (!strcasecmp(argv[count], "-v")) { printf("Version: %s\n", MHVTL_VERSION); exit(1); } } Check_Params(argc, argv); deviceNo = atol(argv[1]); if ((deviceNo < 0) || (deviceNo >= VTLCMD_Q)) { fprintf(stderr, "Invalid device number for " "tape/library: %s\n", argv[1]); exit(1); } conf = fopen(config, "r"); if (!conf) { fprintf(stderr, "Can not open config file %s : %s\n", config, strerror(errno)); exit(1); } p = buf; buf[0] = '\0'; /* While read in a line */ while (fgets(b, sizeof(b), conf) != NULL) { if (sscanf(b, "Drive: %ld ", &indx) == 1 && indx == deviceNo) { device_type = TYPE_DRIVE; break; } if (sscanf(b, "Library: %ld ", &indx) == 1 && indx == deviceNo) { device_type = TYPE_LIBRARY; break; } } fclose(conf); if (device_type == TYPE_UNKNOWN) { fprintf(stderr, "No tape/library (%s) configured with " "device number: %ld\n", config, deviceNo); exit(1); } /* Concat all args into one string */ p = buf; buf[0] = '\0'; for (count = 2; count < argc; count++) { strcat(p, argv[count]); p += strlen(argv[count]); strcat(p, " "); p += strlen(" "); } /* check if command to the specific device is allowed */ if (device_type == TYPE_LIBRARY) { if (!strncmp(buf, "online", 6)) { } else if (!strncmp(buf, "add slot", 8)) { } else if (!strncmp(buf, "offline", 7)) { } else if (!strncmp(buf, "open map", 8)) { } else if (!strncmp(buf, "close map", 9)) { } else if (!strncmp(buf, "empty map", 9)) { } else if (!strncmp(buf, "list map", 8)) { } else if (!strncmp(buf, "load map", 8)) { } else if (!strncmp(buf, "verbose", 7)) { } else if (!strncmp(buf, "debug", 5)) { } else if (!strncmp(buf, "exit", 4)) { } else if (!strncmp(buf, "TapeAlert", 9)) { } else { fprintf(stderr, "Command for library not allowed\n"); exit(1); } } if (device_type == TYPE_DRIVE) { if (!strncmp(buf, "load", 4)) { } else if (!strncmp(buf, "unload", 6)) { } else if (!strncmp(buf, "verbose", 7)) { } else if (!strncmp(buf, "debug", 5)) { } else if (!strncmp(buf, "dump", 4)) { } else if (!strncmp(buf, "exit", 4)) { } else if (!strncmp(buf, "compression", 11)) { } else if (!strncmp(buf, "TapeAlert", 9)) { } else if (!strncasecmp(buf, "append", 6)) { } else if (!strncasecmp(buf, "delay load", 10)) { } else if (!strncasecmp(buf, "delay unload", 12)) { } else if (!strncasecmp(buf, "delay rewind", 12)) { } else if (!strncasecmp(buf, "delay position", 14)) { } else if (!strncasecmp(buf, "delay thread", 12)) { } else { fprintf(stderr, "Command for tape not allowed\n"); exit(1); } } /* Check for the existance of a datafile first - abort if not there */ if (device_type == TYPE_LIBRARY) { if (!strcmp(argv[2], "load") && !strcmp(argv[3], "map")) { if (check_media(deviceNo, argv[4])) { fprintf(stderr, "Hint: Use command 'mktape' to " "create media first\n"); exit(1); } } } long ReceiverQid; ReceiverQid = OpenExistingQueue(QKEY); if (ReceiverQid == -1) { fprintf(stderr, "MessageQueue not available\n"); exit(1); } if (SendMsg(ReceiverQid, deviceNo, buf) < 0) { fprintf(stderr, "Message Queue Error: send message\n"); exit(1); } if (device_type == TYPE_LIBRARY) { if (!strcmp(argv[2], "add") && !strcmp(argv[3], "slot")) DisplayResponse(ReceiverQid, ""); if (!strcmp(argv[2], "open") && !strcmp(argv[3], "map")) DisplayResponse(ReceiverQid, ""); if (!strcmp(argv[2], "close") && !strcmp(argv[3], "map")) DisplayResponse(ReceiverQid, ""); if (!strcmp(argv[2], "empty") && !strcmp(argv[3], "map")) DisplayResponse(ReceiverQid, ""); if (!strcmp(argv[2], "list") && !strcmp(argv[3], "map")) DisplayResponse(ReceiverQid, "Contents: "); if (!strcmp(argv[2], "load") && !strcmp(argv[3], "map")) DisplayResponse(ReceiverQid, ""); } exit(0); }