rbb 00/01/06 06:43:51
Modified: src/include httpd.h src/lib/apr/file_io/unix fileacc.c filedup.c fileio.h filestat.c open.c pipe.c readwrite.c src/lib/apr/include apr_file_io.h src/lib/apr/test ab_apr.c testmmap.c src/main http_config.c http_core.c http_log.c http_protocol.c http_request.c util.c src/modules/standard mod_actions.c mod_asis.c mod_autoindex.c mod_cgi.c mod_dir.c mod_include.c mod_mime.c mod_negotiation.c mod_userdir.c Log: Separate the stat structure from the file structure and use ap_stat and ap_getfileinfo in apache. Revision Changes Path 1.17 +1 -1 apache-2.0/src/include/httpd.h Index: httpd.h =================================================================== RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- httpd.h 1999/12/21 21:41:43 1.16 +++ httpd.h 2000/01/06 14:43:00 1.17 @@ -768,7 +768,7 @@ char *filename; char *path_info; char *args; /* QUERY_ARGS, if any */ - struct stat finfo; /* ST_MODE set to zero if no such file */ + ap_finfo_t finfo; /* ST_MODE set to zero if no such file */ uri_components parsed_uri; /* components of uri, dismantled */ /* Various other config info which may change with .htaccess files 1.13 +16 -130 apache-2.0/src/lib/apr/file_io/unix/fileacc.c Index: fileacc.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/fileacc.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- fileacc.c 1999/12/03 15:18:22 1.12 +++ fileacc.c 2000/01/06 14:43:05 1.13 @@ -104,144 +104,30 @@ } /* ***APRDOC******************************************************** - * ap_status_t ap_get_filesize(ap_ssize_t *, ap_file_t *) - * Return the size of the current file. - * arg 1) The currently open file. - * arg 2) The size of the file. - */ -ap_status_t ap_get_filesize(ap_ssize_t *size, struct file_t *file) -{ - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - *size = file->size; - return APR_SUCCESS; - } - else { - *size = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_fileperms(ap_fileperms_t *, ap_file_t *) - * Return the permissions of the current file. - * arg 1) The currently open file. - * arg 2) The permissions of the file. - */ -ap_status_t ap_get_fileperms(ap_fileperms_t *perm, struct file_t *file) -{ - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - *perm = file->protection; - return APR_SUCCESS; - } - else { - *perm = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_fileatime(time_t *, ap_file_t *) - * Return the last access time of the current file. - * arg 1) The currently open file. - * arg 2) The last access time of the file. - */ -ap_status_t ap_get_fileatime(time_t *atime, struct file_t *file) -{ - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - *atime = file->atime; - return APR_SUCCESS; - } - else { - *atime = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filectime(time_t *, ap_file_t *) - * Return the time of the last change to the current file. - * arg 1) The currently open file. - * arg 2) The last change time of the file. - */ -ap_status_t ap_get_filectime(time_t *ptime, struct file_t *file) -{ - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - *ptime = file->ctime; - return APR_SUCCESS; - } - else { - *ptime = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_filemtime(time_t *, ap_file_t *) - * Return the last modified time of the current file. - * arg 1) The currently open file. - * arg 2) The last modified time of the file. - */ -ap_status_t ap_get_filemtime(time_t *mtime, struct file_t *file) -{ - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - *mtime = file->mtime; - return APR_SUCCESS; - } - else { - *mtime = -1; - return APR_ENOFILE; - } -} - -/* ***APRDOC******************************************************** * ap_status_t ap_get_filetype(ap_filetype_e, ap_file_t *) * Return the type of the current file. * arg 1) The currently open file. * arg 2) The file type */ -ap_status_t ap_get_filetype(ap_filetype_e *type, struct file_t *file) +ap_status_t ap_get_filetype(ap_filetype_e *type, ap_fileperms_t perms) { - if (file != NULL) { - if (file->stated == 0) { - ap_getfileinfo(file); - } - if (S_ISREG(file->protection)) - *type = APR_REG; - if (S_ISDIR(file->protection)) - *type = APR_DIR; - if (S_ISCHR(file->protection)) - *type = APR_CHR; - if (S_ISBLK(file->protection)) - *type = APR_BLK; - if (S_ISFIFO(file->protection)) - *type = APR_PIPE; - if (S_ISLNK(file->protection)) - *type = APR_LNK; + if (S_ISREG(perms)) + *type = APR_REG; + if (S_ISDIR(perms)) + *type = APR_DIR; + if (S_ISCHR(perms)) + *type = APR_CHR; + if (S_ISBLK(perms)) + *type = APR_BLK; + if (S_ISFIFO(perms)) + *type = APR_PIPE; + if (S_ISLNK(perms)) + *type = APR_LNK; #ifndef BEOS - if (S_ISSOCK(file->protection)) - *type = APR_SOCK; + if (S_ISSOCK(perms)) + *type = APR_SOCK; #endif - return APR_SUCCESS; - } - else { - *type = APR_REG; - return APR_ENOFILE; - } + return APR_SUCCESS; } /* ***APRDOC******************************************************** 1.8 +0 -7 apache-2.0/src/lib/apr/file_io/unix/filedup.c Index: filedup.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/filedup.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- filedup.c 1999/12/13 13:57:05 1.7 +++ filedup.c 2000/01/06 14:43:07 1.8 @@ -104,13 +104,6 @@ } (*new_file)->fname = ap_pstrdup(old_file->cntxt, old_file->fname); (*new_file)->buffered = old_file->buffered; - (*new_file)->protection = old_file->protection; - (*new_file)->user = old_file->user; - (*new_file)->group = old_file->group; - (*new_file)->size = old_file->size; - (*new_file)->atime = old_file->atime; - (*new_file)->mtime = old_file->mtime; - (*new_file)->ctime = old_file->ctime; ap_register_cleanup((*new_file)->cntxt, (void *)(*new_file), file_cleanup, ap_null_cleanup); return APR_SUCCESS; 1.7 +1 -8 apache-2.0/src/lib/apr/file_io/unix/fileio.h Index: fileio.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/fileio.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- fileio.h 1999/12/03 15:18:23 1.6 +++ fileio.h 2000/01/06 14:43:07 1.7 @@ -108,15 +108,8 @@ char * fname; int oflags; int buffered; - int stated; int eof_hit; - mode_t protection; - uid_t user; - gid_t group; - off_t size; - time_t atime; - time_t mtime; - time_t ctime; + int pipe; int timeout; }; 1.7 +25 -33 apache-2.0/src/lib/apr/file_io/unix/filestat.c Index: filestat.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- filestat.c 2000/01/04 20:46:48 1.6 +++ filestat.c 2000/01/06 14:43:08 1.7 @@ -63,20 +63,24 @@ * get the specified file's stats.. * arg 1) The file to get information about. */ -ap_status_t ap_getfileinfo(struct file_t *thefile) +ap_status_t ap_getfileinfo(ap_finfo_t *finfo, struct file_t *thefile) { struct stat info; int rv = stat(thefile->fname, &info); if (rv == 0) { - thefile->protection = info.st_mode; - thefile->user = info.st_uid; - thefile->group = info.st_gid; - thefile->size = info.st_size; - thefile->atime = info.st_atime; - thefile->mtime = info.st_mtime; - thefile->ctime = info.st_ctime; - thefile->stated = 1; + finfo->protection = info.st_mode; + finfo->user = info.st_uid; + finfo->group = info.st_gid; + finfo->size = info.st_size; + finfo->inode = info.st_ino; + ap_make_time(&finfo->atime, thefile->cntxt); + ap_set_curtime(finfo->atime, info.st_atime); + ap_make_time(&finfo->mtime, thefile->cntxt); + ap_set_curtime(finfo->mtime, info.st_mtime); + ap_make_time(&finfo->ctime, thefile->cntxt); + ap_set_curtime(finfo->ctime, info.st_ctime); + return APR_SUCCESS; } else { @@ -92,35 +96,23 @@ * arg 2) The name of the file to stat. * arg 3) the context to use to allocate the new file. */ -ap_status_t ap_stat(struct file_t **thefile, const char *fname, ap_context_t *cont) +ap_status_t ap_stat(ap_finfo_t *finfo, const char *fname, ap_context_t *cont) { struct stat info; int rv = stat(fname, &info); if (rv == 0) { - if ((*thefile) == NULL) { - /* Only allocate more space and initialize the object if it is - * NULL when passed in. - */ - (*thefile) = ap_pcalloc(cont, sizeof(struct file_t)); - if ((*thefile) == NULL) { - return APR_ENOMEM; - } - (*thefile)->cntxt = cont; - ap_register_cleanup((*thefile)->cntxt, (void *)(*thefile), - file_cleanup, ap_null_cleanup); - (*thefile)->fname = ap_pstrdup(cont, fname); - (*thefile)->filehand = NULL; - (*thefile)->filedes = -1; - } - (*thefile)->protection = info.st_mode; - (*thefile)->user = info.st_uid; - (*thefile)->group = info.st_gid; - (*thefile)->size = info.st_size; - (*thefile)->atime = info.st_atime; - (*thefile)->mtime = info.st_mtime; - (*thefile)->ctime = info.st_ctime; - (*thefile)->stated = 1; + finfo->protection = info.st_mode; + finfo->user = info.st_uid; + finfo->group = info.st_gid; + finfo->size = info.st_size; + finfo->inode = info.st_ino; + ap_make_time(&finfo->atime, cont); + ap_set_curtime(finfo->atime, info.st_atime); + ap_make_time(&finfo->mtime, cont); + ap_set_curtime(finfo->mtime, info.st_mtime); + ap_make_time(&finfo->ctime, cont); + ap_set_curtime(finfo->ctime, info.st_ctime); return APR_SUCCESS; } else { 1.31 +1 -3 apache-2.0/src/lib/apr/file_io/unix/open.c Index: open.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/open.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- open.c 2000/01/04 19:00:42 1.30 +++ open.c 2000/01/06 14:43:09 1.31 @@ -176,7 +176,7 @@ if (flag & APR_DELONCLOSE) { unlink(fname); } - (*new)->stated = 0; /* we haven't called stat for this file yet. */ + (*new)->pipe = 0; (*new)->timeout = -1; (*new)->eof_hit = 0; ap_register_cleanup((*new)->cntxt, (void *)(*new), file_cleanup, @@ -265,7 +265,6 @@ (*file)->buffered = 0; (*file)->eof_hit = 0; (*file)->timeout = -1; - (*file)->stated = 0; (*file)->filedes = *dafile; return APR_SUCCESS; } @@ -321,7 +320,6 @@ (*thefile)->cntxt = cont; (*thefile)->fname = NULL; (*thefile)->filehand = NULL; - (*thefile)->stated = 0; (*thefile)->buffered = 0; (*thefile)->eof_hit = 0; 1.10 +3 -3 apache-2.0/src/lib/apr/file_io/unix/pipe.c Index: pipe.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/pipe.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- pipe.c 1999/12/15 13:07:21 1.9 +++ pipe.c 2000/01/06 14:43:09 1.10 @@ -88,7 +88,7 @@ */ ap_status_t ap_set_pipe_timeout(struct file_t *thepipe, ap_int32_t timeout) { - if (thepipe->stated == -1) { + if (thepipe->pipe == 1) { thepipe->timeout = timeout; return APR_SUCCESS; } @@ -114,16 +114,16 @@ (*in)->cntxt = cont; (*in)->filedes = filedes[0]; (*in)->buffered = 0; + (*in)->pipe = 1; (*in)->fname = ap_pstrdup(cont, "PIPE"); - (*in)->stated = -1; (*in)->timeout = -1; (*out) = (struct file_t *)ap_palloc(cont, sizeof(struct file_t)); (*out)->cntxt = cont; (*out)->filedes = filedes[1]; (*out)->buffered = 0; + (*in)->pipe = 1; (*out)->fname = ap_pstrdup(cont, "PIPE"); - (*out)->stated = -1; (*out)->timeout = -1; pipenonblock(*in); 1.19 +0 -9 apache-2.0/src/lib/apr/file_io/unix/readwrite.c Index: readwrite.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/readwrite.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- readwrite.c 1999/12/03 15:18:23 1.18 +++ readwrite.c 2000/01/06 14:43:10 1.19 @@ -193,7 +193,6 @@ } } /* BUFFERED ?? */ - thefile->stated = 0; *nbytes = rv; if (rv == -1) { return errno; @@ -234,7 +233,6 @@ } else { *iocnt = bytes; - thefile->stated = 0; return APR_SUCCESS; } } @@ -250,7 +248,6 @@ { if (thefile->buffered) { if (fputc(ch, thefile->filehand) == ch) { - thefile->stated = 0; return APR_SUCCESS; } return errno; @@ -258,7 +255,6 @@ if (write(thefile->filedes, &ch, 1) != 1) { return errno; } - thefile->stated = 0; return APR_SUCCESS; } @@ -272,13 +268,11 @@ { if (thefile->buffered) { if (ungetc(ch, thefile->filehand) == ch) { - thefile->stated = 0; return APR_SUCCESS; } return errno; } /* Not sure what to do in this case. For now, return SUCCESS. */ - thefile->stated = 0; return APR_SUCCESS; } @@ -330,7 +324,6 @@ if (thefile->buffered) { if (fputs(str, thefile->filehand)) { - thefile->stated = 0; return APR_SUCCESS; } return errno; @@ -340,7 +333,6 @@ if (rv != len) { return errno; } - thefile->stated = 0; return APR_SUCCESS; } @@ -353,7 +345,6 @@ { if (thefile->buffered) { if (!fflush(thefile->filehand)) { - thefile->stated = 0; return APR_SUCCESS; } return errno; 1.26 +20 -9 apache-2.0/src/lib/apr/include/apr_file_io.h Index: apr_file_io.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- apr_file_io.h 2000/01/04 19:00:44 1.25 +++ apr_file_io.h 2000/01/06 14:43:19 1.26 @@ -57,6 +57,7 @@ #define APR_FILE_IO_H #include "apr_general.h" +#include "apr_time.h" #include "apr_errno.h" #if APR_HAVE_SYS_UIO_H #include <sys/uio.h> @@ -101,13 +102,28 @@ #define APR_OS_DEFAULT 0xFFF -/* should be same as whence type in lseek, POSIZ defines this as int */ +/* should be same as whence type in lseek, POSIX defines this as int */ typedef ap_int32_t ap_seek_where_t; typedef struct file_t ap_file_t; +typedef struct ap_finfo_t ap_finfo_t; typedef struct dir_t ap_dir_t; typedef struct iovec_t ap_iovec_t; typedef ap_int32_t ap_fileperms_t; +typedef uid_t ap_uid_t; +typedef gid_t ap_gid_t; +typedef ino_t ap_ino_t; + +struct ap_finfo_t { + ap_fileperms_t protection; + ap_uid_t user; + ap_gid_t group; + ap_ino_t inode; + ap_off_t size; + ap_time_t *atime; + ap_time_t *mtime; + ap_time_t *ctime; +}; /* Function definitions */ ap_status_t ap_open(ap_file_t **, const char *, ap_int32_t, ap_fileperms_t, ap_context_t *); @@ -131,8 +147,8 @@ ap_status_t ap_make_iov(ap_iovec_t **, struct iovec *, ap_context_t *); ap_status_t ap_dupfile(ap_file_t **, ap_file_t *); -ap_status_t ap_getfileinfo(ap_file_t *); -ap_status_t ap_stat(ap_file_t **thefile, const char *fname, ap_context_t *cont); +ap_status_t ap_getfileinfo(ap_finfo_t *finfo, ap_file_t *thefile); +ap_status_t ap_stat(ap_finfo_t *finfo, const char *fname, ap_context_t *cont); ap_status_t ap_seek(ap_file_t *, ap_seek_where_t, ap_off_t *); ap_status_t ap_opendir(ap_dir_t **, const char *, ap_context_t *); @@ -158,12 +174,7 @@ ap_status_t ap_dir_entry_mtime(time_t *, ap_dir_t *); ap_status_t ap_dir_entry_ftype(ap_filetype_e *, ap_dir_t *); -ap_status_t ap_get_filesize(ap_ssize_t *, ap_file_t *); -ap_status_t ap_get_filetype(ap_filetype_e *, ap_file_t *); -ap_status_t ap_get_fileperms(ap_fileperms_t *, ap_file_t *); -ap_status_t ap_get_fileatime(time_t *, ap_file_t *); -ap_status_t ap_get_filectime(time_t *, ap_file_t *); -ap_status_t ap_get_filemtime(time_t *, ap_file_t *); +ap_status_t ap_get_filetype(ap_filetype_e *, ap_fileperms_t); #ifdef __cplusplus } 1.14 +3 -3 apache-2.0/src/lib/apr/test/ab_apr.c Index: ab_apr.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/test/ab_apr.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- ab_apr.c 1999/12/17 12:32:13 1.13 +++ ab_apr.c 2000/01/06 14:43:21 1.14 @@ -858,6 +858,7 @@ static int open_postfile(char *pfile) { ap_file_t *postfd = NULL; + ap_finfo_t finfo; ap_fileperms_t mode = APR_OS_DEFAULT; ap_ssize_t length; @@ -866,9 +867,8 @@ return errno; } - /* No need to perform stat here, the ap_open will do it for us. */ - - ap_get_filesize(&postlen, postfd); + ap_getfileinfo(&finfo, postfd); + postlen = finfo.size; postdata = (char *)malloc(postlen); if (!postdata) { printf("Can\'t alloc postfile buffer\n"); 1.6 +3 -2 apache-2.0/src/lib/apr/test/testmmap.c Index: testmmap.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testmmap.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- testmmap.c 2000/01/04 19:00:49 1.5 +++ testmmap.c 2000/01/06 14:43:22 1.6 @@ -71,6 +71,7 @@ ap_context_t *context; ap_mmap_t *themmap = NULL; ap_file_t *thefile = NULL; + ap_finfo_t finfo; ap_int32_t flag = APR_READ; char *file1; ap_ssize_t filesize; @@ -98,12 +99,12 @@ } fprintf(stderr, "Getting file size..................."); - if (ap_get_filesize(&filesize, thefile) != APR_SUCCESS) { + if (ap_getfileinfo(&finfo, thefile) != APR_SUCCESS) { perror("Didn't open file"); exit(-1); } else { - fprintf(stdout, "%d bytes\n", filesize); + fprintf(stdout, "%d bytes\n", finfo.size); } fprintf(stdout,"Trying to mmap the open file........"); 1.22 +3 -3 apache-2.0/src/main/http_config.c Index: http_config.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- http_config.c 2000/01/04 19:00:52 1.21 +++ http_config.c 2000/01/06 14:43:25 1.22 @@ -1021,20 +1021,20 @@ { const char *errmsg; cmd_parms parms; - ap_file_t *finfo = NULL; + ap_finfo_t finfo; fname = ap_server_root_relative(p, fname); if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) || !(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) { - if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS) + if (ap_stat(&finfo, fname, p) != APR_SUCCESS) return; } /* don't require conf/httpd.conf if we have a -C or -c switch */ if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) && !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) { - if (ap_stat(&finfo, fname, ptemp) != APR_SUCCESS) + if (ap_stat(&finfo, fname, p) != APR_SUCCESS) return; } 1.30 +8 -10 apache-2.0/src/main/http_core.c Index: http_core.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- http_core.c 1999/12/21 07:54:08 1.29 +++ http_core.c 2000/01/06 14:43:26 1.30 @@ -2491,7 +2491,7 @@ if (r->method_number == M_PUT) { return METHOD_NOT_ALLOWED; } - if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) { + if (r->finfo.protection == 0 || (r->path_info && *r->path_info)) { ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r, "File does not exist: %s",r->path_info ? ap_pstrcat(r->pool, r->filename, r->path_info, NULL) @@ -2507,25 +2507,23 @@ "file permissions deny server access: %s", r->filename); return FORBIDDEN; } - ap_make_time(&temp, r->pool); - ap_set_curtime(temp, r->finfo.st_mtime); - ap_update_mtime(r, temp); + ap_update_mtime(r, r->finfo.mtime); ap_set_last_modified(r); ap_set_etag(r); ap_table_setn(r->headers_out, "Accept-Ranges", "bytes"); if (((errstatus = ap_meets_conditions(r)) != OK) - || (errstatus = ap_set_content_length(r, r->finfo.st_size))) { + || (errstatus = ap_set_content_length(r, r->finfo.size))) { ap_close(fd); return errstatus; } #ifdef USE_MMAP_FILES - if ((r->finfo.st_size >= MMAP_THRESHOLD) - && (r->finfo.st_size < MMAP_LIMIT) + if ((r->finfo.size >= MMAP_THRESHOLD) + && (r->finfo.size < MMAP_LIMIT) && (!r->header_only || (d->content_md5 & 1))) { /* we need to protect ourselves in case we die while we've got the * file mmapped */ - if (ap_mmap_create(&mm, fd, 0, r->finfo.st_size, r->pool) != APR_SUCCESS){ + if (ap_mmap_create(&mm, fd, 0, r->finfo.size, r->pool) != APR_SUCCESS){ ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r, "default_handler: mmap failed: %s", r->filename); mm = NULL; @@ -2584,7 +2582,7 @@ AP_MD5_CTX context; ap_MD5Init(&context); - ap_MD5Update(&context, addr, (unsigned int)r->finfo.st_size); + ap_MD5Update(&context, addr, (unsigned int)r->finfo.size); ap_table_setn(r->headers_out, "Content-MD5", ap_md5contextTo64(r->pool, &context)); } @@ -2594,7 +2592,7 @@ if (!r->header_only) { if (!rangestatus) { - ap_send_mmap(mm, r, 0, r->finfo.st_size); + ap_send_mmap(mm, r, 0, r->finfo.size); } else { ap_off_t offset; 1.24 +2 -1 apache-2.0/src/main/http_log.c Index: http_log.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_log.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- http_log.c 2000/01/04 19:00:53 1.23 +++ http_log.c 2000/01/06 14:43:26 1.24 @@ -514,6 +514,7 @@ void ap_log_pid(ap_context_t *p, const char *fname) { ap_file_t *pid_file = NULL; + ap_finfo_t finfo; static pid_t saved_pid = -1; pid_t mypid; @@ -522,7 +523,7 @@ fname = ap_server_root_relative(p, fname); mypid = getpid(); - if (mypid != saved_pid && ap_stat(&pid_file, fname, p) == 0) { + if (mypid != saved_pid && ap_stat(&finfo, fname, p) == APR_SUCCESS) { /* WINCH and HUP call this on each restart. * Only warn on first time through for this pid. * 1.45 +3 -3 apache-2.0/src/main/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- http_protocol.c 1999/12/21 16:21:44 1.44 +++ http_protocol.c 2000/01/06 14:43:27 1.45 @@ -537,11 +537,11 @@ ap_timediff(r->request_time, r->mtime, &diff); weak = ((diff > 1) && !force_weak) ? "" : "W/"; - if (r->finfo.st_mode != 0) { + if (r->finfo.protection != 0) { etag = ap_psprintf(r->pool, "%s\"%lx-%lx-%lx\"", weak, - (unsigned long) r->finfo.st_ino, - (unsigned long) r->finfo.st_size, + (unsigned long) r->finfo.inode, + (unsigned long) r->finfo.size, (unsigned long) r->mtime); } else { 1.12 +16 -16 apache-2.0/src/main/http_request.c Index: http_request.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_request.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- http_request.c 1999/12/20 16:38:35 1.11 +++ http_request.c 2000/01/06 14:43:27 1.12 @@ -116,10 +116,10 @@ static int check_safe_file(request_rec *r) { - if (r->finfo.st_mode == 0 /* doesn't exist */ - || S_ISDIR(r->finfo.st_mode) - || S_ISREG(r->finfo.st_mode) - || S_ISLNK(r->finfo.st_mode)) { + if (r->finfo.protection == 0 /* doesn't exist */ + || S_ISDIR(r->finfo.protection) + || S_ISREG(r->finfo.protection) + || S_ISLNK(r->finfo.protection)) { return OK; } ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, @@ -200,7 +200,7 @@ char bStripSlash=1; #endif - if (r->finfo.st_mode) { + if (r->finfo.protection) { /* assume path_info already set */ return OK; } @@ -260,20 +260,20 @@ } else { errno = 0; - rv = stat(path, &r->finfo); + rv = ap_stat(&r->finfo, path, r->pool); } if (cp != end) *cp = '/'; - if (!rv) { + if (rv != APR_SUCCESS) { /* * Aha! Found something. If it was a directory, we will search * contents of that directory for a multi_match, so the PATH_INFO * argument starts with the component after that. */ - if (S_ISDIR(r->finfo.st_mode) && last_cp) { - r->finfo.st_mode = 0; /* No such file... */ + if (S_ISDIR(r->finfo.protection) && last_cp) { + r->finfo.protection = 0; /* No such file... */ cp = last_cp; } @@ -284,7 +284,7 @@ /* must set this to zero, some stat()s may have corrupted it * even if they returned an error. */ - r->finfo.st_mode = 0; + r->finfo.protection = 0; #if defined(ENOENT) && defined(ENOTDIR) if (errno == ENOENT || errno == ENOTDIR) { @@ -354,7 +354,7 @@ if (r->filename == NULL) { r->filename = ap_pstrdup(r->pool, r->uri); - r->finfo.st_mode = 0; /* Not really a file... */ + r->finfo.protection = 0; /* Not really a file... */ r->per_dir_config = per_dir_defaults; return OK; @@ -436,7 +436,7 @@ if (test_filename[test_filename_len - 1] == '/') --num_dirs; - if (S_ISDIR(r->finfo.st_mode)) + if (S_ISDIR(r->finfo.protection)) ++num_dirs; /* @@ -571,7 +571,7 @@ * S_ISDIR test. But if you accessed /symlink/index.html, for example, * you would *not* get the 403. */ - if (!S_ISDIR(r->finfo.st_mode) + if (!S_ISDIR(r->finfo.protection) && (res = check_symlinks(r->filename, ap_allow_options(r)))) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "Symbolic link not allowed: %s", r->filename); @@ -860,8 +860,8 @@ rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file); ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */ - if (stat(rnew->filename, &rnew->finfo) < 0) { - rnew->finfo.st_mode = 0; + if (ap_stat(&rnew->finfo, rnew->filename, rnew->pool) != APR_SUCCESS) { + rnew->finfo.protection = 0; } if ((res = check_safe_file(rnew))) { @@ -875,7 +875,7 @@ * no matter what, if it's a subdirectory, we need to re-run * directory_walk */ - if (S_ISDIR(rnew->finfo.st_mode)) { + if (S_ISDIR(rnew->finfo.protection)) { res = directory_walk(rnew); if (!res) { res = file_walk(rnew); 1.24 +3 -1 apache-2.0/src/main/util.c Index: util.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/util.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- util.c 2000/01/04 19:00:53 1.23 +++ util.c 2000/01/06 14:43:28 1.24 @@ -766,6 +766,7 @@ { configfile_t *new_cfg; ap_file_t *file = NULL; + ap_finfo_t finfo; ap_status_t stat; ap_filetype_e type; @@ -791,7 +792,8 @@ if (stat != APR_SUCCESS) return stat; - stat = ap_get_filetype(&type, file); + ap_getfileinfo(&finfo, file); + stat = ap_get_filetype(&type, finfo.protection); if (stat != APR_SUCCESS) return stat; 1.5 +1 -1 apache-2.0/src/modules/standard/mod_actions.c Index: mod_actions.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_actions.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- mod_actions.c 1999/10/20 12:50:07 1.4 +++ mod_actions.c 2000/01/06 14:43:37 1.5 @@ -187,7 +187,7 @@ if ((t = ap_table_get(conf->action_types, action ? action : ap_default_type(r)))) { script = t; - if (r->finfo.st_mode == 0) { + if (r->finfo.protection == 0) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "File does not exist: %s", r->filename); return NOT_FOUND; 1.14 +1 -1 apache-2.0/src/modules/standard/mod_asis.c Index: mod_asis.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_asis.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- mod_asis.c 2000/01/04 19:01:00 1.13 +++ mod_asis.c 2000/01/06 14:43:37 1.14 @@ -72,7 +72,7 @@ r->allowed |= (1 << M_GET); if (r->method_number != M_GET) return DECLINED; - if (r->finfo.st_mode == 0) { + if (r->finfo.protection == 0) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "File does not exist: %s", r->filename); return NOT_FOUND; 1.16 +6 -6 apache-2.0/src/modules/standard/mod_autoindex.c Index: mod_autoindex.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_autoindex.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- mod_autoindex.c 2000/01/04 19:01:01 1.15 +++ mod_autoindex.c 2000/01/06 14:43:38 1.16 @@ -953,7 +953,7 @@ && (rr = ap_sub_req_lookup_uri(header_fname, r)) && (rr->status == HTTP_OK) && (rr->filename != NULL) - && S_ISREG(rr->finfo.st_mode)) { + && S_ISREG(rr->finfo.protection)) { /* * Check for the two specific cases we allow: text/html and * text/anything-else. The former is allowed to be processed for @@ -1036,7 +1036,7 @@ && (rr = ap_sub_req_lookup_uri(readme_fname, r)) && (rr->status == HTTP_OK) && (rr->filename != NULL) - && S_ISREG(rr->finfo.st_mode)) { + && S_ISREG(rr->finfo.protection)) { /* * Check for the two specific cases we allow: text/html and * text/anything-else. The former is allowed to be processed for @@ -1161,9 +1161,9 @@ if (autoindex_opts & FANCY_INDEXING) { request_rec *rr = ap_sub_req_lookup_file(name, r); - if (rr->finfo.st_mode != 0) { - p->lm = rr->finfo.st_mtime; - if (S_ISDIR(rr->finfo.st_mode)) { + if (rr->finfo.protection != 0) { + ap_get_curtime(rr->finfo.mtime, (ap_int64_t *)&p->lm); + if (S_ISDIR(rr->finfo.protection)) { if (!(p->icon = find_icon(d, rr, 1))) { p->icon = find_default_icon(d, "^^DIRECTORY^^"); } @@ -1176,7 +1176,7 @@ else { p->icon = find_icon(d, rr, 0); p->alt = find_alt(d, rr, 0); - p->size = rr->finfo.st_size; + p->size = rr->finfo.size; } } 1.23 +2 -2 apache-2.0/src/modules/standard/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_cgi.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- mod_cgi.c 2000/01/04 19:01:01 1.22 +++ mod_cgi.c 2000/01/06 14:43:38 1.23 @@ -492,11 +492,11 @@ } } #else - if (r->finfo.st_mode == 0) + if (r->finfo.protection == 0) return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO, "script not found or unable to stat"); #endif - if (S_ISDIR(r->finfo.st_mode)) + if (S_ISDIR(r->finfo.protection)) return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO, "attempt to invoke directory as script"); 1.4 +1 -1 apache-2.0/src/modules/standard/mod_dir.c Index: mod_dir.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_dir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mod_dir.c 1999/08/31 05:33:47 1.3 +++ mod_dir.c 2000/01/06 14:43:39 1.4 @@ -161,7 +161,7 @@ char *name_ptr = *names_ptr; request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r); - if (rr->status == HTTP_OK && S_ISREG(rr->finfo.st_mode)) { + if (rr->status == HTTP_OK && S_ISREG(rr->finfo.protection)) { char *new_uri = ap_escape_uri(r->pool, rr->uri); if (rr->args != NULL) 1.15 +12 -20 apache-2.0/src/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_include.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- mod_include.c 2000/01/04 19:01:02 1.14 +++ mod_include.c 2000/01/06 14:43:39 1.15 @@ -127,23 +127,21 @@ ap_time_t *date = r->request_time; ap_time_t *mtime = NULL; - ap_make_time(&mtime, r->pool); - ap_set_curtime(mtime, r->finfo.st_mtime); ap_table_setn(e, "DATE_LOCAL", ap_ht_time(r->pool, date, timefmt, 0)); ap_table_setn(e, "DATE_GMT", ap_ht_time(r->pool, date, timefmt, 1)); ap_table_setn(e, "LAST_MODIFIED", - ap_ht_time(r->pool, mtime, timefmt, 0)); + ap_ht_time(r->pool, r->finfo.mtime, timefmt, 0)); ap_table_setn(e, "DOCUMENT_URI", r->uri); ap_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info); #ifndef WIN32 - pw = getpwuid(r->finfo.st_uid); + pw = getpwuid(r->finfo.user); if (pw) { ap_table_setn(e, "USER_NAME", ap_pstrdup(r->pool, pw->pw_name)); } else { ap_table_setn(e, "USER_NAME", ap_psprintf(r->pool, "user#%lu", - (unsigned long) r->finfo.st_uid)); + (unsigned long) r->finfo.user)); } #endif /* ndef WIN32 */ @@ -596,7 +594,7 @@ if ((rr->path_info && rr->path_info[0]) || rr->args) { return -1; } - if (rr->finfo.st_mode == 0) { + if (rr->finfo.protection == 0) { return -1; } @@ -1026,16 +1024,12 @@ } else if (!strcmp(tag, "timefmt")) { ap_time_t *date = r->request_time; - ap_time_t *mtime = NULL; - ap_make_time(&mtime, r->pool); - ap_set_curtime(mtime, r->finfo.st_mtime); - parse_string(r, tag_val, tf, MAX_STRING_LEN, 0); ap_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, tf, 0)); ap_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, tf, 1)); ap_table_setn(env, "LAST_MODIFIED", - ap_ht_time(r->pool, mtime, tf, 0)); + ap_ht_time(r->pool, r->finfo.mtime, tf, 0)); } else if (!strcmp(tag, "sizefmt")) { parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); @@ -1078,7 +1072,7 @@ ap_getparents(tag_val); /* get rid of any nasties */ rr = ap_sub_req_lookup_file(tag_val, r); - if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { + if (rr->status == HTTP_OK && rr->finfo.protection != 0) { to_send = rr->filename; if (stat(to_send, finfo)) { error_fmt = "unable to get information about \"%s\" " @@ -1104,7 +1098,7 @@ else if (!strcmp(tag, "virtual")) { rr = ap_sub_req_lookup_uri(tag_val, r); - if (rr->status == HTTP_OK && rr->finfo.st_mode != 0) { + if (rr->status == HTTP_OK && rr->finfo.protection != 0) { memcpy((char *) finfo, (const char *) &rr->finfo, sizeof(struct stat)); ap_destroy_sub_req(rr); @@ -2361,7 +2355,7 @@ if (r->method_number != M_GET) { return DECLINED; } - if (r->finfo.st_mode == 0) { + if (r->finfo.protection == 0) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r, "File does not exist: %s", (r->path_info @@ -2381,12 +2375,10 @@ if ((*state == xbithack_full) #if !defined(OS2) && !defined(WIN32) /* OS/2 dosen't support Groups. */ - && (r->finfo.st_mode & S_IXGRP) + && (r->finfo.protection & S_IXGRP) #endif ) { - ap_make_time(&mtime, r->pool); - ap_set_curtime(mtime, r->finfo.st_mtime); - ap_update_mtime(r, mtime); + ap_update_mtime(r, r->finfo.mtime); ap_set_last_modified(r); } if ((errstatus = ap_meets_conditions(r)) != OK) { @@ -2411,7 +2403,7 @@ */ r->subprocess_env = parent->subprocess_env; ap_pool_join(parent->pool, r->pool); - r->finfo.st_mtime = parent->finfo.st_mtime; + r->finfo.mtime = parent->finfo.mtime; } else { /* we're not a nested include, so we create an initial @@ -2455,7 +2447,7 @@ #else enum xbithack *state; - if (!(r->finfo.st_mode & S_IXUSR)) { + if (!(r->finfo.protection & S_IXUSR)) { return DECLINED; } 1.6 +1 -1 apache-2.0/src/modules/standard/mod_mime.c Index: mod_mime.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- mod_mime.c 1999/11/02 15:15:08 1.5 +++ mod_mime.c 2000/01/06 14:43:40 1.6 @@ -286,7 +286,7 @@ const char *orighandler = r->handler; const char *type; - if (S_ISDIR(r->finfo.st_mode)) { + if (S_ISDIR(r->finfo.protection)) { r->content_type = DIR_MAGIC_TYPE; return OK; } 1.15 +3 -6 apache-2.0/src/modules/standard/mod_negotiation.c Index: mod_negotiation.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_negotiation.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- mod_negotiation.c 2000/01/04 19:01:04 1.14 +++ mod_negotiation.c 2000/01/06 14:43:40 1.15 @@ -284,15 +284,12 @@ static void set_vlist_validator(request_rec *r, request_rec *vlistr) { - ap_time_t *temp; /* Calculating the variant list validator is similar to * calculating an etag for the source of the variant list * information, so we use ap_make_etag(). Note that this * validator can be 'weak' in extreme case. */ - ap_make_time(&temp, vlistr->pool); - ap_set_curtime(temp, vlistr->finfo.st_mtime); - ap_update_mtime(vlistr, temp); + ap_update_mtime(vlistr, vlistr->finfo.mtime); r->vlist_validator = ap_make_etag(vlistr, 0); /* ap_set_etag will later take r->vlist_validator into account @@ -2581,7 +2578,7 @@ int res; int j; - if (r->finfo.st_mode != 0 || !(ap_allow_options(r) & OPT_MULTI)) { + if (r->finfo.protection != 0 || !(ap_allow_options(r) & OPT_MULTI)) { return DECLINED; } @@ -2624,7 +2621,7 @@ /* BLECH --- don't multi-resolve non-ordinary files */ - if (!S_ISREG(sub_req->finfo.st_mode)) { + if (!S_ISREG(sub_req->finfo.protection)) { res = NOT_FOUND; goto return_from_multi; } 1.4 +3 -2 apache-2.0/src/modules/standard/mod_userdir.c Index: mod_userdir.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_userdir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mod_userdir.c 1999/08/31 05:34:04 1.3 +++ mod_userdir.c 2000/01/06 14:43:41 1.4 @@ -199,7 +199,7 @@ const char *w, *dname; char *redirect; char *x = NULL; - struct stat statbuf; + ap_finfo_t statbuf; /* * If the URI doesn't match our basic pattern, we've nothing to do with @@ -313,7 +313,8 @@ * anyway, in the hope that some handler might handle it. This can be * used, for example, to run a CGI script for the user. */ - if (filename && (!*userdirs || stat(filename, &statbuf) != -1)) { + if (filename && (!*userdirs || + ap_stat(&statbuf, filename, r->pool) == APR_SUCCESS)) { r->filename = ap_pstrcat(r->pool, filename, dname, NULL); /* when statbuf contains info on r->filename we can save a syscall * by copying it to r->finfo