100-musl-compat.patch (4619B)
1 --- a/configure.ac 2 +++ b/configure.ac 3 @@ -42,7 +42,7 @@ DAV_CHECK_NEON 4 # Checks for header files. 5 AC_HEADER_DIRENT 6 AC_HEADER_STDC 7 -AC_CHECK_HEADERS([fcntl.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h syslog.h termios.h unistd.h utime.h]) 8 +AC_CHECK_HEADERS([error.h fcntl.h libintl.h langinfo.h limits.h locale.h mntent.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/mount.h sys/time.h sys/select.h sys/types.h syslog.h termios.h unistd.h utime.h]) 9 10 # Checks for typedefs, structures, and compiler characteristics. 11 AC_C_CONST 12 @@ -78,7 +78,7 @@ AC_FUNC_SELECT_ARGTYPES 13 AC_FUNC_STRFTIME 14 AC_FUNC_STAT 15 AC_FUNC_UTIME_NULL 16 -AC_CHECK_FUNCS([endpwent ftruncate getmntent memset mkdir nl_langinfo rpmatch select setlocale strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol strtoull utime]) 17 +AC_CHECK_FUNCS([endpwent ftruncate getmntent memset mkdir nl_langinfo rpmatch select setlocale strcasecmp strchr strdup strerror strpbrk strrchr strstr strtol strtoull utime canonicalize_file_name fopencookie]) 18 19 # Misc. 20 DAV_DEFAULTS 21 --- a/src/cache.c 22 +++ b/src/cache.c 23 @@ -19,12 +19,12 @@ 24 25 26 #include "config.h" 27 +#include "compat.h" 28 29 #ifdef HAVE_DIRENT_H 30 #include <dirent.h> 31 #endif 32 #include <errno.h> 33 -#include <error.h> 34 #ifdef HAVE_FCNTL_H 35 #include <fcntl.h> 36 #endif 37 --- a/src/dav_fuse.c 38 +++ b/src/dav_fuse.c 39 @@ -47,6 +47,9 @@ 40 #ifdef HAVE_SYS_STAT_H 41 #include <sys/stat.h> 42 #endif 43 +#ifdef HAVE_SYS_SELECT_H 44 +#include <sys/select.h> 45 +#endif 46 47 #include "defaults.h" 48 #include "mount_davfs.h" 49 --- a/src/kernel_interface.c 50 +++ b/src/kernel_interface.c 51 @@ -19,8 +19,8 @@ 52 53 54 #include "config.h" 55 +#include "compat.h" 56 57 -#include <error.h> 58 #ifdef HAVE_FCNTL_H 59 #include <fcntl.h> 60 #endif 61 @@ -51,6 +51,9 @@ 62 #ifdef HAVE_SYS_STAT_H 63 #include <sys/stat.h> 64 #endif 65 +#ifdef HAVE_SYS_TYPES_H 66 +#include <sys/types.h> 67 +#endif 68 #include <sys/wait.h> 69 70 #include "defaults.h" 71 --- a/src/mount_davfs.c 72 +++ b/src/mount_davfs.c 73 @@ -19,10 +19,10 @@ 74 75 76 #include "config.h" 77 +#include "compat.h" 78 79 #include <ctype.h> 80 #include <errno.h> 81 -#include <error.h> 82 #ifdef HAVE_FCNTL_H 83 #include <fcntl.h> 84 #endif 85 --- a/src/umount_davfs.c 86 +++ b/src/umount_davfs.c 87 @@ -19,8 +19,8 @@ 88 89 90 #include "config.h" 91 +#include "compat.h" 92 93 -#include <error.h> 94 #include <errno.h> 95 #include <getopt.h> 96 #ifdef HAVE_LIBINTL_H 97 --- a/src/webdav.c 98 +++ b/src/webdav.c 99 @@ -19,9 +19,9 @@ 100 101 102 #include "config.h" 103 +#include "compat.h" 104 105 #include <errno.h> 106 -#include <error.h> 107 #ifdef HAVE_FCNTL_H 108 #include <fcntl.h> 109 #endif 110 @@ -368,6 +368,7 @@ dav_init_webdav(const dav_args *args) 111 error(EXIT_FAILURE, errno, _("socket library initialization failed")); 112 113 if (args->neon_debug & ~NE_DBG_HTTPPLAIN) { 114 +#ifdef HAVE_FOPENCOOKIE 115 char *buf = malloc(log_bufsize); 116 cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t)); 117 if (!log_func) abort(); 118 @@ -380,6 +381,9 @@ dav_init_webdav(const dav_args *args) 119 error(EXIT_FAILURE, errno, 120 _("can't open stream to log neon-messages")); 121 ne_debug_init(log_stream, args->neon_debug); 122 +#else 123 + error(EXIT_FAILURE, 0, "neon debugging unsupported"); 124 +#endif 125 } 126 127 session = ne_session_create(args->scheme, args->host, args->port); 128 --- /dev/null 129 +++ b/src/compat.h 130 @@ -0,0 +1,64 @@ 131 +#ifndef _COMPAT_H 132 +#define _COMPAT_H 133 + 134 +#ifndef _PATH_MOUNTED 135 +# define _PATH_MOUNTED "/proc/mounts" 136 +#endif 137 + 138 +#ifndef _PATH_MNTTAB 139 +# define _PATH_MNTTAB "/etc/fstab" 140 +#endif 141 + 142 +#ifdef HAVE_ERROR_H 143 +# include <error.h> 144 +#else 145 +# include <stdio.h> 146 +# include <stdarg.h> 147 +# include <stdlib.h> 148 +# include <string.h> 149 +static void error_at_line(int status, int errnum, const char *filename, 150 + unsigned int linenum, const char *format, ...) 151 +{ 152 + va_list ap; 153 + 154 + fflush(stdout); 155 + 156 + if (filename != NULL) 157 + fprintf(stderr, "%s:%u: ", filename, linenum); 158 + 159 + va_start(ap, format); 160 + vfprintf(stderr, format, ap); 161 + va_end(ap); 162 + 163 + if (errnum != 0) 164 + fprintf(stderr, ": %s", strerror(errnum)); 165 + 166 + fprintf(stderr, "\n"); 167 + 168 + if (status != 0) 169 + exit(status); 170 +} 171 + 172 +#define error(status, errnum, format...) \ 173 + error_at_line(status, errnum, NULL, 0, format) 174 + 175 +#endif /* HAVE_ERROR_H */ 176 + 177 +#ifndef HAVE_CANONICALIZE_FILE_NAME 178 +#include <limits.h> 179 +#include <string.h> 180 +#include <stdlib.h> 181 +static char * canonicalize_file_name(const char *path) 182 +{ 183 + char buf[PATH_MAX] = { }; 184 + 185 + snprintf(buf, sizeof(buf) - 1, "%s", path); 186 + 187 + if (!realpath(path, buf)) 188 + return NULL; 189 + 190 + return strdup(buf); 191 +} 192 +#endif 193 + 194 +#endif /* _COMPAT_H */