| @@ -1,30 +1,64 @@ | | | @@ -1,30 +1,64 @@ |
1 | $NetBSD: patch-ab,v 1.6 2013/06/04 00:47:46 mef Exp $ | | 1 | $NetBSD: patch-ab,v 1.7 2013/06/14 01:07:58 mef Exp $ |
2 | | | 2 | |
| | | 3 | (1) clang flags: |
| | | 4 | dd_rescue.c:1494:22: warning: implicit declaration of function 'basename' is invalid in C99 [-Wimplicit-function-declaration] |
| | | 5 | const char* ibase = basename(inm); |
| | | 6 | (2) |
3 | See http://gnats.netbsd.org/38620 | | 7 | See http://gnats.netbsd.org/38620 |
4 | dd_rescue: (fatal): allocation of aligned buffer failed! | | 8 | dd_rescue: (fatal): allocation of aligned buffer failed! |
5 | | | 9 | |
| | | 10 | (3) clang flags: |
| | | 11 | dd_recue.c:(.text+0x12b4): undefined reference to `mypread' |
| | | 12 | dd_rescue.c:(.text+0x1374): undefined reference to `mypwrite' |
| | | 13 | |
6 | --- dd_rescue.c.orig 2013-03-31 04:24:34.000000000 +0900 | | 14 | --- dd_rescue.c.orig 2013-03-31 04:24:34.000000000 +0900 |
7 | +++ dd_rescue.c 2013-04-08 17:03:27.000000000 +0900 | | 15 | +++ dd_rescue.c 2013-06-13 16:44:35.000000000 +0900 |
8 | @@ -121,6 +121,10 @@ _syscall6(long, splice, int, fdin, loff_ | | 16 | @@ -83,6 +83,7 @@ |
| | | 17 | #include <limits.h> |
| | | 18 | #include <sys/time.h> |
| | | 19 | #include <sys/stat.h> |
| | | 20 | +#include <libgen.h> |
| | | 21 | |
| | | 22 | #include "frandom.h" |
| | | 23 | #include "list.h" |
| | | 24 | @@ -121,6 +122,10 @@ |
9 | # endif | | 25 | # endif |
10 | #endif | | 26 | #endif |
11 | | | 27 | |
12 | +#ifdef __DragonFly__ | | 28 | +#ifdef __DragonFly__ |
13 | +#undef O_DIRECT | | 29 | +#undef O_DIRECT |
14 | +#endif | | 30 | +#endif |
15 | + | | 31 | + |
16 | /* fwd decls */ | | 32 | /* fwd decls */ |
17 | int cleanup(); | | 33 | int cleanup(); |
18 | | | 34 | |
19 | @@ -1452,6 +1456,11 @@ unsigned char* zalloc_buf(unsigned int b | | 35 | @@ -740,7 +745,7 @@ |
| | | 36 | return ln; |
| | | 37 | } |
| | | 38 | |
| | | 39 | -inline ssize_t mypread(int fd, void* bf, size_t sz, off_t off) |
| | | 40 | +static inline ssize_t mypread(int fd, void* bf, size_t sz, off_t off) |
| | | 41 | { |
| | | 42 | if (i_repeat) { |
| | | 43 | if (i_rep_init) |
| | | 44 | @@ -762,7 +767,7 @@ |
| | | 45 | return pread(fd, bf, sz, off); |
| | | 46 | } |
| | | 47 | |
| | | 48 | -inline ssize_t mypwrite(int fd, void* bf, size_t sz, off_t off) |
| | | 49 | +static inline ssize_t mypwrite(int fd, void* bf, size_t sz, off_t off) |
| | | 50 | { |
| | | 51 | if (o_chr) |
| | | 52 | return write(fd, bf, sz); |
| | | 53 | @@ -1452,6 +1457,11 @@ |
20 | unsigned char *ptr; | | 54 | unsigned char *ptr; |
21 | #ifdef O_DIRECT | | 55 | #ifdef O_DIRECT |
22 | void *mp; | | 56 | void *mp; |
23 | +#ifdef linux | | 57 | +#ifdef linux |
24 | +#define my_valloc(a, b, c) posix_memalign((a), (b), (c)) | | 58 | +#define my_valloc(a, b, c) posix_memalign((a), (b), (c)) |
25 | +#else | | 59 | +#else |
26 | +#define my_valloc(a, b, c) !(*(a) = valloc((c))) | | 60 | +#define my_valloc(a, b, c) !(*(a) = valloc((c))) |
27 | +#endif | | 61 | +#endif |
28 | if (posix_memalign(&mp, pagesize, bs)) { | | 62 | if (posix_memalign(&mp, pagesize, bs)) { |
29 | fplog(stderr, "dd_rescue: (fatal): allocation of aligned buffer failed!\n"); | | 63 | fplog(stderr, "dd_rescue: (fatal): allocation of aligned buffer failed!\n"); |
30 | cleanup(); exit(18); | | 64 | cleanup(); exit(18); |