--- device-mapper/configure.in~ 2008-07-06 19:22:49.965050005 +0200 +++ device-mapper/configure.in 2008-07-06 19:26:11.998363857 +0200 @@ -107,7 +107,7 @@ ################################################################################ dnl -- Check for functions -AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \ +AC_CHECK_FUNCS([gethostname memset mkdir rmdir munmap \ strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \ uname], , [AC_MSG_ERROR(bailing out)]) AC_FUNC_ALLOCA --- device-mapper.1.02.09.orig/configure.in 2006-09-27 18:22:22.000000000 +0000 +++ device-mapper.1.02.09.klibc/configure.in 2006-09-27 18:22:22.000000000 +0000 @@ -87,7 +87,7 @@ AC_HEADER_SYS_WAIT AC_HEADER_TIME -AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h \ +AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h \ stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h \ sys/types.h unistd.h], , [AC_MSG_ERROR(bailing out)]) AC_CHECK_HEADERS(termios.h sys/statvfs.h) --- device-mapper.1.02.09.orig/dmsetup/dmsetup.c 2006-08-10 20:53:21.000000000 +0000 +++ device-mapper.1.02.09.klibc/dmsetup/dmsetup.c 2006-09-27 18:22:58.000000000 +0000 @@ -31,12 +31,13 @@ #include #include #include -#include #include #include #include +#ifndef __KLIBC__ #include #include +#endif #ifdef HAVE_SYS_IOCTL_H # include @@ -1547,9 +1548,11 @@ int len; /* Symbol set default */ +#ifndef __KLIBC__ if (!strcmp(nl_langinfo(CODESET), "UTF-8")) _tsym = &_tsym_utf; else +#endif _tsym = &_tsym_ascii; /* Default */ @@ -1647,7 +1650,9 @@ memset(&_values, 0, sizeof(_values)); namebase = strdup((*argv)[0]); - base = basename(namebase); + base = strrchr(namebase,'/'); + if (base != NULL) *base++ = 0; + else base = namebase; if (!strcmp(base, "devmap_name")) { free(namebase); @@ -1783,7 +1788,9 @@ struct command *c; int r = 1; +#ifndef __KLIBC__ (void) setlocale(LC_ALL, ""); +#endif if (!_process_switches(&argc, &argv)) { fprintf(stderr, "Couldn't process command line.\n"); --- device-mapper.1.02.22/lib/ioctl/libdm-iface.c.orig 2007-08-21 18:26:07.000000000 +0200 +++ device-mapper.1.02.22/lib/ioctl/libdm-iface.c 2007-09-09 23:59:33.337996036 +0200 @@ -134,17 +134,25 @@ uint32_t *number) { FILE *fl; - char nm[256]; + char nm[256], buf[300]; int c; - uint32_t num; + uint32_t num, size; if (!(fl = fopen(file, "r"))) { log_sys_error("fopen", file); return 0; } - while (!feof(fl)) { - if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) { + /* Use fread+sscanf for klibc compatibility. */ + do { + size = 0; + do { + num = fread(&buf[size], sizeof(char), 1, fl); + if (num > 0) + size++; + } while (num > 0 && buf[size - 1] != '\n'); + buf[size] = '\0'; + if (sscanf(buf, "%d %255s\n", &num, &nm[0]) == 2) { if (!strcmp(name, nm)) { if (number) { *number = num; @@ -154,10 +162,9 @@ } dm_bit_set(_dm_bitset, num); } - } else do { - c = fgetc(fl); - } while (c != EOF && c != '\n'); - } + } + } while (size > 0); + if (fclose(fl)) log_sys_error("fclose", file); --- device-mapper.1.02.22/lib/libdm-file.c.orig 2007-08-21 18:26:06.000000000 +0200 +++ device-mapper.1.02.22/lib/libdm-file.c 2007-09-10 00:20:00.475926641 +0200 @@ -15,10 +15,16 @@ #include "lib.h" -#include #include #include +#ifndef __KLIBC__ +# include +# ifdef linux +# include +# endif +#endif + static int _create_dir_recursive(const char *dir) { char *orig, *s; @@ -73,7 +79,11 @@ int dm_fclose(FILE *stream) { +#ifdef __KLIBC__ + int prev_fail = 0; +#else int prev_fail = ferror(stream); +#endif int fclose_fail = fclose(stream); /* If there was a previous failure, but fclose succeeded,