int main(int argc, char *argv[]) { struct cmd_opts opts; int rc; switch (get_platform()) { case PLATFORM_UNKNOWN: case PLATFORM_POWERNV: fprintf(stderr, "%s: is not supported on the %s platform\n", argv[0], platform_name); exit(1); } /* make sure that we're running on the proper platform. */ if (! valid_platform("chrp")) exit(1); memset(&opts, 0, sizeof(opts)); /* default to DRSLOT type */ opts.slot_type = SLOT; parse_options(argc, argv, &opts); rc = dr_lock(); if (rc) { say(ERROR, "Unable to obtain Dynamic Reconfiguration lock. " "Please try command again later.\n"); exit(1); } switch (opts.slot_type) { case SLOT: case PCI: rc = lsslot_chrp_pci(&opts); break; case PHB: rc = lsslot_chrp_phb(&opts); break; case CPU: rc = lsslot_chrp_cpu(&opts); break; case MEM: rc = lsslot_chrp_mem(&opts); break; case PORT: rc = lsslot_chrp_port(&opts); break; } free_drc_info(); dr_unlock(); exit(rc); }
/** * dr_fini * @brief Cleanup routine for drmgr and lsslot * */ inline void dr_fini(void) { struct stat sbuf; int max_dr_log_sz = 25000; int rc; time_t t; char tbuf[128]; free_drc_info(); if (! log_fd) return; /* Insert seperator at end of drmgr invocation */ time(&t); strftime(tbuf, 128, "%b %d %T %G", localtime(&t)); say(DEBUG, "########## %s ##########\n", tbuf); close(log_fd); /* Check for log rotation */ rc = stat(DR_LOG_PATH, &sbuf); if (rc) { fprintf(stderr, "Cannot determine log size to check for " "rotation:\n\t%s\n", strerror(errno)); return; } if (sbuf.st_size >= max_dr_log_sz) { fprintf(stderr, "Rotating logs...\n"); rc = unlink(DR_LOG_PATH0); if (rc && (errno != ENOENT)) { fprintf(stderr, "Could not remove %s\n\t%s\n", DR_LOG_PATH0, strerror(errno)); return; } rc = rename(DR_LOG_PATH, DR_LOG_PATH0); if (rc) { fprintf(stderr, "Could not rename %s to %s\n\t%s\n", DR_LOG_PATH, DR_LOG_PATH0, strerror(errno)); return; } } dr_unlock(); }