--- 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 @@ -69,7 +69,7 @@ AC_HEADER_STDC AC_HEADER_TIME -AC_CHECK_HEADERS(ctype.h dirent.h errno.h fcntl.h getopt.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(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) ################################################################################ --- 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.09.orig/lib/ioctl/libdm-iface.c 2006-08-08 21:22:31.000000000 +0000 +++ device-mapper.1.02.09.klibc/lib/ioctl/libdm-iface.c 2006-09-27 18:22:22.000000000 +0000 @@ -135,17 +135,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_error("%s: fopen failed: %s", file, strerror(errno)); 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; @@ -155,10 +163,9 @@ } dm_bit_set(_dm_bitset, num); } - } else do { - c = fgetc(fl); - } while (c != EOF && c != '\n'); - } + } + } while (size > 0); + if (fclose(fl)) log_error("%s: fclose failed: %s", file, strerror(errno)); --- device-mapper.1.02.09.orig/lib/libdm-file.c 2006-05-10 16:23:41.000000000 +0000 +++ device-mapper.1.02.09.klibc/lib/libdm-file.c 2006-09-27 18:22:22.000000000 +0000 @@ -16,10 +16,16 @@ #include "lib.h" #include "libdm-file.h" -#include #include #include +#ifndef __KLIBC__ +# include +# ifdef linux +# include +# endif +#endif + static int _create_dir_recursive(const char *dir) { char *orig, *s;