Description: Enable build for hurd platform Working around PATH_MAX issues Author: Tobias Frost Last-Update: 2013-09-04 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/plugin/myisam/mi_open.cc +++ b/plugin/myisam/mi_open.cc @@ -17,6 +17,7 @@ #include "myisam_priv.h" +#include #include #include #include --- a/drizzled/cached_directory.cc +++ b/drizzled/cached_directory.cc @@ -122,6 +122,10 @@ */ char space[sizeof(dirent) + PATH_MAX + 1]; #endif +#ifdef __GNU__ + // on hurd you need UCHAR_MAX ... + char space[sizeof(dirent) + UCHAR_MAX + 1]; +#endif } buffer; int retcode; --- a/drizzled/internal/my_symlink2.cc +++ b/drizzled/internal/my_symlink2.cc @@ -34,8 +34,11 @@ { /* Test if we should create a link */ bool create_link= false; - char rp_buff[PATH_MAX]; - +#ifndef __GNU__ + char rp_buff[PATH_MAX]; +#else + char *rp_buff = NULL; +#endif if (my_disable_symlinks) { /* Create only the file, not the link and file */ @@ -44,11 +47,28 @@ } else if (linkname) { + char abs_linkname[FN_REFLEN]; +#ifndef __GNU__ if (!realpath(linkname,rp_buff)) my_load_path(rp_buff, linkname, NULL); rp_buff[FN_REFLEN-1]= '\0'; - char abs_linkname[FN_REFLEN]; strcpy(abs_linkname, rp_buff); +#else + // on hurd PATH_MAX isn't but realpath accept NULL and will malloc + rp_buff = realpath(linkname,NULL); + if (!rp_buff) { + char buffer[FN_REFLEN]; + my_load_path(buffer, linkname, NULL); + buffer[FN_REFLEN-1]= '\0'; + strcpy(abs_linkname,buffer); + } else { + if (strlen(rp_buff) >= FN_REFLEN) { + rp_buff[FN_REFLEN-1]= '\0'; + } + strcpy(abs_linkname,rp_buff); + free(rp_buff); + } +#endif create_link= strcmp(abs_linkname, filename); } --- a/plugin/innobase/os/os0file.cc +++ b/plugin/innobase/os/os0file.cc @@ -107,7 +107,7 @@ There are four io-threads (for ibuf, log, read, write). All synchronous IO requests are serviced by the calling thread using os_file_write/os_file_read. The Asynchronous requests are queued up -in an array (there are four such arrays) by the calling thread. +in an array (there are four such arrays) by the calling thread. Later these requests are picked up by the io-thread and are serviced synchronously. @@ -917,11 +917,19 @@ int ret; struct stat statinfo; #ifdef HAVE_READDIR_R - char dirent_buf[sizeof(struct dirent) +#ifndef __GNU__ + char dirent_buf[sizeof(struct dirent) /**/ + _POSIX_PATH_MAX + 100]; - /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as - the max file name len; but in most standards, the - length is NAME_MAX; we add 100 to be even safer */ + /* In /mysys/my_lib.c, _POSIX_PATH_MAX + 1 is used as + the max file name len; but in most standards, the + length is NAME_MAX; we add 100 to be even safer */ +#else + char dirent_buf[sizeof(struct dirent) /**/ + + UCHAR_MAX + 100]; + /** On hurd PATH_MAX is not defined. But we can use UCHAR_MAX + * See http://lists.ximian.com/pipermail/mono-bugs/2007-September/061089.html + and e.g. Debian BTS #438952... */ +#endif #endif next_file: @@ -951,8 +959,13 @@ return(1); } +#ifndef __GNU__ ut_a(strlen(ent->d_name) < _POSIX_PATH_MAX + 100 - 1); #else + ut_a(strlen(ent->d_name) < UCHAR_MAX + 100 - 1); +#endif + +#else ent = readdir(dir); if (ent == NULL) {