diff options
author | Tony Luck <tony.luck@intel.com> | 2020-07-27 09:49:55 -0700 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2020-07-27 09:49:55 -0700 |
commit | 560257780df11ed1d227da87bf979e93d04c4374 (patch) | |
tree | 31c996cd411a0773bd4899e5223fb325f949238c | |
parent | b17c27b2c21da9dc472594376e1f7c430d5364da (diff) | |
download | ras-tools-560257780df11ed1d227da87bf979e93d04c4374.tar.gz |
einj_mem_uc: Print errno or byte count for unsuccessful write
If the write fails then print out the system error code. If it
partially fails, print how many bytes were written.
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | einj_mem_uc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c index affd9f1..aa79c8d 100644 --- a/einj_mem_uc.c +++ b/einj_mem_uc.c @@ -20,6 +20,7 @@ #define _GNU_SOURCE 1 #define __USE_GNU 1 #include <sched.h> +#include <errno.h> extern long long vtop(long long); extern void proc_cpuinfo(int *nsockets, int *ncpus, char *model, int **apicmap); @@ -305,9 +306,9 @@ int trigger_copyin(char *addr) (void)unlink(filename); if ((ret = write(fd, addr, 16) != 16)) { if (ret == -1) - fprintf(stderr, "%s: couldn't write temp file\n", progname); + fprintf(stderr, "%s: couldn't write temp file (errno=%d)\n", progname, errno); else - fprintf(stderr, "%s: short write to temp file\n", progname); + fprintf(stderr, "%s: short (%d bytes) write to temp file\n", ret, progname); } close(fd); return 0; |