repos.c revision 52c1d304b1bd8e05da40a7cded2ecb9f0ba614c5
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu/* ====================================================================
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * The Apache Software License, Version 1.1
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * Copyright (c) 2000 The Apache Software Foundation. All rights
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * Redistribution and use in source and binary forms, with or without
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * modification, are permitted provided that the following conditions
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * 1. Redistributions of source code must retain the above copyright
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * notice, this list of conditions and the following disclaimer.
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * 2. Redistributions in binary form must reproduce the above copyright
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * notice, this list of conditions and the following disclaimer in
17f1de180b775332d98ff24c7ce51d6866272dcdChristian Maeder * the documentation and/or other materials provided with the
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maeder * distribution.
7cfd47f6dc4147e9a3d21d72f68c6325552092f0Christian Maeder * 3. The end-user documentation included with the redistribution,
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * if any, must include the following acknowledgment:
3f5d611a1388ce3cd33f86da3f1e9b7ad68d087cMihaela Turcu * "This product includes software developed by the
17f1de180b775332d98ff24c7ce51d6866272dcdChristian Maeder * Apache Software Foundation (http://www.apache.org/)."
17f1de180b775332d98ff24c7ce51d6866272dcdChristian Maeder * Alternately, this acknowledgment may appear in the software itself,
17f1de180b775332d98ff24c7ce51d6866272dcdChristian Maeder * if and wherever such third-party acknowledgments normally appear.
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder * 4. The names "Apache" and "Apache Software Foundation" must
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * not be used to endorse or promote products derived from this
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * software without prior written permission. For written
53d2d31717e8c65bb3c2d1f2cd891d626cf45e5bChristian Maeder * permission, please contact apache@apache.org.
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * 5. Products derived from this software may not be called "Apache",
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * nor may "Apache" appear in their name, without prior written
c55f9e48a7d93c41ebfe7a3216ed305165346e2fChristian Maeder * permission of the Apache Software Foundation.
53d2d31717e8c65bb3c2d1f2cd891d626cf45e5bChristian Maeder * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
53d2d31717e8c65bb3c2d1f2cd891d626cf45e5bChristian Maeder * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maeder * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * SUCH DAMAGE.
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * ====================================================================
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder * This software consists of voluntary contributions made by many
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * individuals on behalf of the Apache Software Foundation. For more
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu * information on the Apache Software Foundation, please see
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu** DAV filesystem-based repository provider
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu#include "http_protocol.h" /* for ap_set_* (in dav_fs_set_headers) */
1070181294f9381ac4ac19eba1c3ecc40fc731a4Mihaela Turcu#include "http_request.h" /* for ap_update_mtime() */
d20b265a2765e843986ceed6bf0055582981bf0fChristian Maeder/* to assist in debugging mod_dav's GET handling */
7cfd47f6dc4147e9a3d21d72f68c6325552092f0Christian Maeder#define DAV_FS_COPY_BLOCKSIZE 16384 /* copy 16k at a time */
17f1de180b775332d98ff24c7ce51d6866272dcdChristian Maeder/* context needed to identify a resource */
765f3b8c82bca96eeb44463da2305201b1a493daChristian Maeder apr_pool_t *pool; /* memory storage pool associated with request */
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maeder const char *pathname; /* full pathname to resource */
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maeder/* private context for doing a filesystem walk */
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maedertypedef struct {
de2d031e186086e2cb775bc59bacda87c9b18371Christian Maeder /* the input walk parameters */
d20b265a2765e843986ceed6bf0055582981bf0fChristian Maeder /* reused as we walk */
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder/* pull this in from the other source file */
d12f7a58b996457c25e12d674153346a4e21930eChristian Maederextern const dav_hooks_locks dav_hooks_locks_fs;
53d2d31717e8c65bb3c2d1f2cd891d626cf45e5bChristian Maeder/* forward-declare this sucker */
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maederstatic const dav_hooks_repository dav_hooks_repository_fs;
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder** The Provider ID is used to differentiate "logical" providers that use
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder** the same set of hook functions. Essentially, the ID is an instance
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder** handle and the hooks are a vtable.
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder** In this module, we only have a single provider for each type, so we
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder** actually ignore the Provider ID.
398f02e814574f163278b28b5c78cd213493f7ccChristian Maeder** The namespace URIs that we use. This list and the enumeration must
398f02e814574f163278b28b5c78cd213493f7ccChristian Maeder** stay in sync.
16779ccfe622e9db869898f724bc0132b90cb7d7Christian Maederstatic const char * const dav_fs_namespace_uris[] =
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maeder DAV_FS_URI_DAV, /* the DAV: namespace URI */
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maeder DAV_FS_URI_MYPROPS /* the namespace URI for our custom props */
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maeder** The properties that we define.
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder /* using DAV_FS_URI_DAV */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder DAV_PROPID_FS_creationdate = DAV_PROPID_FS,
16779ccfe622e9db869898f724bc0132b90cb7d7Christian Maeder /* using DAV_FS_URI_MYPROPS */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder/* NOTE: the magic "200" is derived from the ranges in mod_dav.h */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder#define DAV_PROPID_FS_OURS(id) (DAV_PROPID_FS <= (id) && \
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maedertypedef struct {
dc792317de0a95aac4e9a6dadfb78df050e5022eChristian Maeder const char * name;
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maederstatic const dav_fs_liveprop_name dav_fs_props[] =
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder { DAV_FS_URI_DAV, "creationdate", DAV_PROPID_FS_creationdate },
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder { DAV_FS_URI_DAV, "getcontentlength", DAV_PROPID_FS_getcontentlength },
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder { DAV_FS_URI_DAV, "getetag", DAV_PROPID_FS_getetag },
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder { DAV_FS_URI_DAV, "getlastmodified", DAV_PROPID_FS_getlastmodified },
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder { DAV_FS_URI_MYPROPS, "executable", DAV_PROPID_FS_executable },
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder /* ### these aren't FS specific */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder { DAV_FS_URI_DAV, "displayname", DAV_PROPID_FS_displayname },
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder { DAV_FS_URI_DAV, "source", DAV_PROPID_FS_source },
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder { 0 } /* sentinel */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder/* define the dav_stream structure for our use */
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maeder const char *pathname; /* we may need to remove it at close time */
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder/* forward declaration for internal treewalkers */
a2cc771b106f5792a02348fd36475550b8731792Christian Maederstatic dav_error * dav_fs_walk(dav_walker_ctx *wctx, int depth);
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder/* --------------------------------------------------------------------
a2cc771b106f5792a02348fd36475550b8731792Christian Maeder** PRIVATE REPOSITORY FUNCTIONS
a2cc771b106f5792a02348fd36475550b8731792Christian Maederapr_pool_t *dav_fs_pool(const dav_resource *resource)
3397210aac34a94e9ae85faacf7f6a02a808097eChristian Maederconst char *dav_fs_pathname(const dav_resource *resource)
16779ccfe622e9db869898f724bc0132b90cb7d7Christian Maeder dav_resource_private *ctx = resource->info;
c55f9e48a7d93c41ebfe7a3216ed305165346e2fChristian Maeder char *dirpath = ap_make_dirstr_parent(ctx->pool, ctx->pathname);
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder /* remove trailing slash from dirpath, unless it's the root dir */
d12f7a58b996457c25e12d674153346a4e21930eChristian Maeder /* ### Win32 check */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder if (dirlen > 1 && dirpath[dirlen - 1] == '/') {
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder/* Note: picked up from ap_gm_timestr_822() */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder/* NOTE: buf must be at least DAV_TIMEBUF_SIZE chars in size */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maederstatic void dav_format_time(int style, apr_time_t sec, char *buf)
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder /* ### what to do if fails? */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder /* ### should we use "-00:00" instead of "Z" ?? */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder /* 20 chars plus null term */
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ",
c5ddf41fe430a758733dbc46db25d5910c85ab8cChristian Maeder tms.tm_year + 1900, tms.tm_mon + 1, tms.tm_mday,
int is_move,
apr_pool_t * p,
const char *src,
const char *dst,
!= APR_SUCCESS) {
return err;
return NULL;
int is_move,
apr_pool_t * p,
const char *src;
const char *dst;
return NULL;
return NULL;
const char *src_dir;
const char *src_file;
const char *src_state1;
const char *src_state2;
const char *dst_dir;
const char *dst_file;
const char *dst_state1;
const char *dst_state2;
#if DAV_DEBUG
pbuf);
pbuf);
return err;
const char *dirpath;
const char *fname;
const char *state1;
const char *state2;
const char *pathname;
NULL);
NULL);
return NULL;
request_rec *r,
const char *root_dir,
const char *workspace,
const char *target,
int is_label)
char *filename;
return resource;
char *dirpath;
#ifdef WIN32
return NULL;
return parent_resource;
static int dav_fs_is_same_resource(
#ifdef WIN32
static int dav_fs_is_parent_resource(
switch (mode) {
case DAV_MODE_READ:
case DAV_MODE_READ_SEEKABLE:
case DAV_MODE_WRITE_TRUNC:
case DAV_MODE_WRITE_SEEKABLE:
ds->p = p;
return NULL;
if (!commit) {
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
ap_set_etag(r);
return NULL;
static const char * dav_fs_get_pathname(
void **free_handle_p)
return NULL;
int calltype)
return NULL;
return err;
int is_move,
int depth,
if (is_move)
return err;
return NULL;
return err;
int depth,
#if DAV_DEBUG
return err;
int can_rename = 0;
#if DAV_DEBUG
const char *dirpath;
if (!can_rename) {
return err;
return NULL;
err);
err);
int result;
if (result != 0) {
return NULL;
return err;
return NULL;
return err;
return NULL;
char *name;
return err;
return err;
return err;
return err;
return NULL;
#if DAV_DEBUG
return err;
int ns;
const char *value;
int ns;
return DAV_PROP_INSERT_NOTME;
** properties; the NOTDEF return code indicates that dav_props.c should
return DAV_PROP_INSERT_NOTDEF;
switch (propid) {
buf);
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_FS_getetag:
buf);
case DAV_PROPID_FS_executable:
#ifdef WIN32
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_FS_source:
return DAV_PROP_INSERT_NOTDEF;
if (insvalue) {
return which;
#ifndef WIN32
int propid)
return DAV_PROP_RW_NOTME;
#ifndef WIN32
return DAV_PROP_RW_YES;
return DAV_PROP_RW_NO;
int operation,
void **context,
int *defer_to_dead)
char value;
return NULL;
? NULL
/* DBG3("name=%s cdata=%s f_cdata=%s",elem->name,cdata ? cdata->text : "[null]",f_cdata ? f_cdata->text : "[null]"); */
goto too_long;
goto too_long;
return NULL;
int operation,
void *context,
return NULL;
if (value)
return NULL;
int operation,
void *context,
int operation,
void *context,
if (value)
return NULL;
#ifdef WIN32
NULL,
#ifndef WIN32
if (propid == 0)
return propid;