[PATCH 4/8] Add function for getting errno string.

Eugene Syromyatnikov evgsyr at gmail.com
Thu Sep 29 12:56:27 UTC 2016


* syscall.c (err_name): New function.
* defs.h: Add declaration of err_name().
---
 defs.h    |    1 +
 syscall.c |    9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/defs.h b/defs.h
index ffea23f..1e2363b 100644
--- a/defs.h
+++ b/defs.h
@@ -457,6 +457,7 @@ extern void clear_regs(void);
 extern void get_regs(pid_t pid);
 extern int get_scno(struct tcb *tcp);
 extern const char *syscall_name(long scno);
+const char *err_name(unsigned err);
 
 extern bool is_erestart(struct tcb *);
 extern void temporarily_clear_syserror(struct tcb *);
diff --git a/syscall.c b/syscall.c
index f649a90..ee2d8cc 100644
--- a/syscall.c
+++ b/syscall.c
@@ -765,6 +765,15 @@ syscall_name(long scno)
 	}
 }
 
+const char *
+err_name(unsigned err)
+{
+	if ((err < nerrnos) && errnoent[err])
+		return errnoent[err];
+
+	return NULL;
+}
+
 static long get_regs_error;
 
 void
-- 
1.7.10.4





More information about the Strace-devel mailing list