/*
- $Id: locking.c,v 1.3 2009-10-22 12:35:39 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
This program is free software; you can redistribute it and/or modify
GNU General Public License for more details.
*/
+/*!
+ * @file
+ * Netatalk utility functions
+ */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <fcntl.h>
#include <atalk/util.h>
-/*
- * Function: lock_reg
+/*!
+ * @def read_lock(fd, offset, whence, len)
+ * @brief place read lock on file
+ *
+ * @param fd (r) File descriptor
+ * @param offset (r) byte offset relative to l_whence
+ * @param whence (r) SEEK_SET, SEEK_CUR, SEEK_END
+ * @param len (r) no. of bytes (0 means to EOF)
+ *
+ * @returns 0 on success, -1 on failure with
+ * fcntl return value and errno
+ */
+
+/*!
+ * @def write_lock(fd, offset, whence, len)
+ * @brief place write lock on file
*
- * Purpose: lock a file with fctnl
+ * @param fd (r) File descriptor
+ * @param offset (r) byte offset relative to l_whence
+ * @param whence (r) SEEK_SET, SEEK_CUR, SEEK_END
+ * @param len (r) no. of bytes (0 means to EOF)
*
- * Arguments:
+ * @returns 0 on success, -1 on failure with
+ * fcntl return value and errno
+ */
+
+/*!
+ * @def unlock(fd, offset, whence, len)
+ * @brief unlock a file
+ *
+ * @param fd (r) File descriptor
+ * @param offset (r) byte offset relative to l_whence
+ * @param whence (r) SEEK_SET, SEEK_CUR, SEEK_END
+ * @param len (r) no. of bytes (0 means to EOF)
+ *
+ * @returns 0 on success, -1 on failure with
+ * fcntl return value and errno
+ */
+
+/*!
+ * @brief lock a file with fctnl
*
- * fd (r) File descriptor
- * cmd (r) cmd to fcntl, only F_SETLK is usable here
- * type (r) F_RDLCK, F_WRLCK, F_UNLCK
- * offset (r) byte offset relative to l_whence
- * whence (r) SEEK_SET, SEEK_CUR, SEEK_END
- * len (r) no. of bytes (0 means to EOF)
+ * This function is called via the macros:
+ * read_lock, write_lock, un_lock
*
- * Returns: fcntl return value
+ * @param fd (r) File descriptor
+ * @param cmd (r) cmd to fcntl, only F_SETLK is usable here
+ * @param type (r) F_RDLCK, F_WRLCK, F_UNLCK
+ * @param offset (r) byte offset relative to l_whence
+ * @param whence (r) SEEK_SET, SEEK_CUR, SEEK_END
+ * @param len (r) no. of bytes (0 means to EOF)
*
- * Effects:
+ * @returns 0 on success, -1 on failure with
+ * fcntl return value and errno
*
- * Function called by macros {read|write|un]_lock to ease locking.
+ * @sa read_lock, write_lock, unlock
*/
int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t len)
{