diff options
Diffstat (limited to 'lockfile.h')
-rw-r--r-- | lockfile.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lockfile.h b/lockfile.h index d26ad27b2b..572064939c 100644 --- a/lockfile.h +++ b/lockfile.h @@ -129,11 +129,17 @@ struct lock_file { /* * If a lock is already taken for the file, `die()` with an error * message. If this flag is not specified, trying to lock a file that - * is already locked returns -1 to the caller. + * is already locked silently returns -1 to the caller, or ... */ #define LOCK_DIE_ON_ERROR 1 /* + * ... this flag can be passed instead to return -1 and give the usual + * error message upon an error. + */ +#define LOCK_REPORT_ON_ERROR 4 + +/* * Usually symbolic links in the destination path are resolved. This * means that (1) the lockfile is created by adding ".lock" to the * resolved path, and (2) upon commit, the resolved path is @@ -170,6 +176,14 @@ static inline int hold_lock_file_for_update( } /* + * Return a nonzero value iff `lk` is currently locked. + */ +static inline int is_lock_file_locked(struct lock_file *lk) +{ + return is_tempfile_active(&lk->tempfile); +} + +/* * Append an appropriate error message to `buf` following the failure * of `hold_lock_file_for_update()` to lock `path`. `err` should be the * `errno` set by the failing call. |