repos.c revision 6f984345bbfa9342dde1f2b7b8c35b7987d078af
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* ====================================================================
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * The Apache Software License, Version 1.1
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * Copyright (c) 2000 The Apache Software Foundation. All rights
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * Redistribution and use in source and binary forms, with or without
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * modification, are permitted provided that the following conditions
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * 1. Redistributions of source code must retain the above copyright
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * notice, this list of conditions and the following disclaimer.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * 2. Redistributions in binary form must reproduce the above copyright
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * notice, this list of conditions and the following disclaimer in
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * the documentation and/or other materials provided with the
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * distribution.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * 3. The end-user documentation included with the redistribution,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * if any, must include the following acknowledgment:
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * "This product includes software developed by the
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * Apache Software Foundation (http://www.apache.org/)."
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * Alternately, this acknowledgment may appear in the software itself,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * if and wherever such third-party acknowledgments normally appear.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * 4. The names "Apache" and "Apache Software Foundation" must
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * not be used to endorse or promote products derived from this
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * software without prior written permission. For written
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * permission, please contact apache@apache.org.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * 5. Products derived from this software may not be called "Apache",
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * nor may "Apache" appear in their name, without prior written
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * permission of the Apache Software Foundation.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * SUCH DAMAGE.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * ====================================================================
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * This software consists of voluntary contributions made by many
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * individuals on behalf of the Apache Software Foundation. For more
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias * information on the Apache Software Foundation, please see
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias** DAV filesystem-based repository provider
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias#include "http_protocol.h" /* for ap_set_* (in dav_fs_set_headers) */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias#include "http_request.h" /* for ap_update_mtime() */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* to assist in debugging mod_dav's GET handling */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias#define DAV_FS_COPY_BLOCKSIZE 16384 /* copy 16k at a time */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* context needed to identify a resource */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias apr_pool_t *pool; /* memory storage pool associated with request */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias const char *pathname; /* full pathname to resource */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* private context for doing a filesystem walk */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiastypedef struct {
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias /* the input walk parameters */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias /* reused as we walk */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias /* MOVE/COPY need a secondary path */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiastypedef struct {
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias dav_buffer work_buf; /* handy buffer for copymove_file() */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias /* CALLBACK: this is a secondary resource managed specially for us */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias /* copied from dav_walk_params (they are invariant across the walk) */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* an internal WALKTYPE to walk hidden files (the .DAV directory) */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* an internal WALKTYPE to call collections (again) after their contents */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias#define DAV_CALLTYPE_POSTFIX 1000 /* a private call type */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* pull this in from the other source file */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasextern const dav_hooks_locks dav_hooks_locks_fs;
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* forward-declare the hook structures */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic const dav_hooks_repository dav_hooks_repository_fs;
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic const dav_hooks_liveprop dav_hooks_liveprop_fs;
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias** The namespace URIs that we use. This list and the enumeration must
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias** stay in sync.
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic const char * const dav_fs_namespace_uris[] =
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias DAV_FS_URI_MYPROPS /* the namespace URI for our custom props */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias** The single property that we define (in the DAV_FS_URI_MYPROPS namespace)
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic const dav_liveprop_spec dav_fs_props[] =
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias "creationdate",
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias "getcontentlength",
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias "getlastmodified",
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias "executable",
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias 0 /* handled special in dav_fs_is_writable */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias { 0 } /* sentinel */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic const dav_liveprop_group dav_fs_liveprop_group =
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* define the dav_stream structure for our use */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias const char *pathname; /* we may need to remove it at close time */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* forward declaration for internal treewalkers */
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic dav_error * dav_fs_walk(const dav_walk_params *params, int depth,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasstatic dav_error * dav_fs_internal_walk(const dav_walk_params *params,
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias/* --------------------------------------------------------------------
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogias** PRIVATE REPOSITORY FUNCTIONS
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasapr_pool_t *dav_fs_pool(const dav_resource *resource)
658187feb755694eb5ff29561bda7109c22c743cAlexis Tsogiasconst char *dav_fs_pathname(const dav_resource *resource)
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 *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;
const char *name;
return err;
return err;
return err;
return err;
return NULL;
#if DAV_DEBUG
return err;
const char *value;
int global_ns;
return DAV_PROP_INSERT_NOTDEF;
switch (propid) {
case DAV_PROPID_creationdate:
buf);
return DAV_PROP_INSERT_NOTDEF;
case DAV_PROPID_getetag:
buf);
case DAV_PROPID_FS_executable:
#ifdef WIN32
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
s = apr_psprintf(p,
return what;
#ifndef WIN32
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;
#ifndef WIN32
#ifndef WIN32