You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by David Reid <ab...@dial.pipex.com> on 1999/11/02 23:23:21 UTC

{PATCH} ap_put_statinfo

Whilst looking into the ap_mmap stuff it seemed like a good idea to add the
following function.  Rather than just committing I'm flagging it here as it
might not be portable etc etc

Anyway, I'll commit it later this week unless there's a reason not to.

For an idea of where this might be useful can I point you at default_handler
in http_core.c for the mmap sections.

david

--- /boot/home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h Sat Oct 16
12:46:13 1999
+++ include/apr_file_io.h Tue Nov  2 21:27:27 1999
@@ -58,6 +58,7 @@

 #include "apr_general.h"
 #include "apr_errno.h"
+#include <sys/stat.h>
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
@@ -162,6 +163,8 @@
 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_put_statinfo(ap_file_t *, struct stat *);

 #ifdef __cplusplus
 }
diff -ru /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c
unix/filestat.c
--- /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c Tue Oct  5
02:15:19 1999
+++ unix/filestat.c Tue Nov  2 21:27:14 1999
@@ -84,3 +84,19 @@
     }
 }

+ap_status_t ap_put_statinfo(struct file_t *thefile, struct stat *theinfo)
+{
+    if (thefile == NULL)
+        return APR_EBADF;
+
+    thefile->protection = theinfo->st_mode;
+    thefile->user = theinfo->st_uid;
+    thefile->group = theinfo->st_gid;
+    thefile->size = theinfo->st_size;
+    thefile->atime = theinfo->st_atime;
+    thefile->mtime = theinfo->st_mtime;
+    thefile->ctime = theinfo->st_ctime;
+    thefile->stated = 1;
+    return APR_SUCCESS;
+}
+



Re: {PATCH} ap_put_statinfo

Posted by Manoj Kasichainula <ma...@io.com>.
On Thu, Nov 04, 1999 at 10:59:49AM -0000, David Reid wrote:
> OK.
> 
> From: Manoj Kasichainula <ma...@io.com>
> > Why is not passing a size cleaner? I think any APR mmap should support
> > both the size and offset arguments, unless there's a platform that
> > can't do this.

Uhhh, that's not what you did. :)

What I was saying is that we only need one APR mmap function:
apr_mmap_create or something, which would take both a size and offset
parameter. Both parameters are useful to Apache, if not now, then
later, for sending byte ranges efficiently. And the simplified
versions of these functions that are in APR now simply aren't
necessary, because they can be done using combinations of other APR
calls.

ap_mmap_size_create => manojs_apr_mmap with offset = 0
ap_mmap_create => manojs_apr_mmap with offset = 0, size = size of the
file.

This way, you get less complexity; a coder only has a single mmap
function to worry about. Also, you don't have to pollute the mmap.c
file with more knowledge about files (i.e. how to call stat()), so you
get simpler functions which are easier to maintain and are more likely
to be sharable.

Did I convince you yet? If not, please at least have the current
functions call a more generic mmap with size + offset, so that there
isn't so much duplicated code.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/

Re: {PATCH} ap_put_statinfo

Posted by David Reid <ab...@dial.pipex.com>.
OK.

----- Original Message ----- 
From: Manoj Kasichainula <ma...@io.com>
To: <ne...@apache.org>
Sent: 04 November 1999 07:03
Subject: Re: {PATCH} ap_put_statinfo


> On Wed, Nov 03, 1999 at 12:19:47PM -0000, David Reid wrote:
> > This seemed to be cleaner than trying to create a new ap_mmap_t
> > creation function that only took a size
> 
> Why is not passing a size cleaner? I think any APR mmap should support
> both the size and offset arguments, unless there's a platform that
> can't do this.
> 
> Doing this seems cleaner to me than forcing down a pile of stat info
> down an ap_file_t's throat.
> 
> -- 
> Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/


Re: {PATCH} ap_put_statinfo

Posted by Manoj Kasichainula <ma...@io.com>.
On Wed, Nov 03, 1999 at 12:19:47PM -0000, David Reid wrote:
> This seemed to be cleaner than trying to create a new ap_mmap_t
> creation function that only took a size

Why is not passing a size cleaner? I think any APR mmap should support
both the size and offset arguments, unless there's a platform that
can't do this.

Doing this seems cleaner to me than forcing down a pile of stat info
down an ap_file_t's throat.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/

Re: {PATCH} ap_put_statinfo

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
There has been some talk of having APR do stat chaching.  Not sure if this
will help or not, because I am too lazy to read all of these messages
today.  I will post a quick design for a stat chache (not being
implemented until much later, like APR2.0).  I will also read this message
all the way through when I have recovered from the honeymoon a bit more.

Ryan

On Wed, 3 Nov 1999, David Reid wrote:

> What I'm trying to avoid is having the ap_mmap function re-stat the file.
> As Bill pointed out this would be a big loss...
> 
> The file in the default_handler has already been statted so when the
> ap_file_t is created I propose using the ap_put_statinfo to simply add the
> stat information into the ap_file_t, then when I create the ap_mmap_t via
> the ap_file_t no further stat will be required.  This seemed to be cleaner
> than trying to create a new ap_mmap_t creation function that only took a
> size, or to get involved in to stat or not to stat flags in the function
> calls.
> 
> To show what I have in mind here is a diff of the files in src/main that are
> affected.  I've tested this on FreeBSD 3.3 and BeOS and it works OK.  I'm
> sure it can be improved on though :-)
> 
> This needs some functions that are in mmap and I'll commit them later today.
> 
> david
> 
> 
> diff -u /boot/home/cvs/apache-2.0/src/main/http_core.c ./http_core.c
> --- /boot/home/cvs/apache-2.0/src/main/http_core.c Thu Oct 21 19:57:41 1999
> +++ ./http_core.c Wed Nov  3 10:41:45 1999
> @@ -71,7 +71,7 @@
>  #include "http_connection.h"
> 
>  #ifdef USE_MMAP_FILES
> -#include <sys/mman.h>
> +#include "apr_mmap.h"
> 
>  /* mmap support for static files based on ideas from John Heidemann's
>   * patch against 1.0.5.  See
> @@ -2442,25 +2442,6 @@
> 
>  static int do_nothing(request_rec *r) { return OK; }
> 
> -#ifdef USE_MMAP_FILES
> -struct mmap_rec {
> -    void *mm;
> -    size_t length;
> -};
> -
> -static ap_status_t mmap_cleanup(void *mmv)
> -{
> -    struct mmap_rec *mmd = mmv;
> -
> -    if (munmap(mmd->mm, mmd->length) == -1) {
> -        ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL,
> -                     "Failed to munmap memory of length %ld at 0x%lx",
> -                     (long) mmd->length, (long) mmd->mm);
> -    }
> -    return APR_SUCCESS;
> -}
> -#endif
> -
>  /*
>   * Default handler for MIME types without other handlers.  Only GET
>   * and OPTIONS at this point... anyone who wants to write a generic
> @@ -2478,7 +2459,7 @@
>      int fd_os;
>      ap_status_t status;
>  #ifdef USE_MMAP_FILES
> -    caddr_t mm;
> +    ap_mmap_t *mm = NULL;
>  #endif
>  #ifdef CHARSET_EBCDIC
>      /* To make serving of "raw ASCII text" files easy (they serve faster
> @@ -2528,8 +2509,10 @@
>         "file permissions deny server access: %s", r->filename);
>          return FORBIDDEN;
>      }
> -    else
> -       ap_get_os_file(&fd_os, fd);
> +    else {
> +        ap_put_statinfo(fd, &r->finfo);
> +        ap_get_os_file(&fd_os, fd);
> + }
> 
>      ap_update_mtime(r, r->finfo.st_mtime);
>      ap_set_last_modified(r);
> @@ -2543,22 +2526,20 @@
> 
>  #ifdef USE_MMAP_FILES
>      if ((r->finfo.st_size >= MMAP_THRESHOLD)
> - && (r->finfo.st_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 */
> - mm = mmap(NULL, r->finfo.st_size, PROT_READ, MAP_PRIVATE,
> -    fd_os, 0);
> - if (mm == (caddr_t)-1) {
> -     ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
> +     && (r->finfo.st_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_open_create(&mm, fd, r->pool)) != APR_SUCCESS)
> 
> +         ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
>      "default_handler: mmap failed: %s", r->filename);
> - }
> +     }
>      }
>      else {
> - mm = (caddr_t)-1;
> +     mm = NULL;
>      }
> 
> -    if (mm == (caddr_t)-1) {
> +    if (mm == NULL) {
>  #endif
> 
>  #ifdef CHARSET_EBCDIC
> @@ -2600,18 +2581,13 @@
>  #ifdef USE_MMAP_FILES
>      }
>      else {
> - struct mmap_rec *mmd;
> -
> - mmd = ap_palloc(r->pool, sizeof(*mmd));
> - mmd->mm = mm;
> - mmd->length = r->finfo.st_size;
> - ap_register_cleanup(r->pool, (void *)mmd, mmap_cleanup, mmap_cleanup);
> -
> +    char *addr;
> +    ap_mmap_offset((void**)&addr, mm, 0);
>   if (d->content_md5 & 1) {
>       AP_MD5_CTX context;
> 
>       ap_MD5Init(&context);
> -     ap_MD5Update(&context, (void *)mm, (unsigned int)r->finfo.st_size);
> +     ap_MD5Update(&context, addr, (unsigned int)r->finfo.st_size);
>       ap_table_setn(r->headers_out, "Content-MD5",
>       ap_md5contextTo64(r->pool, &context));
>   }
> diff -u /boot/home/cvs/apache-2.0/src/main/http_protocol.c ./http_protocol.c
> --- /boot/home/cvs/apache-2.0/src/main/http_protocol.c Tue Nov  2 11:22:47
> 1999
> +++ ./http_protocol.c Wed Nov  3 10:27:31 1999
> @@ -2156,15 +2156,17 @@
>  #define MMAP_SEGMENT_SIZE       32768
>  #endif
> 
> +#ifdef USE_MMAP_FILES
>  /* send data from an in-memory buffer */
> -API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset,
> +API_EXPORT(size_t) ap_send_mmap(ap_mmap_t *mm, request_rec *r, size_t
> offset,
>                               size_t length)
>  {
>      size_t total_bytes_sent = 0;
>      int n;
>      ap_ssize_t w;
>      ap_status_t rv;
> -
> +    char *base;
> +
>      if (length == 0)
>          return 0;
> 
> @@ -2179,7 +2181,8 @@
>          }
> 
>          while (n && !r->connection->aborted) {
> -            rv = ap_bwrite(r->connection->client, (char *) mm + offset, n,
> &w);
> +            ap_mmap_offset((void*)&base, mm, offset);
> +            rv = ap_bwrite(r->connection->client, base, n, &w);
>              if (w > 0) {
>                  total_bytes_sent += w;
>                  n -= w;
> @@ -2204,6 +2207,7 @@
>      SET_BYTES_SENT(r);
>      return total_bytes_sent;
>  }
> +#endif /* USE_MMAP_FILES */
> 
>  API_EXPORT(int) ap_rputc(int c, request_rec *r)
>  {
> 
> 
> ----- Original Message -----
> From: Manoj Kasichainula <ma...@io.com>
> To: <ne...@apache.org>
> Sent: 03 November 1999 08:14
> Subject: Re: {PATCH} ap_put_statinfo
> 
> 
> > On Tue, Nov 02, 1999 at 10:23:21PM -0000, David Reid wrote:
> > > Whilst looking into the ap_mmap stuff it seemed like a good idea to add
> the
> > > following function.  Rather than just committing I'm flagging it here as
> it
> > > might not be portable etc etc
> >
> > If an ap_put_statinfo function is useful, I think that suggests that
> > stat information should be kept in a new and different APR object from
> > ap_file_t.
> >
> > > For an idea of where this might be useful can I point you at
> default_handler
> > > in http_core.c for the mmap sections.
> >
> > I don't see it. Maybe I will after some sleep, but in the mean time,
> > can you point it out? :)
> >
> > --
> > Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	


Re: {PATCH} ap_put_statinfo

Posted by David Reid <ab...@dial.pipex.com>.
What I'm trying to avoid is having the ap_mmap function re-stat the file.
As Bill pointed out this would be a big loss...

The file in the default_handler has already been statted so when the
ap_file_t is created I propose using the ap_put_statinfo to simply add the
stat information into the ap_file_t, then when I create the ap_mmap_t via
the ap_file_t no further stat will be required.  This seemed to be cleaner
than trying to create a new ap_mmap_t creation function that only took a
size, or to get involved in to stat or not to stat flags in the function
calls.

To show what I have in mind here is a diff of the files in src/main that are
affected.  I've tested this on FreeBSD 3.3 and BeOS and it works OK.  I'm
sure it can be improved on though :-)

This needs some functions that are in mmap and I'll commit them later today.

david


diff -u /boot/home/cvs/apache-2.0/src/main/http_core.c ./http_core.c
--- /boot/home/cvs/apache-2.0/src/main/http_core.c Thu Oct 21 19:57:41 1999
+++ ./http_core.c Wed Nov  3 10:41:45 1999
@@ -71,7 +71,7 @@
 #include "http_connection.h"

 #ifdef USE_MMAP_FILES
-#include <sys/mman.h>
+#include "apr_mmap.h"

 /* mmap support for static files based on ideas from John Heidemann's
  * patch against 1.0.5.  See
@@ -2442,25 +2442,6 @@

 static int do_nothing(request_rec *r) { return OK; }

-#ifdef USE_MMAP_FILES
-struct mmap_rec {
-    void *mm;
-    size_t length;
-};
-
-static ap_status_t mmap_cleanup(void *mmv)
-{
-    struct mmap_rec *mmd = mmv;
-
-    if (munmap(mmd->mm, mmd->length) == -1) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, errno, NULL,
-                     "Failed to munmap memory of length %ld at 0x%lx",
-                     (long) mmd->length, (long) mmd->mm);
-    }
-    return APR_SUCCESS;
-}
-#endif
-
 /*
  * Default handler for MIME types without other handlers.  Only GET
  * and OPTIONS at this point... anyone who wants to write a generic
@@ -2478,7 +2459,7 @@
     int fd_os;
     ap_status_t status;
 #ifdef USE_MMAP_FILES
-    caddr_t mm;
+    ap_mmap_t *mm = NULL;
 #endif
 #ifdef CHARSET_EBCDIC
     /* To make serving of "raw ASCII text" files easy (they serve faster
@@ -2528,8 +2509,10 @@
        "file permissions deny server access: %s", r->filename);
         return FORBIDDEN;
     }
-    else
-       ap_get_os_file(&fd_os, fd);
+    else {
+        ap_put_statinfo(fd, &r->finfo);
+        ap_get_os_file(&fd_os, fd);
+ }

     ap_update_mtime(r, r->finfo.st_mtime);
     ap_set_last_modified(r);
@@ -2543,22 +2526,20 @@

 #ifdef USE_MMAP_FILES
     if ((r->finfo.st_size >= MMAP_THRESHOLD)
- && (r->finfo.st_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 */
- mm = mmap(NULL, r->finfo.st_size, PROT_READ, MAP_PRIVATE,
-    fd_os, 0);
- if (mm == (caddr_t)-1) {
-     ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
+     && (r->finfo.st_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_open_create(&mm, fd, r->pool)) != APR_SUCCESS)

+         ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
     "default_handler: mmap failed: %s", r->filename);
- }
+     }
     }
     else {
- mm = (caddr_t)-1;
+     mm = NULL;
     }

-    if (mm == (caddr_t)-1) {
+    if (mm == NULL) {
 #endif

 #ifdef CHARSET_EBCDIC
@@ -2600,18 +2581,13 @@
 #ifdef USE_MMAP_FILES
     }
     else {
- struct mmap_rec *mmd;
-
- mmd = ap_palloc(r->pool, sizeof(*mmd));
- mmd->mm = mm;
- mmd->length = r->finfo.st_size;
- ap_register_cleanup(r->pool, (void *)mmd, mmap_cleanup, mmap_cleanup);
-
+    char *addr;
+    ap_mmap_offset((void**)&addr, mm, 0);
  if (d->content_md5 & 1) {
      AP_MD5_CTX context;

      ap_MD5Init(&context);
-     ap_MD5Update(&context, (void *)mm, (unsigned int)r->finfo.st_size);
+     ap_MD5Update(&context, addr, (unsigned int)r->finfo.st_size);
      ap_table_setn(r->headers_out, "Content-MD5",
      ap_md5contextTo64(r->pool, &context));
  }
diff -u /boot/home/cvs/apache-2.0/src/main/http_protocol.c ./http_protocol.c
--- /boot/home/cvs/apache-2.0/src/main/http_protocol.c Tue Nov  2 11:22:47
1999
+++ ./http_protocol.c Wed Nov  3 10:27:31 1999
@@ -2156,15 +2156,17 @@
 #define MMAP_SEGMENT_SIZE       32768
 #endif

+#ifdef USE_MMAP_FILES
 /* send data from an in-memory buffer */
-API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset,
+API_EXPORT(size_t) ap_send_mmap(ap_mmap_t *mm, request_rec *r, size_t
offset,
                              size_t length)
 {
     size_t total_bytes_sent = 0;
     int n;
     ap_ssize_t w;
     ap_status_t rv;
-
+    char *base;
+
     if (length == 0)
         return 0;

@@ -2179,7 +2181,8 @@
         }

         while (n && !r->connection->aborted) {
-            rv = ap_bwrite(r->connection->client, (char *) mm + offset, n,
&w);
+            ap_mmap_offset((void*)&base, mm, offset);
+            rv = ap_bwrite(r->connection->client, base, n, &w);
             if (w > 0) {
                 total_bytes_sent += w;
                 n -= w;
@@ -2204,6 +2207,7 @@
     SET_BYTES_SENT(r);
     return total_bytes_sent;
 }
+#endif /* USE_MMAP_FILES */

 API_EXPORT(int) ap_rputc(int c, request_rec *r)
 {


----- Original Message -----
From: Manoj Kasichainula <ma...@io.com>
To: <ne...@apache.org>
Sent: 03 November 1999 08:14
Subject: Re: {PATCH} ap_put_statinfo


> On Tue, Nov 02, 1999 at 10:23:21PM -0000, David Reid wrote:
> > Whilst looking into the ap_mmap stuff it seemed like a good idea to add
the
> > following function.  Rather than just committing I'm flagging it here as
it
> > might not be portable etc etc
>
> If an ap_put_statinfo function is useful, I think that suggests that
> stat information should be kept in a new and different APR object from
> ap_file_t.
>
> > For an idea of where this might be useful can I point you at
default_handler
> > in http_core.c for the mmap sections.
>
> I don't see it. Maybe I will after some sleep, but in the mean time,
> can you point it out? :)
>
> --
> Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/


Re: {PATCH} ap_put_statinfo

Posted by Manoj Kasichainula <ma...@io.com>.
On Tue, Nov 02, 1999 at 10:23:21PM -0000, David Reid wrote:
> Whilst looking into the ap_mmap stuff it seemed like a good idea to add the
> following function.  Rather than just committing I'm flagging it here as it
> might not be portable etc etc

If an ap_put_statinfo function is useful, I think that suggests that
stat information should be kept in a new and different APR object from
ap_file_t. 

> For an idea of where this might be useful can I point you at default_handler
> in http_core.c for the mmap sections.

I don't see it. Maybe I will after some sleep, but in the mean time,
can you point it out? :)

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/

Re: {PATCH} ap_put_statinfo

Posted by Bill Stoddard <st...@raleigh.ibm.com>.
>
> This isn't portable enough, unless we define a stat structure.  I am 99%
> sure that Windows doesn't use stat to get file info.  I'll have to take a
> look at this code before I can seriously suggest an alternative though.
>
> Ryan
stat is in the CRT.  However, the native call (there are a coupld actually)
are about 30% faster. I have no problem using the CRT stat structure. In
fact, this is what I suggest unless someone can come up with a compelling
reason not to use it. It will eliminate a mapping from stat to another
struct on Unix.

Bill


Re: {PATCH} ap_put_statinfo

Posted by David Reid <ab...@dial.pipex.com>.
Ryan,

After discussion with Manoj I'm going to commit a bunch of changes that
remove the need to use stat.

Been working since we agreed it so I'll get to it in the next few days.

david
----- Original Message -----
From: Ryan Bloom <rb...@raleigh.ibm.com>
To: <ne...@apache.org>
Sent: 08 November 1999 12:34
Subject: Re: {PATCH} ap_put_statinfo


>
> This isn't portable enough, unless we define a stat structure.  I am 99%
> sure that Windows doesn't use stat to get file info.  I'll have to take a
> look at this code before I can seriously suggest an alternative though.
>
> Ryan
>
> On Tue, 2 Nov 1999, David Reid wrote:
>
> > Whilst looking into the ap_mmap stuff it seemed like a good idea to add
the
> > following function.  Rather than just committing I'm flagging it here as
it
> > might not be portable etc etc
> >
> > Anyway, I'll commit it later this week unless there's a reason not to.
> >
> > For an idea of where this might be useful can I point you at
default_handler
> > in http_core.c for the mmap sections.
> >
> > david
> >
> > --- /boot/home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h Sat Oct
16
> > 12:46:13 1999
> > +++ include/apr_file_io.h Tue Nov  2 21:27:27 1999
> > @@ -58,6 +58,7 @@
> >
> >  #include "apr_general.h"
> >  #include "apr_errno.h"
> > +#include <sys/stat.h>
> >  #ifdef HAVE_TIME_H
> >  #include <time.h>
> >  #endif
> > @@ -162,6 +163,8 @@
> >  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_put_statinfo(ap_file_t *, struct stat *);
> >
> >  #ifdef __cplusplus
> >  }
> > diff -ru /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c
> > unix/filestat.c
> > --- /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c Tue
Oct  5
> > 02:15:19 1999
> > +++ unix/filestat.c Tue Nov  2 21:27:14 1999
> > @@ -84,3 +84,19 @@
> >      }
> >  }
> >
> > +ap_status_t ap_put_statinfo(struct file_t *thefile, struct stat
*theinfo)
> > +{
> > +    if (thefile == NULL)
> > +        return APR_EBADF;
> > +
> > +    thefile->protection = theinfo->st_mode;
> > +    thefile->user = theinfo->st_uid;
> > +    thefile->group = theinfo->st_gid;
> > +    thefile->size = theinfo->st_size;
> > +    thefile->atime = theinfo->st_atime;
> > +    thefile->mtime = theinfo->st_mtime;
> > +    thefile->ctime = theinfo->st_ctime;
> > +    thefile->stated = 1;
> > +    return APR_SUCCESS;
> > +}
> > +
> >
> >
>
> _______________________________________________________________________
> Ryan Bloom rbb@raleigh.ibm.com
> 4205 S Miami Blvd
> RTP, NC 27709 It's a beautiful sight to see good dancers
> doing simple steps.  It's a painful sight to
> see beginners doing complicated patterns.
>


Re: {PATCH} ap_put_statinfo

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
This isn't portable enough, unless we define a stat structure.  I am 99%
sure that Windows doesn't use stat to get file info.  I'll have to take a
look at this code before I can seriously suggest an alternative though.

Ryan

On Tue, 2 Nov 1999, David Reid wrote:

> Whilst looking into the ap_mmap stuff it seemed like a good idea to add the
> following function.  Rather than just committing I'm flagging it here as it
> might not be portable etc etc
> 
> Anyway, I'll commit it later this week unless there's a reason not to.
> 
> For an idea of where this might be useful can I point you at default_handler
> in http_core.c for the mmap sections.
> 
> david
> 
> --- /boot/home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h Sat Oct 16
> 12:46:13 1999
> +++ include/apr_file_io.h Tue Nov  2 21:27:27 1999
> @@ -58,6 +58,7 @@
> 
>  #include "apr_general.h"
>  #include "apr_errno.h"
> +#include <sys/stat.h>
>  #ifdef HAVE_TIME_H
>  #include <time.h>
>  #endif
> @@ -162,6 +163,8 @@
>  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_put_statinfo(ap_file_t *, struct stat *);
> 
>  #ifdef __cplusplus
>  }
> diff -ru /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c
> unix/filestat.c
> --- /boot/home/cvs/apache-2.0/src/lib/apr/file_io/unix/filestat.c Tue Oct  5
> 02:15:19 1999
> +++ unix/filestat.c Tue Nov  2 21:27:14 1999
> @@ -84,3 +84,19 @@
>      }
>  }
> 
> +ap_status_t ap_put_statinfo(struct file_t *thefile, struct stat *theinfo)
> +{
> +    if (thefile == NULL)
> +        return APR_EBADF;
> +
> +    thefile->protection = theinfo->st_mode;
> +    thefile->user = theinfo->st_uid;
> +    thefile->group = theinfo->st_gid;
> +    thefile->size = theinfo->st_size;
> +    thefile->atime = theinfo->st_atime;
> +    thefile->mtime = theinfo->st_mtime;
> +    thefile->ctime = theinfo->st_ctime;
> +    thefile->stated = 1;
> +    return APR_SUCCESS;
> +}
> +
> 
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.