repos.c revision ba5fef01faa2808e468764c697013d6e5cf8f48b
f743002678eb67b99bbc29fee116b65d9530fec0wrowe/* Licensed to the Apache Software Foundation (ASF) under one or more
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg * contributor license agreements. See the NOTICE file distributed with
cc5a4a08dc9783fcbc52ce86f11e01c281a43810minfrin * this work for additional information regarding copyright ownership.
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick * The ASF licenses this file to You under the Apache License, Version 2.0
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick * (the "License"); you may not use this file except in compliance with
f87299dab99bc04b51a6b8cad51b6795db862c0atrawick * the License. You may obtain a copy of the License at
77c6374e145713c55bc3d6e648abe917b04921f3trawick * Unless required by applicable law or agreed to in writing, software
4d12805e6c18253040223ea637acd6b3b3c18f60jorton * distributed under the License is distributed on an "AS IS" BASIS,
4d12805e6c18253040223ea637acd6b3b3c18f60jorton * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4d12805e6c18253040223ea637acd6b3b3c18f60jorton * See the License for the specific language governing permissions and
4d12805e6c18253040223ea637acd6b3b3c18f60jorton * limitations under the License.
f2287adf33e3664c55b421fd65c45f0e05fe6977covener** DAV filesystem-based repository provider
75a230a728338d84dcfe81edd375352f34de22d0covener#include "http_protocol.h" /* for ap_set_* (in dav_fs_set_headers) */
75a230a728338d84dcfe81edd375352f34de22d0covener#include "http_request.h" /* for ap_update_mtime() */
1f50dc34ae069adeed20b2986e5ffdefa5c410e0covener/* to assist in debugging mod_dav's GET handling */
63a5ea80bddcc84a462e40f402b4f330e0e05411covener#define DAV_FS_COPY_BLOCKSIZE 16384 /* copy 16k at a time */
63a5ea80bddcc84a462e40f402b4f330e0e05411covener/* context needed to identify a resource */
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin apr_pool_t *pool; /* memory storage pool associated with request */
986f3ea2c314d4d4b3b937149853a0f23f6119aaminfrin const char *pathname; /* full pathname to resource */
65a4e663b82f8bce28ac22ab2edfd7502de36998sf/* private context for doing a filesystem walk */
65a4e663b82f8bce28ac22ab2edfd7502de36998sftypedef struct {
c7de1955eb0eaeabf7042902476397692672d549sf /* the input walk parameters */
509622419be000045d461ef38fb97df778fdf81djailletc /* reused as we walk */
74e7f6c55fd67b10cb400b3f6d1dc718a303d944minfrin /* MOVE/COPY need a secondary path */
63921358ef93fcb41bc71d9894221ba3d7fbb87bminfrintypedef struct {
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin dav_buffer work_buf; /* handy buffer for copymove_file() */
6d601599d3d65df0410eae6e573e75b2dbfb1fb4minfrin /* CALLBACK: this is a secondary resource managed specially for us */
2c487ac43b583db869e743772a7a10b278aa2bcfminfrin /* copied from dav_walk_params (they are invariant across the walk) */
5c43d2fb853f84497b5ece2d414ef9484aa87e5fsf/* an internal WALKTYPE to walk hidden files (the .DAV directory) */
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq/* an internal WALKTYPE to call collections (again) after their contents */
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq#define DAV_CALLTYPE_POSTFIX 1000 /* a private call type */
ef82e8fa164e0a1f8b813f7deb6b7ead96018c94niq/* pull this in from the other source file */
c12917da693bae4028a1d5a5e8224bceed8c739dsf/* forward-declare the hook structures */
c12917da693bae4028a1d5a5e8224bceed8c739dsfstatic const dav_hooks_repository dav_hooks_repository_fs;
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf** The namespace URIs that we use. This list and the enumeration must
eafcc0ebf263d0ba69855b6e10958c4c1a2361bdsf** stay in sync.
d7ffd2da16d58b1a0de212e4d56f7aebb72bef26sfstatic const char * const dav_fs_namespace_uris[] =
1366443dc565c33e7b449ae428bbfc4c86f33935drh DAV_FS_URI_MYPROPS /* the namespace URI for our custom props */
bd3f5647b96d378d9c75c954e3f13582af32c643sf** Does this platform support an executable flag?
bd3f5647b96d378d9c75c954e3f13582af32c643sf** ### need a way to portably abstract this query
584a85dd4047e38d3ed3a29b6662fcc9d100ae4csf** The single property that we define (in the DAV_FS_URI_MYPROPS namespace)
f6b9c755a0b793e8a3a3aebd327ca20a86478117sf /* standard DAV properties */
132ee6ac1c26d6e8953836316ba50734eefab47bsf "creationdate",
d776b0a2d2889ce1d13494873368f34327a2e1bbtrawick "getcontentlength",
79c5787b92ac5f0e1cc82393816c77a006399316trawick "getlastmodified",
79c5787b92ac5f0e1cc82393816c77a006399316trawick /* our custom properties */
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton "executable",
7b395e4e878c28a4784919cfd2e704ddd14a3390jorton 0 /* handled special in dav_fs_is_writable */
536e48c08d674acac5d44929318f2ad928edc361jorton { 0 } /* sentinel */
3e4e54d4e3fc0123c63d57aa84ac7ad7a8c73ff8jortonstatic const dav_liveprop_group dav_fs_liveprop_group =
6bb524f1895f30265a1431afc460977d391cb36bsf/* define the dav_stream structure for our use */
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin const char *pathname; /* we may need to remove it at close time */
e6dd71992459d05a676b98b7963423dc5dc1e24aminfrin/* returns an appropriate HTTP status code given an APR status code for a
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin * failed I/O operation. ### use something besides 500? */
23f1535d6a60817d2846bac0aea230ea475d7dccminfrin#define MAP_IO2HTTP(e) (APR_STATUS_IS_ENOSPC(e) ? HTTP_INSUFFICIENT_STORAGE : \
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjung/* forward declaration for internal treewalkers */
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjungstatic dav_error * dav_fs_walk(const dav_walk_params *params, int depth,
ec7520b24cd80d34d82bbcaca153cbb23cc04bc0rjungstatic dav_error * dav_fs_internal_walk(const dav_walk_params *params,
6249dfa569d3b4f1f539665b979a80c6e335d93etrawick/* --------------------------------------------------------------------
0827cb14e550f6f65018431c22c2c913631c8f25kbrand** PRIVATE REPOSITORY FUNCTIONS
ae600ca541efc686b34f8b1f21bd3d0741d37674covenerapr_pool_t *dav_fs_pool(const dav_resource *resource)
74499a117b3b2cd9666715a14f90c0e5d1a4ee8ajimconst char *dav_fs_pathname(const dav_resource *resource)
const char **dirpath_p,
const char **fname_p)
if (dirlen > 0) {
"An incomplete/bad path was found in "
return NULL;
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 *label,
int use_checked_in,
char *filename;
return NULL;
char *dirpath;
const char *testroot;
const char *testpath;
return NULL;
return NULL;
return NULL;
static int dav_fs_is_same_resource(
static int dav_fs_is_parent_resource(
switch (mode) {
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;
ap_set_etag(r);
return NULL;
return NULL;
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);
return NULL;
return err;
return NULL;
return err;
return NULL;
return err;
return err;
return err;
return err;
return NULL;
#if DAV_DEBUG
return err;
NULL,
NULL,
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:
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
return DAV_PROP_INSERT_NOTDEF;
s = apr_psprintf(p,
return what;
#ifdef DAV_FS_HAS_EXECUTABLE
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 DAV_FS_HAS_EXECUTABLE
#ifdef DAV_FS_HAS_EXECUTABLE