lock.c revision 6582c8e9b0d0d65427b0c55cb48eaac7950dcb8f
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi/* ====================================================================
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * Redistribution and use in source and binary forms, with or without
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * modification, are permitted provided that the following conditions
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * 1. Redistributions of source code must retain the above copyright
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * notice, this list of conditions and the following disclaimer.
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * distribution.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * 3. The end-user documentation included with the redistribution,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * if any, must include the following acknowledgment:
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * "This product includes software developed by the
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * Apache Software Foundation (http://www.apache.org/)."
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * Alternately, this acknowledgment may appear in the software itself,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * if and wherever such third-party acknowledgments normally appear.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * 4. The names "Apache" and "Apache Software Foundation" must
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * not be used to endorse or promote products derived from this
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * software without prior written permission. For written
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * permission, please contact apache@apache.org.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * 5. Products derived from this software may not be called "Apache",
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * nor may "Apache" appear in their name, without prior written
9f1e24d6556e511a871fe4a354b955f549fda6c5sf * permission of the Apache Software Foundation.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * SUCH DAMAGE.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * ====================================================================
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * This software consists of voluntary contributions made by many
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * individuals on behalf of the Apache Software Foundation. For more
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi * information on the Apache Software Foundation, please see
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** DAV filesystem lock implementation
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar/* ---------------------------------------------------------------
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** Lock database primitives
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** LOCK DATABASES
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** Lockdiscovery information is stored in the single lock database specified
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** by the DAVLockDB directive. Information about this db is stored in the
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** global server configuration.
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** The database is keyed by a key_type unsigned char (DAV_TYPE_INODE or
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** DAV_TYPE_FNAME) followed by inode and device number if possible,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** otherwise full path (in the case of Win32 or lock-null resources).
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** The value consists of a list of elements.
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** DIRECT LOCK: [char (DAV_LOCK_DIRECT),
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** char (dav_lock_scope),
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** char (dav_lock_type),
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** int depth,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** time_t expires,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** apr_uuid_t locktoken,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** char[] owner,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** char[] auth_user]
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** INDIRECT LOCK: [char (DAV_LOCK_INDIRECT),
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** apr_uuid_t locktoken,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** time_t expires,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** int key_size,
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** char[] key]
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar** The key is to the collection lock that resulted in this indirect lock
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi/* Stored lock_discovery prefix */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi/* ack. forward declare. */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic dav_error * dav_fs_remove_locknull_member(apr_pool_t *p,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi const char *filename,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** Use the opaquelock scheme for locktokens
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi memcmp(&(plt1)->uuid, &(plt2)->uuid, sizeof((plt1)->uuid))
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi/* #################################################################
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** ### keep these structures (internal) or move fully to dav_lock?
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** We need to reliably size the fixed-length portion of
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** dav_lock_discovery; best to separate it into another
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi** struct for a convenient sizeof, unless we pack lock_discovery.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi const char *owner; /* owner field from activelock */
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung const char *auth_user; /* authenticated user who created the lock */
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh/* Indirect locks represent locks inherited from containing collections.
0d0ba3a410038e179b695446bb149cce6264e0abnd * They reference the lock token for the collection the lock is
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh * inherited from. A lock provider may also define a key to the
727872d18412fc021f03969b8641810d8896820bhumbedooh * inherited lock, for fast datbase lookup. The key is opaque outside
0d0ba3a410038e179b695446bb149cce6264e0abnd * the lock provider.
0d0ba3a410038e179b695446bb149cce6264e0abndtypedef struct dav_lock_indirect
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh/* ################################################################# */
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd** Stored direct lock info - full lock_discovery length:
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd** prefix + Fixed length + lock token + 2 strings + 2 nulls (one for each string)
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi#define dav_size_direct(a) (1 + sizeof(dav_lock_discovery_fixed) \
+ sizeof(apr_uuid_t) \
+ sizeof(time_t) \
struct dav_lockdb_private
struct dav_lock_private
apr_pool_t *p,
const char *char_token,
return dav_new_error(p,
return NULL;
static const char *dav_fs_format_locktoken(
apr_pool_t *p,
static int dav_fs_compare_locktoken(
return NULL;
err);
return NULL;
if (force) {
return NULL;
return key;
#ifndef WIN32
return key;
char *ptr;
#if DAV_DEBUG
return err;
return NULL;
while(dp) {
while(ip) {
while(dp) {
while(ip) {
err);
return NULL;
int add_method,
return err;
return NULL;
return err;
return NULL;
case DAV_LOCK_DIRECT:
++offset;
++offset;
return err;
case DAV_LOCK_INDIRECT:
--offset;
return dav_new_error(p,
apr_psprintf(p,
return NULL;
return err;
return NULL;
return supported;
p) != APR_SUCCESS) {
return NULL;
apr_psprintf(p,
goto loaderror;
apr_psprintf(p,
goto loaderror;
return err;
const char *pathname;
return NULL;
NULL);
apr_psprintf(p,
return NULL;
apr_psprintf(p,
pathname));
apr_psprintf(p,
return err;
const char *filename,
char *scan;
const char *scanend;
int dirty = 0;
return err;
if (dirty) {
return err;
return NULL;
/* Note: used by dav_fs_repos.c */
const char *dirpath;
const char *dirpath;
const char *fname;
return NULL;
return err;
#ifndef WIN32
return err;
return err;
return err;
return NULL;
key,
NULL);
return NULL;
int calltype,
#if DAV_DEBUG
return err;
return err;
return NULL;
int partial_ok,
return err;
return NULL;
if (partial_ok) {
return err;
return NULL;
return NULL;
int *locks_present)
*locks_present = 0;
return err;
return NULL;
return NULL;
int make_indirect,
return err;
if (make_indirect) {
return err;
return err;
return NULL;
return err;
if (dprev)
if (iprev)
return err;
return err;
return NULL;
int dirty = 0;
return dirty;
int dirty = 0;
return err;
if (dirty
return err;
return err;
return err;
return NULL;