You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2002/02/01 02:40:39 UTC

cvs commit: apr/include apr_file_info.h apr_file_io.h

gstein      02/01/31 17:40:39

  Modified:    .        libapr.dsp
               file_io/unix Makefile.in filestat.c
               file_io/win32 filestat.c
               include  apr_file_info.h apr_file_io.h
  Log:
  Add apr_file_copy() and apr_file_append() functions. These are written
  in terms of APR itself, so each platform just uses the one function. A
  future improvement would use CopyFile(Ex) on Windows and sendfile() on
  sendfile-capable systems.
  
  Also add apr_file_attrs_set() for setting file attributes in a logical
  fashion, rather than based on (Posix) permission bits. This is not
  (yet) implemented for Windows, and still needs a way to turn *off* the
  readonly and executable modes.
  
  Submitted by: Philip Martin <ph...@codematters.co.uk>
  
  Revision  Changes    Path
  1.55      +4 -0      apr/libapr.dsp
  
  Index: libapr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/libapr.dsp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- libapr.dsp	31 Jan 2002 17:29:09 -0000	1.54
  +++ libapr.dsp	1 Feb 2002 01:40:38 -0000	1.55
  @@ -103,6 +103,10 @@
   # PROP Default_Filter ""
   # Begin Source File
   
  +SOURCE=.\file_io\unix\copy.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\file_io\win32\dir.c
   # End Source File
   # Begin Source File
  
  
  
  1.24      +1 -0      apr/file_io/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/Makefile.in,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Makefile.in	31 Mar 2001 06:22:38 -0000	1.23
  +++ Makefile.in	1 Feb 2002 01:40:38 -0000	1.24
  @@ -1,5 +1,6 @@
   
   TARGETS = \
  +	copy.lo \
   	dir.lo \
   	fileacc.lo \
   	filedup.lo \
  
  
  
  1.49      +26 -0     apr/file_io/unix/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filestat.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- filestat.c	16 Oct 2001 23:24:09 -0000	1.48
  +++ filestat.c	1 Feb 2002 01:40:38 -0000	1.49
  @@ -136,6 +136,32 @@
       return APR_SUCCESS;
   }
   
  +APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
  +                                             apr_fileattrs_t attributes,
  +                                             apr_pool_t *cont)
  +{
  +    apr_status_t status;
  +    apr_finfo_t finfo;
  +
  +    status = apr_stat(&finfo, fname, APR_FINFO_PROT, cont);
  +    if (!APR_STATUS_IS_SUCCESS(status))
  +        return status;
  +
  +    if (attributes & APR_FILE_ATTR_READONLY) {
  +        finfo.protection &= ~APR_UWRITE;
  +        finfo.protection &= ~APR_GWRITE;
  +        finfo.protection &= ~APR_WWRITE;
  +    }
  +    if (attributes & APR_FILE_ATTR_EXECUTABLE) {
  +        /* ### TODO: should this be umask'd? */
  +        finfo.protection |= APR_UEXECUTE;
  +        finfo.protection |= APR_GEXECUTE;
  +        finfo.protection |= APR_WEXECUTE;
  +    }
  +
  +   return apr_file_perms_set(fname, finfo.protection);
  +}
  +                                                  
   APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, 
                                      const char *fname, 
                                      apr_int32_t wanted, apr_pool_t *cont)
  
  
  
  1.62      +7 -0      apr/file_io/win32/filestat.c
  
  Index: filestat.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filestat.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- filestat.c	28 Jan 2002 15:56:08 -0000	1.61
  +++ filestat.c	1 Feb 2002 01:40:38 -0000	1.62
  @@ -611,3 +611,10 @@
   {
       return apr_stat(finfo, fname, wanted | APR_FINFO_LINK, cont);
   }
  +
  +APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
  +                                             apr_fileattrs_t attributes,
  +                                             apr_pool_t *cont)
  +{
  +   return APR_ENOTIMPL;
  +}
  
  
  
  1.25      +17 -12    apr/include/apr_file_info.h
  
  Index: apr_file_info.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_info.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- apr_file_info.h	9 Sep 2001 06:03:05 -0000	1.24
  +++ apr_file_info.h	1 Feb 2002 01:40:38 -0000	1.25
  @@ -94,20 +94,25 @@
    * @{
    */
   
  -#define APR_UREAD     0x400 /**< Read by user */
  -#define APR_UWRITE    0x200 /**< Write by user */
  -#define APR_UEXECUTE  0x100 /**< Execute by user */
  -
  -#define APR_GREAD     0x040 /**< Read by group */
  -#define APR_GWRITE    0x020 /**< Write by group */
  -#define APR_GEXECUTE  0x010 /**< Execute by group */
  -
  -#define APR_WREAD     0x004 /**< Read by others */
  -#define APR_WWRITE    0x002 /**< Write by others */
  -#define APR_WEXECUTE  0x001 /**< Execute by others */
  +#define APR_UREAD       0x4000 /**< Read by user */
  +#define APR_UWRITE      0x2000 /**< Write by user */
  +#define APR_UEXECUTE    0x1000 /**< Execute by user */
  +
  +#define APR_GREAD       0x0040 /**< Read by group */
  +#define APR_GWRITE      0x0020 /**< Write by group */
  +#define APR_GEXECUTE    0x0010 /**< Execute by group */
  +
  +#define APR_WREAD       0x0004 /**< Read by others */
  +#define APR_WWRITE      0x0002 /**< Write by others */
  +#define APR_WEXECUTE    0x0001 /**< Execute by others */
  +
  +#define APR_OS_DEFAULT  0x0FFF /**< use OS's default permissions */
  +
  +/* additional permission flags for apr_file_copy  and apr_file_append */
  +#define APR_FILE_SOURCE_PERMS 0x1000 /**< Copy source file's permissions */
   
  -#define APR_OS_DEFAULT 0xFFF /**< use default permissions of Underlying Operating System*/
   /** @} */
  +
   
   /**
    * Structure for referencing directories.
  
  
  
  1.117     +66 -0     apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_io.h,v
  retrieving revision 1.116
  retrieving revision 1.117
  diff -u -r1.116 -r1.117
  --- apr_file_io.h	25 Jan 2002 21:07:49 -0000	1.116
  +++ apr_file_io.h	1 Feb 2002 01:40:38 -0000	1.117
  @@ -115,6 +115,19 @@
   #define APR_END SEEK_END
   /** @} */
   
  +/**
  + * @defgroup APR_file_set_attributes File Attribute Flags
  + * @{
  + */
  +
  +/* flags for apr_file_set_attributes */
  +#define APR_FILE_ATTR_READONLY   0x01          /**< File is read-only */
  +#define APR_FILE_ATTR_EXECUTABLE 0x02          /**< File is executable */
  +/** @} */
  +
  +/** File attributes */
  +typedef apr_int32_t apr_fileattrs_t;
  +
   /** should be same as whence type in lseek, POSIX defines this as int */
   typedef int       apr_seek_where_t;
   
  @@ -205,6 +218,39 @@
                                             apr_pool_t *pool);
   
   /**
  + * copy the specified file to another file.
  + * @param from_path The full path to the original file (using / on all systems)
  + * @param to_path The full path to the new file (using / on all systems)
  + * @param perms Access permissions for the new file if it is created.
  + *     In place of the usual or'd combination of file permissions, the
  + *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
  + *     file's permissions are copied.
  + * @param pool The pool to use.
  + * @remark The new file does not need to exist, it will be created if required.
  + * @warning If the new file already exists, its contents will be overwritten.
  + */
  +APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, 
  +                                        const char *to_path,
  +                                        apr_fileperms_t perms,
  +                                        apr_pool_t *pool);
  +
  +/**
  + * append the specified file to another file.
  + * @param from_path The full path to the source file (using / on all systems)
  + * @param to_path The full path to the destination file (using / on all systems)
  + * @param perms Access permissions for the destination file if it is created.
  + *     In place of the usual or'd combination of file permissions, the
  + *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
  + *     file's permissions are copied.
  + * @param pool The pool to use.
  + * @remark The new file does not need to exist, it will be created if required.
  + */
  +APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, 
  +                                          const char *to_path,
  +                                          apr_fileperms_t perms,
  +                                          apr_pool_t *pool);
  +
  +/**
    * Are we at the end of the file
    * @param fptr The apr file we are testing.
    * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
  @@ -528,6 +574,26 @@
    */
   APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname,
                                              apr_fileperms_t perms);
  +
  +/**
  + * Set attributes of the specified file.
  + * @param fname The full path to the file (using / on all systems)
  + * @param attributes Or'd combination of
  + * <PRE>
  + *            APR_FILE_ATTR_READONLY   - make the file readonly
  + *            APR_FILE_ATTR_EXECUTABLE - make the file executable
  + * </PRE>
  + * @param cont the pool to use.
  + * @remark This function should be used in preference to explict manipulation
  + *      of the file permissions, because the operations to provide these
  + *      attributes are platform specific and may involve more than simply
  + *      setting permission bits.
  + * @warning Platforms which do not implement this feature will return
  + *      APR_ENOTIMPL.
  + */
  +APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname,
  +                                             apr_fileattrs_t attributes,
  +                                             apr_pool_t *cont);
   
   /**
    * Create a new directory on the file system.
  
  
  

Re: cvs commit: apr/include apr_file_info.h apr_file_io.h

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Thu, Jan 31, 2002 at 08:35:32PM -0800, Aaron Bannert wrote:
> On Fri, Feb 01, 2002 at 01:40:39AM -0000, gstein@apache.org wrote:
> > gstein      02/01/31 17:40:39
> > 
> >   Modified:    .        libapr.dsp
> >                file_io/unix Makefile.in filestat.c
> >                file_io/win32 filestat.c
> >                include  apr_file_info.h apr_file_io.h
> >   Log:
> >   Add apr_file_copy() and apr_file_append() functions. These are written
> >   in terms of APR itself, so each platform just uses the one function. A
> >   future improvement would use CopyFile(Ex) on Windows and sendfile() on
> >   sendfile-capable systems.
> >   
> >   Also add apr_file_attrs_set() for setting file attributes in a logical
> >   fashion, rather than based on (Posix) permission bits. This is not
> >   (yet) implemented for Windows, and still needs a way to turn *off* the
> >   readonly and executable modes.
> >   
> >   Submitted by: Philip Martin <ph...@codematters.co.uk>
> 
> I think you forgot to add the copy.c files from your tree, perhaps?

I just added a version of copy.c that Philip submitted to dev@svn to
the APR repository.

Should be okay now.  -- justin


Re: cvs commit: apr/include apr_file_info.h apr_file_io.h

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Thu, Jan 31, 2002 at 08:35:32PM -0800, Aaron Bannert wrote:
> On Fri, Feb 01, 2002 at 01:40:39AM -0000, gstein@apache.org wrote:
> > gstein      02/01/31 17:40:39
> > 
> >   Modified:    .        libapr.dsp
> >                file_io/unix Makefile.in filestat.c
> >                file_io/win32 filestat.c
> >                include  apr_file_info.h apr_file_io.h
> >   Log:
> >   Add apr_file_copy() and apr_file_append() functions. These are written
> >   in terms of APR itself, so each platform just uses the one function. A
> >   future improvement would use CopyFile(Ex) on Windows and sendfile() on
> >   sendfile-capable systems.
> >   
> >   Also add apr_file_attrs_set() for setting file attributes in a logical
> >   fashion, rather than based on (Posix) permission bits. This is not
> >   (yet) implemented for Windows, and still needs a way to turn *off* the
> >   readonly and executable modes.
> >   
> >   Submitted by: Philip Martin <ph...@codematters.co.uk>
> 
> I think you forgot to add the copy.c files from your tree, perhaps?

I just added a version of copy.c that Philip submitted to dev@svn to
the APR repository.

Should be okay now.  -- justin


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: cvs commit: apr/include apr_file_info.h apr_file_io.h

Posted by Aaron Bannert <aa...@clove.org>.
On Fri, Feb 01, 2002 at 01:40:39AM -0000, gstein@apache.org wrote:
> gstein      02/01/31 17:40:39
> 
>   Modified:    .        libapr.dsp
>                file_io/unix Makefile.in filestat.c
>                file_io/win32 filestat.c
>                include  apr_file_info.h apr_file_io.h
>   Log:
>   Add apr_file_copy() and apr_file_append() functions. These are written
>   in terms of APR itself, so each platform just uses the one function. A
>   future improvement would use CopyFile(Ex) on Windows and sendfile() on
>   sendfile-capable systems.
>   
>   Also add apr_file_attrs_set() for setting file attributes in a logical
>   fashion, rather than based on (Posix) permission bits. This is not
>   (yet) implemented for Windows, and still needs a way to turn *off* the
>   readonly and executable modes.
>   
>   Submitted by: Philip Martin <ph...@codematters.co.uk>

I think you forgot to add the copy.c files from your tree, perhaps?

I'm getting:

gmake[1]: Entering directory `/home/aaron/work/httpd-2.0/srclib/apr/file_io/unix'
gmake[1]: *** No rule to make target `copy.lo', needed by `local-all'.  Stop.
gmake[1]: Leaving directory `/home/aaron/work/httpd-2.0/srclib/apr/file_io/unix'

(Justin pointed the build failure, BTW)

-aaron

Re: cvs commit: apr/include apr_file_info.h apr_file_io.h

Posted by Jeff Trawick <tr...@attglobal.net>.
gstein@apache.org writes:

> gstein      02/01/31 17:40:39
> 
>   Modified:    .        libapr.dsp
>                file_io/unix Makefile.in filestat.c
>                file_io/win32 filestat.c
>                include  apr_file_info.h apr_file_io.h
>   Log:
...
>   Also add apr_file_attrs_set() for setting file attributes in a logical
>   fashion, rather than based on (Posix) permission bits. This is not
>   (yet) implemented for Windows, and still needs a way to turn *off* the
>   readonly and executable modes.
...
>   Index: apr_file_info.h
>   ===================================================================
>   RCS file: /home/cvs/apr/include/apr_file_info.h,v
>   retrieving revision 1.24
>   retrieving revision 1.25
>   diff -u -r1.24 -r1.25
>   --- apr_file_info.h	9 Sep 2001 06:03:05 -0000	1.24
>   +++ apr_file_info.h	1 Feb 2002 01:40:38 -0000	1.25
>   @@ -94,20 +94,25 @@
>     * @{
>     */
>    
>   -#define APR_UREAD     0x400 /**< Read by user */
>   -#define APR_UWRITE    0x200 /**< Write by user */
>   -#define APR_UEXECUTE  0x100 /**< Execute by user */
>   -
>   -#define APR_GREAD     0x040 /**< Read by group */
>   -#define APR_GWRITE    0x020 /**< Write by group */
>   -#define APR_GEXECUTE  0x010 /**< Execute by group */
>   -
>   -#define APR_WREAD     0x004 /**< Read by others */
>   -#define APR_WWRITE    0x002 /**< Write by others */
>   -#define APR_WEXECUTE  0x001 /**< Execute by others */
>   +#define APR_UREAD       0x4000 /**< Read by user */
>   +#define APR_UWRITE      0x2000 /**< Write by user */
>   +#define APR_UEXECUTE    0x1000 /**< Execute by user */
>   +
>   +#define APR_GREAD       0x0040 /**< Read by group */
>   +#define APR_GWRITE      0x0020 /**< Write by group */
>   +#define APR_GEXECUTE    0x0010 /**< Execute by group */
>   +
>   +#define APR_WREAD       0x0004 /**< Read by others */
>   +#define APR_WWRITE      0x0002 /**< Write by others */
>   +#define APR_WEXECUTE    0x0001 /**< Execute by others */
>   +
>   +#define APR_OS_DEFAULT  0x0FFF /**< use OS's default permissions */

Shouldn't APR_OS_DEFAULT have been changed to 0xFFFF with this?  It no
longer works.  Try to run testdir more than once.  Try to run
buildconf after running testdir.  testdir says perms should be
APR_OS_DEFAULT.  The perms on the created directory end up being 055.

Hopefully I'll get time to play with it later today...  but
confirmation in advance is always nice :)

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Re: cvs commit: apr/include apr_file_info.h apr_file_io.h

Posted by Jeff Trawick <tr...@attglobal.net>.
gstein@apache.org writes:

> gstein      02/01/31 17:40:39
> 
>   Modified:    .        libapr.dsp
>                file_io/unix Makefile.in filestat.c
>                file_io/win32 filestat.c
>                include  apr_file_info.h apr_file_io.h
>   Log:
...
>   Also add apr_file_attrs_set() for setting file attributes in a logical
>   fashion, rather than based on (Posix) permission bits. This is not
>   (yet) implemented for Windows, and still needs a way to turn *off* the
>   readonly and executable modes.
...
>   Index: apr_file_info.h
>   ===================================================================
>   RCS file: /home/cvs/apr/include/apr_file_info.h,v
>   retrieving revision 1.24
>   retrieving revision 1.25
>   diff -u -r1.24 -r1.25
>   --- apr_file_info.h	9 Sep 2001 06:03:05 -0000	1.24
>   +++ apr_file_info.h	1 Feb 2002 01:40:38 -0000	1.25
>   @@ -94,20 +94,25 @@
>     * @{
>     */
>    
>   -#define APR_UREAD     0x400 /**< Read by user */
>   -#define APR_UWRITE    0x200 /**< Write by user */
>   -#define APR_UEXECUTE  0x100 /**< Execute by user */
>   -
>   -#define APR_GREAD     0x040 /**< Read by group */
>   -#define APR_GWRITE    0x020 /**< Write by group */
>   -#define APR_GEXECUTE  0x010 /**< Execute by group */
>   -
>   -#define APR_WREAD     0x004 /**< Read by others */
>   -#define APR_WWRITE    0x002 /**< Write by others */
>   -#define APR_WEXECUTE  0x001 /**< Execute by others */
>   +#define APR_UREAD       0x4000 /**< Read by user */
>   +#define APR_UWRITE      0x2000 /**< Write by user */
>   +#define APR_UEXECUTE    0x1000 /**< Execute by user */
>   +
>   +#define APR_GREAD       0x0040 /**< Read by group */
>   +#define APR_GWRITE      0x0020 /**< Write by group */
>   +#define APR_GEXECUTE    0x0010 /**< Execute by group */
>   +
>   +#define APR_WREAD       0x0004 /**< Read by others */
>   +#define APR_WWRITE      0x0002 /**< Write by others */
>   +#define APR_WEXECUTE    0x0001 /**< Execute by others */
>   +
>   +#define APR_OS_DEFAULT  0x0FFF /**< use OS's default permissions */

Shouldn't APR_OS_DEFAULT have been changed to 0xFFFF with this?  It no
longer works.  Try to run testdir more than once.  Try to run
buildconf after running testdir.  testdir says perms should be
APR_OS_DEFAULT.  The perms on the created directory end up being 055.

Hopefully I'll get time to play with it later today...  but
confirmation in advance is always nice :)

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...