]> git.pld-linux.org Git - packages/device-mapper.git/blob - device-mapper-klibc.patch
- lvm2 up to 2.02.43; device-mapper is now part of lvm2 package
[packages/device-mapper.git] / device-mapper-klibc.patch
1 --- device-mapper/configure.in~ 2008-07-06 19:22:49.965050005 +0200
2 +++ device-mapper/configure.in  2008-07-06 19:26:11.998363857 +0200
3 @@ -107,7 +107,7 @@
4  
5  ################################################################################
6  dnl -- Check for functions
7 -AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \
8 +AC_CHECK_FUNCS([gethostname memset mkdir rmdir munmap \
9    strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \
10    uname], , [AC_MSG_ERROR(bailing out)])
11  AC_FUNC_ALLOCA
12 --- device-mapper.1.02.09.orig/configure.in     2006-09-27 18:22:22.000000000 +0000
13 +++ device-mapper.1.02.09.klibc/configure.in    2006-09-27 18:22:22.000000000 +0000
14 @@ -87,7 +87,7 @@
15  AC_HEADER_SYS_WAIT
16  AC_HEADER_TIME
17  
18 -AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h \
19 +AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h \
20    stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h \
21    sys/types.h unistd.h], , [AC_MSG_ERROR(bailing out)])
22  AC_CHECK_HEADERS(termios.h sys/statvfs.h)
23 --- device-mapper.1.02.09.orig/dmsetup/dmsetup.c        2006-08-10 20:53:21.000000000 +0000
24 +++ device-mapper.1.02.09.klibc/dmsetup/dmsetup.c       2006-09-27 18:22:58.000000000 +0000
25 @@ -31,12 +31,13 @@
26  #include <dirent.h>
27  #include <errno.h>
28  #include <unistd.h>
29 -#include <libgen.h>
30  #include <sys/wait.h>
31  #include <unistd.h>
32  #include <sys/param.h>
33 +#ifndef __KLIBC__
34  #include <locale.h>
35  #include <langinfo.h>
36 +#endif
37  
38  #ifdef HAVE_SYS_IOCTL_H
39  #  include <sys/ioctl.h>
40 @@ -1547,9 +1548,11 @@
41         int len;
42  
43         /* Symbol set default */
44 +#ifndef __KLIBC__
45         if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
46                 _tsym = &_tsym_utf;
47         else
48 +#endif
49                 _tsym = &_tsym_ascii;
50  
51         /* Default */
52 @@ -1647,7 +1650,9 @@
53         memset(&_values, 0, sizeof(_values));
54  
55         namebase = strdup((*argv)[0]);
56 -       base = basename(namebase);
57 +       base = strrchr(namebase,'/');
58 +       if (base != NULL) *base++ = 0;
59 +       else base = namebase;
60  
61         if (!strcmp(base, "devmap_name")) {
62                 free(namebase);
63 @@ -1783,7 +1788,9 @@
64         struct command *c;
65         int r = 1;
66  
67 +#ifndef __KLIBC__
68         (void) setlocale(LC_ALL, "");
69 +#endif
70  
71         if (!_process_switches(&argc, &argv)) {
72                 fprintf(stderr, "Couldn't process command line.\n");
73 --- device-mapper.1.02.22/lib/ioctl/libdm-iface.c.orig  2007-08-21 18:26:07.000000000 +0200
74 +++ device-mapper.1.02.22/lib/ioctl/libdm-iface.c       2007-09-09 23:59:33.337996036 +0200
75 @@ -134,17 +134,25 @@
76                             uint32_t *number)
77  {
78         FILE *fl;
79 -       char nm[256];
80 +       char nm[256], buf[300];
81         int c;
82 -       uint32_t num;
83 +       uint32_t num, size;
84  
85         if (!(fl = fopen(file, "r"))) {
86                 log_sys_error("fopen", file);
87                 return 0;
88         }
89  
90 -       while (!feof(fl)) {
91 -               if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) {
92 +       /* Use fread+sscanf for klibc compatibility. */
93 +       do {
94 +               size = 0;
95 +               do {
96 +                       num = fread(&buf[size], sizeof(char), 1, fl);
97 +                       if (num > 0)
98 +                               size++;
99 +               } while (num > 0 && buf[size - 1] != '\n');
100 +               buf[size] = '\0';
101 +               if (sscanf(buf, "%d %255s\n", &num, &nm[0]) == 2) {
102                         if (!strcmp(name, nm)) {
103                                 if (number) {
104                                         *number = num;
105 @@ -154,10 +162,9 @@
106                                 }
107                                 dm_bit_set(_dm_bitset, num);
108                         }
109 -               } else do {
110 -                       c = fgetc(fl);
111 -               } while (c != EOF && c != '\n');
112 -       }
113 +               }
114 +       } while (size > 0);
115 +       
116         if (fclose(fl))
117                 log_sys_error("fclose", file);
118  
119 --- device-mapper.1.02.22/lib/libdm-file.c.orig 2007-08-21 18:26:06.000000000 +0200
120 +++ device-mapper.1.02.22/lib/libdm-file.c      2007-09-10 00:20:00.475926641 +0200
121 @@ -15,10 +15,16 @@
122  
123  #include "lib.h"
124  
125 -#include <sys/file.h>
126  #include <fcntl.h>
127  #include <dirent.h>
128  
129 +#ifndef __KLIBC__
130 +#  include <sys/file.h>
131 +#  ifdef linux
132 +#    include <malloc.h>
133 +#  endif
134 +#endif
135 +
136  static int _create_dir_recursive(const char *dir)
137  {
138         char *orig, *s;
139 @@ -73,7 +79,11 @@
140  
141  int dm_fclose(FILE *stream)
142  {
143 +#ifdef __KLIBC__
144 +       int prev_fail = 0;
145 +#else
146         int prev_fail = ferror(stream);
147 +#endif
148         int fclose_fail = fclose(stream);
149  
150         /* If there was a previous failure, but fclose succeeded,
This page took 0.040572 seconds and 3 git commands to generate.