summaryrefslogtreecommitdiff
path: root/sysutils/dd_rescue/patches/patch-ab
blob: 91992e03f70b5f89e18c948493463e37dc79c250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
$NetBSD: patch-ab,v 1.7 2013/06/14 01:07:58 mef Exp $

(1) clang flags:
dd_rescue.c:1494:22: warning: implicit declaration of function 'basename' is invalid in C99 [-Wimplicit-function-declaration]
        const char* ibase = basename(inm);
(2)
See http://gnats.netbsd.org/38620
dd_rescue: (fatal): allocation of aligned buffer failed!

(3) clang flags:
dd_recue.c:(.text+0x12b4): undefined reference to `mypread'
dd_rescue.c:(.text+0x1374): undefined reference to `mypwrite'

--- dd_rescue.c.orig	2013-03-31 04:24:34.000000000 +0900
+++ dd_rescue.c	2013-06-13 16:44:35.000000000 +0900
@@ -83,6 +83,7 @@
 #include <limits.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#include <libgen.h>
 
 #include "frandom.h"
 #include "list.h"
@@ -121,6 +122,10 @@
 # endif
 #endif
 
+#ifdef __DragonFly__
+#undef O_DIRECT
+#endif
+
 /* fwd decls */
 int cleanup();
 
@@ -740,7 +745,7 @@
 	return ln;
 }
 
-inline ssize_t mypread(int fd, void* bf, size_t sz, off_t off)
+static inline ssize_t mypread(int fd, void* bf, size_t sz, off_t off)
 {
 	if (i_repeat) {
 		if (i_rep_init)
@@ -762,7 +767,7 @@
 		return pread(fd, bf, sz, off);
 }
 
-inline ssize_t mypwrite(int fd, void* bf, size_t sz, off_t off)
+static inline ssize_t mypwrite(int fd, void* bf, size_t sz, off_t off)
 {
 	if (o_chr)
 		return write(fd, bf, sz);
@@ -1452,6 +1457,11 @@
 	unsigned char *ptr;
 #ifdef O_DIRECT
 	void *mp;
+#ifdef linux
+#define my_valloc(a, b, c)     posix_memalign((a), (b), (c))
+#else
+#define my_valloc(a, b, c)     !(*(a) = valloc((c)))
+#endif
 	if (posix_memalign(&mp, pagesize, bs)) {
 		fplog(stderr, "dd_rescue: (fatal): allocation of aligned buffer failed!\n");
 		cleanup(); exit(18);