summaryrefslogtreecommitdiff
path: root/net-dialup/sterm/files/Print-more-descriptive-error-message.patch
diff options
context:
space:
mode:
Diffstat (limited to 'net-dialup/sterm/files/Print-more-descriptive-error-message.patch')
-rw-r--r--net-dialup/sterm/files/Print-more-descriptive-error-message.patch46
1 files changed, 46 insertions, 0 deletions
diff --git a/net-dialup/sterm/files/Print-more-descriptive-error-message.patch b/net-dialup/sterm/files/Print-more-descriptive-error-message.patch
new file mode 100644
index 0000000..9db1dad
--- /dev/null
+++ b/net-dialup/sterm/files/Print-more-descriptive-error-message.patch
@@ -0,0 +1,46 @@
+From 613b8407347b063320ebf408d06bb120293c6c3a Mon Sep 17 00:00:00 2001
+From: Michal Sojka <sojkam1@fel.cvut.cz>
+Date: Thu, 4 May 2017 00:00:10 +0200
+Subject: [PATCH] Print more descriptive error message
+
+---
+ sterm.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/sterm.c b/sterm.c
+index b375caf..ea86573 100644
+--- a/sterm.c
++++ b/sterm.c
+@@ -31,6 +31,7 @@
+
+ #define _BSD_SOURCE
+ #define _DEFAULT_SOURCE
++#define _GNU_SOURCE
+ #include <sys/ioctl.h>
+ #include <sys/types.h>
+ #include <unistd.h>
+@@ -44,6 +45,7 @@
+ #include <string.h>
+ #include <signal.h>
+ #include <lockdev.h>
++#include <errno.h>
+
+ #define STRINGIFY(val) #val
+ #define TOSTRING(val) STRINGIFY(val)
+@@ -269,7 +271,12 @@ int main(int argc, char *argv[])
+ fprintf(stderr, "%s is used by PID %d\n", dev, pid);
+ exit(1);
+ } else if (pid < 0) {
+- perror("dev_lock()");
++ char *msg;
++ asprintf(&msg, "dev_lock('%s')", dev); /* No free() because we exit() immediately */
++ if (errno)
++ perror(msg);
++ else
++ fprintf(stderr, "%s: Error\n", msg);
+ exit(1);
+ }
+ atexit(unlock);
+--
+2.13.0
+