X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=common-src%2Famflock.h;h=5f917e2b0d7c03f67c209100d60baaa4c726ecc3;hb=HEAD;hp=75661b277f8d344832faef5c0bde568a458935dd;hpb=d5853102f67d85d8e169f9dbe973ad573306c215;p=debian%2Famanda diff --git a/common-src/amflock.h b/common-src/amflock.h index 75661b2..5f917e2 100644 --- a/common-src/amflock.h +++ b/common-src/amflock.h @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1999 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -30,7 +31,7 @@ * New interface */ -typedef struct file_lock_ { +typedef struct file_lock { /* the entire contents of the locked file */ char *data; size_t len; @@ -77,6 +78,18 @@ void file_lock_free(file_lock *lock); */ int file_lock_lock(file_lock *lock); +/* Lock the file in write or read mode, the file is not read + * + * @param lock: the file_lock object @returns: -1 on error, 0 on success, 1 on + * a busy lock (see above) + */ +int file_lock_lock_wr(file_lock *lock); +int file_lock_lock_rd(file_lock *lock); + +/* Return 1 if the object is already locked + */ +int file_lock_locked(file_lock *lock); + /* Write the given data to the locked file, and reset the file_lock * data member to point to a copy of the new data. This does not unlock * the file.