[packages] mdadm: add missing functions posix_memalign() and canonicalize_file_name...
[openwrt/svn-archive/archive.git] / utils / mdadm / patches / 200-uclibc_0.9.30_compat.patch
1 Index: mdadm-3.2/mdadm.h
2 ===================================================================
3 --- mdadm-3.2.orig/mdadm.h 2011-02-01 06:06:21.000000000 +0100
4 +++ mdadm-3.2/mdadm.h 2011-07-11 00:36:52.135848368 +0200
5 @@ -33,6 +33,37 @@
6 # endif
7 #endif
8
9 +#ifdef UCLIBC
10 +# include <features.h>
11 +# if __UCLIBC_MINOR__ <= 9 && __UCLIBC_SUBLEVEL__ <= 30
12 +
13 +#include <errno.h>
14 +void *memalign(size_t blocksize, size_t bytes);
15 +static inline int posix_memalign(void **memptr, size_t alignment, size_t size)
16 +{
17 + if (alignment % sizeof(void *) != 0)
18 + return EINVAL;
19 +
20 + *memptr = memalign(alignment, size);
21 + return (*memptr != NULL ? 0 : ENOMEM);
22 +}
23 +
24 +#include <limits.h>
25 +char *strdup(const char *s);
26 +char *realpath(const char *path, char *resolved_path);
27 +static inline char *canonicalize_file_name(const char *path)
28 +{
29 + char resolved[PATH_MAX] = { 0 };
30 +
31 + if (!realpath(path, resolved))
32 + return NULL;
33 +
34 + return strdup(resolved);
35 +}
36 +
37 +# endif /* __UCLIBC_MINOR__ <= 9 && __UCLIBC_SUBLEVEL__ <= 30 */
38 +#endif /* UCLIBC */
39 +
40 #include <sys/types.h>
41 #include <sys/stat.h>
42 #include <stdlib.h>