📄 svn_fs.h
字号:
/** * @copyright * ==================================================================== * Copyright (c) 2000-2004 CollabNet. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://subversion.tigris.org/license-1.html. * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * * This software consists of voluntary contributions made by many * individuals. For exact contribution history, see the revision * history and logs, available at http://subversion.tigris.org/. * ==================================================================== * @endcopyright * * @file svn_fs.h * @brief Interface to the Subversion filesystem. */#ifndef SVN_FS_H#define SVN_FS_H#include <apr_pools.h>#include <apr_hash.h>#include <apr_tables.h>#include "svn_types.h"#include "svn_error.h"#include "svn_delta.h"#include "svn_io.h"#ifdef __cplusplusextern "C" {#endif /* __cplusplus *//** * Get libsvn_fs version information. * * @since New in 1.1. */const svn_version_t *svn_fs_version(void);/* Opening and creating filesystems. *//** An object representing a Subversion filesystem. */typedef struct svn_fs_t svn_fs_t;/** * @name Filesystem configuration options * @{ */#define SVN_FS_CONFIG_BDB_TXN_NOSYNC "bdb-txn-nosync"#define SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE "bdb-log-autoremove"/* See also svn_fs_type(). *//** @since New in 1.1. */#define SVN_FS_CONFIG_FS_TYPE "fs-type"/** @since New in 1.1. */#define SVN_FS_TYPE_BDB "bdb"/** @since New in 1.1. */#define SVN_FS_TYPE_FSFS "fsfs"/** Create repository format compatible with Subversion versions * earlier than 1.4. * * @since New in 1.4. */#define SVN_FS_CONFIG_PRE_1_4_COMPATIBLE "pre-1.4-compatible"/** @} *//** * Callers should invoke this function to initialize global state in * the FS library before creating FS objects. If this function is * invoked, no FS objects may be created in another thread at the same * time as this invocation, and the provided @a pool must last longer * than any FS object created subsequently. * * If this function is not called, the FS library will make a best * effort to bootstrap a mutex for protecting data common to FS * objects; however, there is a small window of failure. Also, a * small amount of data will be leaked if the Subversion FS library is * dynamically unloaded. * * If this function is called multiple times before the pool passed to * the first call is destroyed or cleared, the later calls will have * no effect. * * @since New in 1.2. */svn_error_t *svn_fs_initialize(apr_pool_t *pool);/** The type of a warning callback function. @a baton is the value specified * in the call to svn_fs_set_warning_func(); the filesystem passes it through * to the callback. @a err contains the warning message. * * The callback function should not clear the error that is passed to it; * its caller should do that. */typedef void (*svn_fs_warning_callback_t)(void *baton, svn_error_t *err);/** Provide a callback function, @a warning, that @a fs should use to * report (non-fatal) errors. To print an error, the filesystem will call * @a warning, passing it @a warning_baton and the error. * * By default, this is set to a function that will crash the process. * Dumping to @c stderr or <tt>/dev/tty</tt> is not acceptable default * behavior for server processes, since those may both be equivalent to * <tt>/dev/null</tt>. */void svn_fs_set_warning_func(svn_fs_t *fs, svn_fs_warning_callback_t warning, void *warning_baton);/** * Create a new, empty Subversion filesystem, stored in the directory * @a path, and return a pointer to it in @a *fs_p. @a path must not * currently exist, but its parent must exist. If @a fs_config is not * @c NULL, the options it contains modify the behavior of the * filesystem. The interpretation of @a fs_config is specific to the * filesystem back-end. The new filesystem may be closed by * destroying @a pool. * * @note The lifetime of @a fs_config must not be shorter than @a * pool's. It's a good idea to allocate @a fs_config from @a pool or * one of its ancestors. * * If @a fs_config contains a value for @c SVN_FS_CONFIG_FS_TYPE, that * value determines the filesystem type for the new filesystem. * Currently defined values are: * * SVN_FS_TYPE_BDB Berkeley-DB implementation * SVN_FS_TYPE_FSFS Native-filesystem implementation * * If @a fs_config is @c NULL or does not contain a value for * @c SVN_FS_CONFIG_FS_TYPE then the default filesystem type will be used. * This will typically be BDB for version 1.1 and FSFS for later versions, * though the caller should not rely upon any particular default if they * wish to ensure that a filesystem of a specific type is created. * * @since New in 1.1. */svn_error_t *svn_fs_create(svn_fs_t **fs_p, const char *path, apr_hash_t *fs_config, apr_pool_t *pool);/** * Open a Subversion filesystem located in the directory @a path, and * return a pointer to it in @a *fs_p. If @a fs_config is not @c * NULL, the options it contains modify the behavior of the * filesystem. The interpretation of @a fs_config is specific to the * filesystem back-end. The opened filesystem may be closed by * destroying @a pool. * * @note The lifetime of @a fs_config must not be shorter than @a * pool's. It's a good idea to allocate @a fs_config from @a pool or * one of its ancestors. * * Only one thread may operate on any given filesystem object at once. * Two threads may access the same filesystem simultaneously only if * they open separate filesystem objects. * * @note You probably don't want to use this directly. Take a look at * svn_repos_open() instead. * * @since New in 1.1. */svn_error_t *svn_fs_open(svn_fs_t **fs_p, const char *path, apr_hash_t *config, apr_pool_t *pool);/** * Return, in @a *fs_type, a string identifying the back-end type of * the Subversion filesystem located in @a path. Allocate @a *fs_type * in @a pool. * * The string should be equal to one of the @c SVN_FS_TYPE_* defined * constants, unless the filesystem is a new back-end type added in * a later version of Subversion. * * In general, the type should make no difference in the filesystem's * semantics, but there are a few situations (such as backups) where * it might matter. * * @since New in 1.3. */svn_error_t *svn_fs_type(const char **fs_type, const char *path, apr_pool_t *pool);/** * Return the path to @a fs's repository, allocated in @a pool. * @note This is just what was passed to svn_fs_create() or * svn_fs_open() -- might be absolute, might not. * * @since New in 1.1. */const char *svn_fs_path(svn_fs_t *fs, apr_pool_t *pool);/** * Delete the filesystem at @a path. * * @since New in 1.1. */svn_error_t *svn_fs_delete_fs(const char *path, apr_pool_t *pool);/** * Copy a possibly live Subversion filesystem from @a src_path to * @a dest_path. If @a clean is @c TRUE, perform cleanup on the * source filesystem as part of the copy operation; currently, this * means deleting copied, unused logfiles for a Berkeley DB source * filesystem. * * @since New in 1.1. */svn_error_t *svn_fs_hotcopy(const char *src_path, const char *dest_path, svn_boolean_t clean, apr_pool_t *pool);/** Subversion filesystems based on Berkeley DB. * * The following functions are specific to Berkeley DB filesystems. * * @defgroup svn_fs_bdb berkeley db filesystems * @{ *//** Register an error handling function for Berkeley DB error messages. * * @deprecated Provided for backward compatibility with the 1.2 API. * * Despite being first declared deprecated in Subversion 1.3, this API * is redundant in versions 1.1 and 1.2 as well. * * Berkeley DB's error codes are seldom sufficiently informative to allow * adequate troubleshooting. Berkeley DB provides extra messages through * a callback function - if an error occurs, the @a handler will be called * with two strings: an error message prefix, which will be zero, and * an error message. @a handler might print it out, log it somewhere, * etc. * * Subversion 1.1 and later install their own handler internally, and * wrap the messages from Berkeley DB into the standard svn_error_t object, * making any information gained through this interface redundant. * * It is only worth using this function if your program will be used * with Subversion 1.0. * * This function connects to the Berkeley DB @c DBENV->set_errcall interface. * Since that interface supports only a single callback, Subversion's internal * callback is registered with Berkeley DB, and will forward notifications to * a user provided callback after performing its own processing. */svn_error_t *svn_fs_set_berkeley_errcall(svn_fs_t *fs, void (*handler)(const char *errpfx, char *msg));/** Perform any necessary non-catastrophic recovery on a Berkeley * DB-based Subversion filesystem, stored in the environment @a path. * Do any necessary allocation within @a pool. * * After an unexpected server exit, due to a server crash or a system * crash, a Subversion filesystem based on Berkeley DB needs to run * recovery procedures to bring the database back into a consistent * state and release any locks that were held by the deceased process. * The recovery procedures require exclusive access to the database * --- while they execute, no other process or thread may access the * database. * * In a server with multiple worker processes, like Apache, if a * worker process accessing the filesystem dies, you must stop the * other worker processes, and run recovery. Then, the other worker * processes can re-open the database and resume work. * * If the server exited cleanly, there is no need to run recovery, but * there is no harm in it, either, and it take very little time. So * it's a fine idea to run recovery when the server process starts, * before it begins handling any requests. */svn_error_t *svn_fs_berkeley_recover(const char *path, apr_pool_t *pool);/** Set @a *logfiles to an array of <tt>const char *</tt> log file names * of Berkeley DB-based Subversion filesystem. * * If @a only_unused is @c TRUE, set @a *logfiles to an array which * contains only the names of Berkeley DB log files no longer in use * by the filesystem. Otherwise, all log files (used and unused) are * returned. * This function wraps the Berkeley DB 'log_archive' function * called by the db_archive binary. Repository administrators may * want to run this function periodically and delete the unused log * files, as a way of reclaiming disk space. */svn_error_t *svn_fs_berkeley_logfiles(apr_array_header_t **logfiles, const char *path, svn_boolean_t only_unused, apr_pool_t *pool);/** * The following functions are similar to their generic counterparts. * * In Subversion 1.2 and earlier, they only work on Berkeley DB filesystems. * In Subversion 1.3 and later, they perform largely as aliases for their * generic counterparts. * * @defgroup svn_fs_bdb_deprecated berkeley db filesystem compatibility * @{ *//** @deprecated Provided for backward compatibility with the 1.0 API. */svn_fs_t *svn_fs_new(apr_hash_t *fs_config, apr_pool_t *pool);/** @deprecated Provided for backward compatibility with the 1.0 API. */svn_error_t *svn_fs_create_berkeley(svn_fs_t *fs, const char *path);/** @deprecated Provided for backward compatibility with the 1.0 API. */svn_error_t *svn_fs_open_berkeley(svn_fs_t *fs, const char *path);/** @deprecated Provided for backward compatibility with the 1.0 API. */const char *svn_fs_berkeley_path(svn_fs_t *fs, apr_pool_t *pool);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -