lock.h revision 299742
187744Sphantom/* lock.h : internal interface to lock functions
287659Sphantom *
372169Sphantom * ====================================================================
472169Sphantom *    Licensed to the Apache Software Foundation (ASF) under one
572169Sphantom *    or more contributor license agreements.  See the NOTICE file
672169Sphantom *    distributed with this work for additional information
772169Sphantom *    regarding copyright ownership.  The ASF licenses this file
872169Sphantom *    to you under the Apache License, Version 2.0 (the
972169Sphantom *    "License"); you may not use this file except in compliance
1072169Sphantom *    with the License.  You may obtain a copy of the License at
1172169Sphantom *
1272169Sphantom *      http://www.apache.org/licenses/LICENSE-2.0
1372169Sphantom *
1472169Sphantom *    Unless required by applicable law or agreed to in writing,
1572169Sphantom *    software distributed under the License is distributed on an
1672169Sphantom *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1772169Sphantom *    KIND, either express or implied.  See the License for the
1872169Sphantom *    specific language governing permissions and limitations
1972169Sphantom *    under the License.
2072169Sphantom * ====================================================================
2172169Sphantom */
2272169Sphantom
2372169Sphantom#ifndef SVN_LIBSVN_FS_LOCK_H
2472169Sphantom#define SVN_LIBSVN_FS_LOCK_H
2572169Sphantom
2672169Sphantom#include "trail.h"
2772169Sphantom
2872169Sphantom
2987744Sphantom#ifdef __cplusplus
3087744Sphantomextern "C" {
3172169Sphantom#endif /* __cplusplus */
3272169Sphantom
3372169Sphantom
3472169Sphantom
3572169Sphantom/* These functions implement part of the FS loader library's fs
3672169Sphantom   vtables. */
3772169Sphantom
3872169Sphantom/* See svn_fs_lock(), svn_fs_lock_many(). */
3972169Sphantomsvn_error_t *svn_fs_base__lock(svn_fs_t *fs,
4072169Sphantom                               apr_hash_t *targets,
4172169Sphantom                               const char *comment,
4272169Sphantom                               svn_boolean_t is_dav_comment,
4372169Sphantom                               apr_time_t expiration_date,
4472169Sphantom                               svn_boolean_t steal_lock,
4572169Sphantom                               svn_fs_lock_callback_t lock_callback,
4672169Sphantom                               void *lock_baton,
4772169Sphantom                               apr_pool_t *result_pool,
4872169Sphantom                               apr_pool_t *scratch_pool);
4972169Sphantom
5072169Sphantom/* See svn_fs_generate_lock_token(). */
5172169Sphantomsvn_error_t *svn_fs_base__generate_lock_token(const char **token,
5272169Sphantom                                              svn_fs_t *fs,
5372169Sphantom                                              apr_pool_t *pool);
5472169Sphantom
5572169Sphantom/* See svn_fs_unlock(), svn_fs_unlock_many(). */
5672169Sphantomsvn_error_t *svn_fs_base__unlock(svn_fs_t *fs,
5772169Sphantom                                 apr_hash_t *targets,
5872169Sphantom                                 svn_boolean_t break_lock,
5972169Sphantom                                 svn_fs_lock_callback_t lock_callback,
6072169Sphantom                                 void *lock_baton,
6172169Sphantom                                 apr_pool_t *result_pool,
6272169Sphantom                                 apr_pool_t *scratch_pool);
6372169Sphantom
6472169Sphantom/* See svn_fs_get_lock(). */
6572169Sphantomsvn_error_t *svn_fs_base__get_lock(svn_lock_t **lock,
6672169Sphantom                                   svn_fs_t *fs,
6772169Sphantom                                   const char *path,
6872169Sphantom                                   apr_pool_t *pool);
6972169Sphantom
7072169Sphantom/* See svn_fs_get_locks2(). */
7172169Sphantomsvn_error_t *
7272169Sphantomsvn_fs_base__get_locks(svn_fs_t *fs,
7372169Sphantom                       const char *path,
7472169Sphantom                       svn_depth_t depth,
7572169Sphantom                       svn_fs_get_locks_callback_t get_locks_func,
7672169Sphantom                       void *get_locks_baton,
7772169Sphantom                       apr_pool_t *pool);
7872169Sphantom
7972169Sphantom
8072169Sphantom
8172169Sphantom/* These next functions are 'helpers' for internal fs use:
8272169Sphantom   if a fs function's txn_body needs to enforce existing locks, it
8372169Sphantom   should use these routines:
8472169Sphantom*/
8572169Sphantom
8672169Sphantom
8772169Sphantom/* Implements main logic of 'svn_fs_get_lock' (or in this
8872169Sphantom   case, svn_fs_base__get_lock() above.)  See svn_fs.h. */
8972169Sphantomsvn_error_t *
9072169Sphantomsvn_fs_base__get_lock_helper(svn_lock_t **lock_p,
9172169Sphantom                             const char *path,
9272169Sphantom                             trail_t *trail,
9372169Sphantom                             apr_pool_t *pool);
9472169Sphantom
9572169Sphantom
9672169Sphantom/* Examine PATH for existing locks, and check whether they can be
9772169Sphantom   used.  Do all work in the context of TRAIL, using POOL for
9872169Sphantom   temporary allocations.
9972169Sphantom
10072169Sphantom   If no locks are present, return SVN_NO_ERROR.
10172169Sphantom
10272169Sphantom   If PATH is locked (or contains locks "below" it, when RECURSE is
10372169Sphantom   set), then verify that:
10472169Sphantom
10574458Sache      1. a username has been supplied to TRAIL->fs's access-context,
10674458Sache         else return SVN_ERR_FS_NO_USER.
10772169Sphantom
10893032Simp      2. for every lock discovered, the current username in the access
10972169Sphantom         context of TRAIL->fs matches the "owner" of the lock, else
11072169Sphantom         return SVN_ERR_FS_LOCK_OWNER_MISMATCH.
11187744Sphantom
112      3. for every lock discovered, a matching lock token has been
113         passed into TRAIL->fs's access-context, else return
114         SVN_ERR_FS_BAD_LOCK_TOKEN.
115
116   If all three conditions are met, return SVN_NO_ERROR.
117*/
118svn_error_t *svn_fs_base__allow_locked_operation(const char *path,
119                                                 svn_boolean_t recurse,
120                                                 trail_t *trail,
121                                                 apr_pool_t *pool);
122
123#ifdef __cplusplus
124}
125#endif /* __cplusplus */
126
127#endif /* SVN_LIBSVN_FS_LOCK_H */
128