Merge branch 'mh/safe-create-leading-directories'
Code clean-up and protection against concurrent write access to the ref namespace. * mh/safe-create-leading-directories: rename_tmp_log(): on SCLD_VANISHED, retry rename_tmp_log(): limit the number of remote_empty_directories() attempts rename_tmp_log(): handle a possible mkdir/rmdir race rename_ref(): extract function rename_tmp_log() remove_dir_recurse(): handle disappearing files and directories remove_dir_recurse(): tighten condition for removing unreadable dir lock_ref_sha1_basic(): if locking fails with ENOENT, retry lock_ref_sha1_basic(): on SCLD_VANISHED, retry safe_create_leading_directories(): add new error value SCLD_VANISHED cmd_init_db(): when creating directories, handle errors conservatively safe_create_leading_directories(): introduce enum for return values safe_create_leading_directories(): always restore slash at end of loop safe_create_leading_directories(): split on first of multiple slashes safe_create_leading_directories(): rename local variable safe_create_leading_directories(): add explicit "slash" pointer safe_create_leading_directories(): reduce scope of local variable safe_create_leading_directories(): fix format of "if" chaining
This commit is contained in:
25
cache.h
25
cache.h
@ -737,8 +737,29 @@ enum sharedrepo {
|
||||
};
|
||||
int git_config_perm(const char *var, const char *value);
|
||||
int adjust_shared_perm(const char *path);
|
||||
int safe_create_leading_directories(char *path);
|
||||
int safe_create_leading_directories_const(const char *path);
|
||||
|
||||
/*
|
||||
* Create the directory containing the named path, using care to be
|
||||
* somewhat safe against races. Return one of the scld_error values
|
||||
* to indicate success/failure.
|
||||
*
|
||||
* SCLD_VANISHED indicates that one of the ancestor directories of the
|
||||
* path existed at one point during the function call and then
|
||||
* suddenly vanished, probably because another process pruned the
|
||||
* directory while we were working. To be robust against this kind of
|
||||
* race, callers might want to try invoking the function again when it
|
||||
* returns SCLD_VANISHED.
|
||||
*/
|
||||
enum scld_error {
|
||||
SCLD_OK = 0,
|
||||
SCLD_FAILED = -1,
|
||||
SCLD_PERMS = -2,
|
||||
SCLD_EXISTS = -3,
|
||||
SCLD_VANISHED = -4
|
||||
};
|
||||
enum scld_error safe_create_leading_directories(char *path);
|
||||
enum scld_error safe_create_leading_directories_const(const char *path);
|
||||
|
||||
int mkdir_in_gitdir(const char *path);
|
||||
extern void home_config_paths(char **global, char **xdg, char *file);
|
||||
extern char *expand_user_path(const char *path);
|
||||
|
Reference in New Issue
Block a user