aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2020-07-27 09:49:55 -0700
committerTony Luck <tony.luck@intel.com>2020-07-27 09:49:55 -0700
commit560257780df11ed1d227da87bf979e93d04c4374 (patch)
tree31c996cd411a0773bd4899e5223fb325f949238c
parentb17c27b2c21da9dc472594376e1f7c430d5364da (diff)
downloadras-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.c5
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;