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