1*90221f91SCody Peter Mello /*
2*90221f91SCody Peter Mello  * This file and its contents are supplied under the terms of the
3*90221f91SCody Peter Mello  * Common Development and Distribution License ("CDDL"), version 1.0.
4*90221f91SCody Peter Mello  * You may only use this file in accordance with the terms of version
5*90221f91SCody Peter Mello  * 1.0 of the CDDL.
6*90221f91SCody Peter Mello  *
7*90221f91SCody Peter Mello  * A full copy of the text of the CDDL should have accompanied this
8*90221f91SCody Peter Mello  * source.  A copy of the CDDL is also available via the Internet at
9*90221f91SCody Peter Mello  * http://www.illumos.org/license/CDDL.
10*90221f91SCody Peter Mello  */
11*90221f91SCody Peter Mello 
12*90221f91SCody Peter Mello /*
13*90221f91SCody Peter Mello  * Copyright 2016 Joyent, Inc.
14*90221f91SCody Peter Mello  */
15*90221f91SCody Peter Mello 
16*90221f91SCody Peter Mello #ifndef FLOCK_TEST_UTIL_H
17*90221f91SCody Peter Mello #define	FLOCK_TEST_UTIL_H
18*90221f91SCody Peter Mello 
19*90221f91SCody Peter Mello #include <fcntl.h>
20*90221f91SCody Peter Mello #include <sys/types.h>
21*90221f91SCody Peter Mello 
22*90221f91SCody Peter Mello #define	BAD_ARGS_MESSAGE	"Expected to receive 3 arguments, but found %d."
23*90221f91SCody Peter Mello #define	BAD_MODE_MESSAGE	"Lock mode must be one of " \
24*90221f91SCody Peter Mello 	"\"shared\" or \"exclusive\""
25*90221f91SCody Peter Mello #define	BAD_LOCK_MESSAGE	"Lock style must be one of " \
26*90221f91SCody Peter Mello 	"\"posix\", \"ofd\", or \"exclusive\""
27*90221f91SCody Peter Mello 
28*90221f91SCody Peter Mello typedef enum lock_style {
29*90221f91SCody Peter Mello 	LSTYLE_POSIX,
30*90221f91SCody Peter Mello 	LSTYLE_OFD,
31*90221f91SCody Peter Mello 	LSTYLE_FLOCK,
32*90221f91SCody Peter Mello 	LSTYLE_LAST
33*90221f91SCody Peter Mello } lock_style_t;
34*90221f91SCody Peter Mello 
35*90221f91SCody Peter Mello extern boolean_t	LOG;
36*90221f91SCody Peter Mello 
37*90221f91SCody Peter Mello extern boolean_t	flock_nodata(int);
38*90221f91SCody Peter Mello 
39*90221f91SCody Peter Mello extern void	flock_block(int);
40*90221f91SCody Peter Mello extern void	flock_alert(int);
41*90221f91SCody Peter Mello extern void	flock_log(const char *, ...);
42*90221f91SCody Peter Mello extern void	flock_reinit(struct flock *, int);
43*90221f91SCody Peter Mello 
44*90221f91SCody Peter Mello extern char		*flock_cmdname(int);
45*90221f91SCody Peter Mello extern char		*flock_stylename(lock_style_t);
46*90221f91SCody Peter Mello extern char		*flock_stylestr(lock_style_t);
47*90221f91SCody Peter Mello extern lock_style_t	flock_styleenum(char *);
48*90221f91SCody Peter Mello 
49*90221f91SCody Peter Mello #endif /* FLOCK_TEST_UTIL_H */