/** * opd_open_files - open necessary files * * Open the device files and the log file, * and mmap() the hash map. */ static void opd_open_files(void) { devfd = op_open_device("/dev/oprofile/buffer"); if (devfd == -1) { if (errno == EINVAL) fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n" "parameters. Check /var/log/messages."); else perror("Failed to open profile device"); exit(EXIT_FAILURE); } /* give output before re-opening stdout as the logfile */ printf("Using log file %s\n", op_log_file); /* set up logfile */ close(0); close(1); if (open("/dev/null", O_RDONLY) == -1) { perror("oprofiled: couldn't re-open stdin as /dev/null: "); exit(EXIT_FAILURE); } opd_open_logfile(); opd_create_pipe(); printf("oprofiled started %s", op_get_time()); printf("kernel pointer size: %lu\n", (unsigned long)kernel_pointer_size); fflush(stdout); }
/** re-open files for logrotate/opcontrol --reset */ static void opd_sighup(void) { printf("Received SIGHUP.\n"); /* We just close them, and re-open them lazily as usual. */ sfile_close_files(); close(1); close(2); opd_open_logfile(); }
static void opd_sighup(void) { printf("Received SIGHUP.\n"); close(1); close(2); opd_open_logfile(); opd_for_each_image(opd_close_image_samples_files); }
static void op_open_files(void) { hashmapdevfd = op_open_device(op_hash_device); if (hashmapdevfd == -1) { perror("Failed to open hash map device"); exit(EXIT_FAILURE); } notedevfd = op_open_device(op_note_device); if (notedevfd == -1) { if (errno == EINVAL) fprintf(stderr, "Failed to open note device. Possibly you have passed incorrect\n" "parameters. Check /var/log/messages."); else perror("Failed to open note device"); exit(EXIT_FAILURE); } devfd = op_open_device(op_device); if (devfd == -1) { if (errno == EINVAL) fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n" "parameters. Check /var/log/messages."); else perror("Failed to open profile device"); exit(EXIT_FAILURE); } opd_init_hash_map(); printf("Using log file %s\n", op_log_file); close(0); close(1); if (open("/dev/null", O_RDONLY) == -1) { perror("oprofiled: couldn't re-open stdin as /dev/null: "); exit(EXIT_FAILURE); } opd_open_logfile(); printf("oprofiled started %s", op_get_time()); fflush(stdout); }