* Fixed last commit
[project/luci.git] / libs / sgi-webuci / unmerged-patches / 050-lfs_support.patch
1 Index: boa-0.94.14rc21/src/boa.h
2 ===================================================================
3 --- boa-0.94.14rc21.orig/src/boa.h 2007-11-03 00:51:46.000000000 -0400
4 +++ boa-0.94.14rc21/src/boa.h 2007-11-03 01:05:20.000000000 -0400
5 @@ -25,7 +25,9 @@
6 #ifndef _BOA_H
7 #define _BOA_H
8
9 +/* Important, include before anything else */
10 #include "config.h"
11 +
12 #include <errno.h>
13 #include <stdlib.h> /* malloc, free, etc. */
14 #include <stdio.h> /* stdin, stdout, stderr */
15 @@ -165,7 +167,7 @@
16 void clean_pathname(char *pathname);
17 char *get_commonlog_time(void);
18 void rfc822_time_buf(char *buf, time_t s);
19 -char *simple_itoa(unsigned int i);
20 +char *simple_itoa(uint64_t i);
21 int boa_atoi(const char *s);
22 int month2int(const char *month);
23 int modified_since(time_t * mtime, const char *if_modified_since);
24 Index: boa-0.94.14rc21/src/buffer.c
25 ===================================================================
26 --- boa-0.94.14rc21.orig/src/buffer.c 2007-11-03 00:51:46.000000000 -0400
27 +++ boa-0.94.14rc21/src/buffer.c 2007-11-03 01:05:20.000000000 -0400
28 @@ -212,7 +212,7 @@
29 return -2;
30
31 if (bytes_to_write) {
32 - int bytes_written;
33 + off_t bytes_written;
34
35 bytes_written = write(req->fd, req->buffer + req->buffer_start,
36 bytes_to_write);
37 Index: boa-0.94.14rc21/src/config.h.in
38 ===================================================================
39 --- boa-0.94.14rc21.orig/src/config.h.in 2007-11-03 00:51:46.000000000 -0400
40 +++ boa-0.94.14rc21/src/config.h.in 2007-11-03 01:08:36.000000000 -0400
41 @@ -205,3 +205,16 @@
42
43 /* Define to `int' if <sys/types.h> doesn't define. */
44 #undef uid_t
45 +
46 +/* Those enable the LFS ready structures in the system headers */
47 +#define _FILE_OFFSET_BITS 64 /* glibc style */
48 +#define _LARGEFILE_SOURCE 1 /* To make ftello() visible (HP-UX 10.20). */
49 +#define _LARGE_FILES 1 /* Large file defined on AIX-style hosts. */
50 +
51 +#define _LARGEFILE64_SOURCE /* tell kernel headers to provide the O_LARGEFILE value */
52 +
53 +#if __WORDSIZE == 64
54 +#define PRINTF_OFF_T_ARG "%ld"
55 +#elif __WORDSIZE == 32
56 +#define PRINTF_OFF_T_ARG "%lld"
57 +#endif
58 Index: boa-0.94.14rc21/src/get.c
59 ===================================================================
60 --- boa-0.94.14rc21.orig/src/get.c 2007-11-03 00:51:46.000000000 -0400
61 +++ boa-0.94.14rc21/src/get.c 2007-11-03 01:08:20.000000000 -0400
62 @@ -25,6 +25,10 @@
63 #include "boa.h"
64 #include "access.h"
65
66 +#include <sys/types.h>
67 +#include <sys/stat.h>
68 +#include <fcntl.h>
69 +
70 #define STR(s) __STR(s)
71 #define __STR(s) #s
72
73 @@ -52,9 +56,9 @@
74 {
75 int data_fd, saved_errno;
76 struct stat statbuf;
77 - volatile unsigned int bytes_free;
78 + volatile off_t bytes_free;
79
80 - data_fd = open(req->pathname, O_RDONLY);
81 + data_fd = open(req->pathname, O_RDONLY|O_LARGEFILE);
82 saved_errno = errno; /* might not get used */
83
84 #ifdef GUNZIP
85 @@ -76,7 +80,7 @@
86 memcpy(gzip_pathname, req->pathname, len);
87 memcpy(gzip_pathname + len, ".gz", 3);
88 gzip_pathname[len + 3] = '\0';
89 - data_fd = open(gzip_pathname, O_RDONLY);
90 + data_fd = open(gzip_pathname, O_RDONLY|O_LARGEFILE);
91 if (data_fd != -1) {
92 close(data_fd);
93
94 @@ -430,8 +434,8 @@
95
96 int process_get(request * req)
97 {
98 - int bytes_written;
99 - volatile unsigned int bytes_to_write;
100 + off_t bytes_written;
101 + volatile off_t bytes_to_write;
102
103 if (req->method == M_HEAD) {
104 return complete_response(req);
105 @@ -531,7 +535,7 @@
106 memcpy(pathname_with_index, req->pathname, l1); /* doesn't copy NUL */
107 memcpy(pathname_with_index + l1, directory_index, l2 + 1); /* does */
108
109 - data_fd = open(pathname_with_index, O_RDONLY);
110 + data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
111
112 if (data_fd != -1) { /* user's index file */
113 /* We have to assume that directory_index will fit, because
114 @@ -555,7 +559,7 @@
115 * try index.html.gz
116 */
117 strcat(pathname_with_index, ".gz");
118 - data_fd = open(pathname_with_index, O_RDONLY);
119 + data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
120 if (data_fd != -1) { /* user's index file */
121 close(data_fd);
122
123 @@ -624,9 +628,9 @@
124 * include the NUL when calculating if the size is enough
125 */
126 snprintf(pathname_with_index, sizeof(pathname_with_index),
127 - "%s/dir.%d.%ld", cachedir,
128 + "%s/dir.%d." PRINTF_OFF_T_ARG, cachedir,
129 (int) statbuf->st_dev, statbuf->st_ino);
130 - data_fd = open(pathname_with_index, O_RDONLY);
131 + data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
132
133 if (data_fd != -1) { /* index cache */
134
135 @@ -642,7 +646,7 @@
136 if (index_directory(req, pathname_with_index) == -1)
137 return -1;
138
139 - data_fd = open(pathname_with_index, O_RDONLY); /* Last chance */
140 + data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE); /* Last chance */
141 if (data_fd != -1) {
142 strcpy(req->request_uri, directory_index); /* for mimetype */
143 fstat(data_fd, statbuf);
144 @@ -671,7 +675,7 @@
145 DIR *request_dir;
146 FILE *fdstream;
147 struct dirent *dirbuf;
148 - int bytes = 0;
149 + off_t bytes = 0;
150 char *escname = NULL;
151
152 if (chdir(req->pathname) == -1) {
153 Index: boa-0.94.14rc21/src/globals.h
154 ===================================================================
155 --- boa-0.94.14rc21.orig/src/globals.h 2007-11-03 00:51:46.000000000 -0400
156 +++ boa-0.94.14rc21/src/globals.h 2007-11-03 01:05:20.000000000 -0400
157 @@ -130,9 +130,9 @@
158 int numranges;
159
160 int data_fd; /* fd of data */
161 - unsigned long filesize; /* filesize */
162 - unsigned long filepos; /* position in file */
163 - unsigned long bytes_written; /* total bytes written (sans header) */
164 + off_t filesize; /* filesize */
165 + off_t filepos; /* position in file */
166 + size_t bytes_written; /* total bytes written (sans header) */
167 char *data_mem; /* mmapped/malloced char array */
168
169 char *logline; /* line to log file */
170 Index: boa-0.94.14rc21/src/index_dir.c
171 ===================================================================
172 --- boa-0.94.14rc21.orig/src/index_dir.c 2007-11-03 00:51:46.000000000 -0400
173 +++ boa-0.94.14rc21/src/index_dir.c 2007-11-03 01:08:11.000000000 -0400
174 @@ -19,6 +19,7 @@
175
176 /* $Id: index_dir.c,v 1.32.2.7 2005/02/22 03:00:24 jnelson Exp $*/
177
178 +#include "config.h"
179 #include <stdio.h>
180 #include <sys/stat.h>
181 #include <limits.h> /* for PATH_MAX */
182 @@ -266,10 +267,12 @@
183 printf("<tr>"
184 "<td width=\"40%%\"><a href=\"%s/\">%s/</a></td>"
185 "<td align=right>%s</td>"
186 - "<td align=right>%ld bytes</td>"
187 + "<td align=right>"
188 + PRINTF_OFF_T_ARG
189 + " bytes</td>"
190 "</tr>\n",
191 escaped_filename, html_filename,
192 - ctime(&statbuf.st_mtime), (long) statbuf.st_size);
193 + ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
194 }
195
196 printf
197 @@ -312,10 +315,12 @@
198 "<td width=\"40%%\"><a href=\"%s\">%s</a> "
199 "<a href=\"%s.gz\">(.gz)</a></td>"
200 "<td align=right>%s</td>"
201 - "<td align=right>%ld bytes</td>"
202 + "<td align=right>"
203 + PRINTF_OFF_T_ARG
204 + "bytes</td>"
205 "</tr>\n",
206 escaped_filename, html_filename, http_filename,
207 - ctime(&statbuf.st_mtime), (long) statbuf.st_size);
208 + ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
209 } else {
210 #endif
211 if (html_escape_string(http_filename, escaped_filename,
212 @@ -326,10 +331,12 @@
213 printf("<tr>"
214 "<td width=\"40%%\"><a href=\"%s\">%s</a></td>"
215 "<td align=right>%s</td>"
216 - "<td align=right>%ld bytes</td>"
217 + "<td align=right>"
218 + PRINTF_OFF_T_ARG
219 + "bytes</td>"
220 "</tr>\n",
221 escaped_filename, html_filename,
222 - ctime(&statbuf.st_mtime), (long) statbuf.st_size);
223 + ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
224 #ifdef GUNZIP
225 }
226 #endif
227 Index: boa-0.94.14rc21/src/log.c
228 ===================================================================
229 --- boa-0.94.14rc21.orig/src/log.c 2007-11-03 00:51:46.000000000 -0400
230 +++ boa-0.94.14rc21/src/log.c 2007-11-03 01:05:20.000000000 -0400
231 @@ -146,7 +146,7 @@
232 } else if (vhost_root) {
233 printf("%s ", (req->host ? req->host : "(null)"));
234 }
235 - printf("%s - - %s\"%s\" %d %ld \"%s\" \"%s\"\n",
236 + printf("%s - - %s\"%s\" %d %zu \"%s\" \"%s\"\n",
237 req->remote_ip_addr,
238 get_commonlog_time(),
239 req->logline ? req->logline : "-",
240 Index: boa-0.94.14rc21/src/mmap_cache.c
241 ===================================================================
242 --- boa-0.94.14rc21.orig/src/mmap_cache.c 2007-11-03 00:51:46.000000000 -0400
243 +++ boa-0.94.14rc21/src/mmap_cache.c 2007-11-03 01:05:20.000000000 -0400
244 @@ -140,7 +140,7 @@
245 int data_fd;
246 struct stat statbuf;
247 struct mmap_entry *e;
248 - data_fd = open(fname, O_RDONLY);
249 + data_fd = open(fname, O_RDONLY|O_LARGEFILE);
250 if (data_fd == -1) {
251 perror(fname);
252 return NULL;
253 Index: boa-0.94.14rc21/src/pipe.c
254 ===================================================================
255 --- boa-0.94.14rc21.orig/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
256 +++ boa-0.94.14rc21/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
257 @@ -37,8 +37,8 @@
258
259 int read_from_pipe(request * req)
260 {
261 - int bytes_read; /* signed */
262 - unsigned int bytes_to_read; /* unsigned */
263 + off_t bytes_read; /* signed */
264 + off_t bytes_to_read; /* unsigned */ /* XXX really? */
265
266 bytes_to_read = BUFFER_SIZE - (req->header_end - req->buffer - 1);
267
268 @@ -128,8 +128,8 @@
269
270 int write_from_pipe(request * req)
271 {
272 - int bytes_written;
273 - size_t bytes_to_write = req->header_end - req->header_line;
274 + off_t bytes_written;
275 + off_t bytes_to_write = req->header_end - req->header_line;
276
277 if (bytes_to_write == 0) {
278 if (req->cgi_status == CGI_DONE)
279 @@ -170,9 +170,9 @@
280 #ifdef HAVE_SENDFILE
281 int io_shuffle_sendfile(request * req)
282 {
283 - int bytes_written;
284 - size_t bytes_to_write;
285 off_t sendfile_offset;
286 + off_t bytes_written;
287 + off_t bytes_to_write;
288
289 if (req->method == M_HEAD) {
290 return complete_response(req);
291 @@ -266,8 +266,8 @@
292
293 int io_shuffle(request * req)
294 {
295 - int bytes_to_read;
296 - int bytes_written, bytes_to_write;
297 + off_t bytes_to_read;
298 + off_t bytes_written, bytes_to_write;
299
300 if (req->method == M_HEAD) {
301 return complete_response(req);
302 @@ -287,7 +287,7 @@
303 bytes_to_read = bytes_to_write;
304
305 if (bytes_to_read > 0 && req->data_fd) {
306 - int bytes_read;
307 + off_t bytes_read;
308 off_t temp;
309
310 temp = lseek(req->data_fd, req->ranges->start, SEEK_SET);
311 Index: boa-0.94.14rc21/src/range.c
312 ===================================================================
313 --- boa-0.94.14rc21.orig/src/range.c 2007-11-03 00:51:46.000000000 -0400
314 +++ boa-0.94.14rc21/src/range.c 2007-11-03 01:05:20.000000000 -0400
315 @@ -147,7 +147,7 @@
316 * 5) start > stop && start != -1 :: invalid
317 */
318 DEBUG(DEBUG_RANGE) {
319 - fprintf(stderr, "range.c: ranges_fixup: %lu-%lu\n", r->start, r->stop);
320 + fprintf(stderr, "range.c: ranges_fixup: %lu - %lu\n", r->start, r->stop);
321 }
322
323 /* no stop range specified or stop is too big.
324 Index: boa-0.94.14rc21/src/read.c
325 ===================================================================
326 --- boa-0.94.14rc21.orig/src/read.c 2007-11-03 00:51:46.000000000 -0400
327 +++ boa-0.94.14rc21/src/read.c 2007-11-03 01:05:20.000000000 -0400
328 @@ -38,7 +38,7 @@
329
330 int read_header(request * req)
331 {
332 - int bytes;
333 + off_t bytes;
334 char *check, *buffer;
335 unsigned char uc;
336
337 @@ -179,7 +179,7 @@
338 */
339
340 if (req->content_length) {
341 - int content_length;
342 + off_t content_length;
343
344 content_length = boa_atoi(req->content_length);
345 /* Is a content-length of 0 legal? */
346 @@ -195,7 +195,7 @@
347 && content_length > single_post_limit) {
348 log_error_doc(req);
349 fprintf(stderr,
350 - "Content-Length [%d] > SinglePostLimit [%d] on POST!\n",
351 + "Content-Length [" PRINTF_OFF_T_ARG "] > SinglePostLimit [%d] on POST!\n",
352 content_length, single_post_limit);
353 send_r_bad_request(req);
354 return 0;
355 @@ -224,7 +224,7 @@
356
357 if (req->status < BODY_READ) {
358 /* only reached if request is split across more than one packet */
359 - unsigned int buf_bytes_left;
360 + off_t buf_bytes_left;
361
362 buf_bytes_left = CLIENT_STREAM_SIZE - req->client_stream_pos;
363 if (buf_bytes_left < 1 || buf_bytes_left > CLIENT_STREAM_SIZE) {
364 @@ -273,7 +273,7 @@
365 DEBUG(DEBUG_HEADER_READ) {
366 log_error_time();
367 req->client_stream[req->client_stream_pos] = '\0';
368 - fprintf(stderr, "%s:%d -- We read %d bytes: \"%s\"\n",
369 + fprintf(stderr, "%s:%d -- We read " PRINTF_OFF_T_ARG " bytes: \"%s\"\n",
370 __FILE__, __LINE__, bytes,
371 #ifdef VERY_FASCIST_LOGGING2
372 req->client_stream + req->client_stream_pos - bytes
373 @@ -309,8 +309,8 @@
374
375 int read_body(request * req)
376 {
377 - int bytes_read;
378 - unsigned int bytes_to_read, bytes_free;
379 + off_t bytes_read;
380 + off_t bytes_to_read, bytes_free;
381
382 bytes_free = BUFFER_SIZE - (req->header_end - req->header_line);
383 bytes_to_read = req->filesize - req->filepos;
384 @@ -367,8 +367,8 @@
385
386 int write_body(request * req)
387 {
388 - int bytes_written;
389 - unsigned int bytes_to_write = req->header_end - req->header_line;
390 + off_t bytes_written;
391 + off_t bytes_to_write = req->header_end - req->header_line;
392
393 if (req->filepos + bytes_to_write > req->filesize)
394 bytes_to_write = req->filesize - req->filepos;
395 @@ -402,7 +402,7 @@
396 }
397 DEBUG(DEBUG_HEADER_READ) {
398 log_error_time();
399 - fprintf(stderr, "%s:%d - wrote %d bytes of CGI body. %ld of %ld\n",
400 + fprintf(stderr, "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes of CGI body. " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
401 __FILE__, __LINE__,
402 bytes_written, req->filepos, req->filesize);
403 }
404 @@ -417,7 +417,7 @@
405
406 req->header_line[bytes_written] = '\0';
407 fprintf(stderr,
408 - "%s:%d - wrote %d bytes (%s). %lu of %lu\n",
409 + "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes (%s). " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
410 __FILE__, __LINE__, bytes_written,
411 req->header_line, req->filepos, req->filesize);
412 req->header_line[bytes_written] = c;
413 Index: boa-0.94.14rc21/src/request.c
414 ===================================================================
415 --- boa-0.94.14rc21.orig/src/request.c 2007-11-03 00:51:46.000000000 -0400
416 +++ boa-0.94.14rc21/src/request.c 2007-11-03 01:05:20.000000000 -0400
417 @@ -259,14 +259,14 @@
418
419 static void sanitize_request(request * req, int new_req)
420 {
421 - static unsigned int bytes_to_zero = offsetof(request, fd);
422 + static off_t bytes_to_zero = offsetof(request, fd);
423
424 if (new_req) {
425 req->kacount = ka_max;
426 req->time_last = current_time;
427 req->client_stream_pos = 0;
428 } else {
429 - unsigned int bytes_to_move =
430 + off_t bytes_to_move =
431 req->client_stream_pos - req->parse_pos;
432
433 if (bytes_to_move) {
434 @@ -282,7 +282,7 @@
435
436 DEBUG(DEBUG_REQUEST) {
437 log_error_time();
438 - fprintf(stderr, "req: %p, offset: %u\n", (void *) req,
439 + fprintf(stderr, "req: %p, offset: " PRINTF_OFF_T_ARG "\n", (void *) req,
440 bytes_to_zero);
441 }
442
443 Index: boa-0.94.14rc21/src/util.c
444 ===================================================================
445 --- boa-0.94.14rc21.orig/src/util.c 2007-11-03 01:05:20.000000000 -0400
446 +++ boa-0.94.14rc21/src/util.c 2007-11-03 01:05:20.000000000 -0400
447 @@ -497,7 +497,7 @@
448 memcpy(p, day_tab + t->tm_wday * 4, 4);
449 }
450
451 -char *simple_itoa(unsigned int i)
452 +char *simple_itoa(uint64_t i)
453 {
454 /* 21 digits plus null terminator, good for 64-bit or smaller ints
455 * for bigger ints, use a bigger buffer!