summaryrefslogtreecommitdiffstats
path: root/system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff
diff options
context:
space:
mode:
Diffstat (limited to 'system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff')
-rw-r--r--system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff36
1 files changed, 36 insertions, 0 deletions
diff --git a/system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff b/system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff
new file mode 100644
index 0000000000..06b0b03980
--- /dev/null
+++ b/system/ksh-openbsd/patches/09b-linux-new_history_implementation.diff
@@ -0,0 +1,36 @@
+Linux specific modifications:
+ - #include stdint.h for uint32_t
+ - #define timespeccmp() which is sys/time.h in OpenBSD
+ - Linux doesn't have any LOCK flags for open(2), so use flock(2) instead
+
+--- ../ksh-openbsd49/history.c 2011-09-01 08:09:51.486181269 +0200
++++ history.c 2011-09-01 08:08:59.657181265 +0200
+@@ -17,11 +17,17 @@
+ #include "sh.h"
+ #include <sys/stat.h>
+ #include "strlcat.h"
++#include "stdint.h"
+
+ #ifdef HISTORY
+ # include <sys/file.h>
+ # include <sys/mman.h>
+
++#define timespeccmp(tsp, usp, cmp) \
++ (((tsp)->tv_sec == (usp)->tv_sec) ? \
++ ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
++ ((tsp)->tv_sec cmp (usp)->tv_sec))
++
+ static void writehistfile(FILE *);
+ static FILE *history_open(int *);
+ static int history_load(FILE *, Source *);
+@@ -604,7 +610,9 @@
+ FILE *f = NULL;
+ struct stat sb;
+
+- if ((fd = open(hname, O_RDWR | O_CREAT | O_EXLOCK, 0600)) == -1)
++ if ((fd = open(hname, O_RDWR | O_CREAT, 0600)) == -1)
++ return (NULL);
++ if (flock(fd, LOCK_EX) == -1)
+ return (NULL);
+ f = fdopen(fd, "r+");
+ if (f == NULL) {