From eb8a6b1b4c9cf66afc395f8de49f6c189217e8e3 Mon Sep 17 00:00:00 2001 From: Clay Smith Date: Sat, 25 Mar 2023 00:17:05 -0500 Subject: Clearer error message when unable to read devices. --- handle_devices.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'handle_devices.c') diff --git a/handle_devices.c b/handle_devices.c index 439ad27..7c854d0 100644 --- a/handle_devices.c +++ b/handle_devices.c @@ -37,7 +37,8 @@ void print_one_event(unsigned long long event_num) int fptr = open(path_to_event, O_RDWR); int initial_read = read(fptr, &event, event_size); if (initial_read == -1) { - fprintf(stderr, "PROBLEM READING FILE!\n"); + fprintf(stderr, "PROBLEM READING FILE!\n \ + Either your input number does not correlate to a device file or you do not have permission set up properly to read input files. (Most common)"); exit(-1); } char buffer[BUFSIZE+1] = {0}; @@ -76,7 +77,8 @@ void print_multiple_events(int num_events, unsigned long long event_nums[]) //make sure there was no error int initial_read = read(event_fptrs[0], &event[0], event_size); if (initial_read == -1) { - fprintf(stderr, "PROBLEM READING FILE!\n"); + fprintf(stderr, "PROBLEM READING FILE!\n \ + Either your input number does not correlate to a device file or you do not have permission set up properly to read input files. (Most common)"); exit(-1); } //shared memory for all processes to get usec @@ -101,7 +103,8 @@ void print_multiple_events(int num_events, unsigned long long event_nums[]) char buffer[BUFSIZE+1]; int initial_read = read(event_fptrs[0], &event[0], event_size); if (initial_read == -1) { - fprintf(stderr, "PROBLEM READING FILE!\n"); + fprintf(stderr, "PROBLEM READING FILE!\n \ + Either your input number does not correlate to a device file or you do not have permission set up properly to read input files. (Most common)"); exit(-1); } int string_size = 0; @@ -126,7 +129,8 @@ void print_multiple_events(int num_events, unsigned long long event_nums[]) char buffer[BUFSIZE+1]; int initial_read = read(event_fptrs[i+1], &event[i+1], event_size); if (initial_read == -1) { - fprintf(stderr, "PROBLEM READING FILE!\n"); + fprintf(stderr, "PROBLEM READING FILE!\n \ + Either your input number does not correlate to a device file or you do not have permission set up properly to read input files. (Most common)"); exit(-1); } int string_size = 0; -- cgit v1.2.1