1 /*	$OpenBSD: exf.h,v 1.4 2001/01/29 01:58:29 niklas Exp $	*/
2 
3 /*-
4  * Copyright (c) 1992, 1993, 1994
5  *	The Regents of the University of California.  All rights reserved.
6  * Copyright (c) 1992, 1993, 1994, 1995, 1996
7  *	Keith Bostic.  All rights reserved.
8  *
9  * See the LICENSE file for redistribution information.
10  *
11  *	@(#)exf.h	10.7 (Berkeley) 7/9/96
12  */
13 					/* Undo direction. */
14 /*
15  * exf --
16  *	The file structure.
17  */
18 struct _exf {
19 	int	 refcnt;		/* Reference count. */
20 
21 					/* Underlying database state. */
22 	DB	*db;			/* File db structure. */
23 	char	*c_lp;			/* Cached line. */
24 	size_t	 c_len;			/* Cached line length. */
25 	recno_t	 c_lno;			/* Cached line number. */
26 	recno_t	 c_nlines;		/* Cached lines in the file. */
27 
28 	DB	*log;			/* Log db structure. */
29 	char	*l_lp;			/* Log buffer. */
30 	size_t	 l_len;			/* Log buffer length. */
31 	recno_t	 l_high;		/* Log last + 1 record number. */
32 	recno_t	 l_cur;			/* Log current record number. */
33 	MARK	 l_cursor;		/* Log cursor position. */
34 	dir_t	 lundo;			/* Last undo direction. */
35 
36 	LIST_HEAD(_markh, _lmark) marks;/* Linked list of file MARK's. */
37 
38 	/*
39 	 * XXX
40 	 * Mtime should be a struct timespec, but time_t is more portable.
41 	 */
42 	dev_t	 mdev;			/* Device. */
43 	ino_t	 minode;		/* Inode. */
44 	time_t	 mtime;			/* Last modification time. */
45 
46 	int	 fcntl_fd;		/* Fcntl locking fd; see exf.c. */
47 
48 	/*
49 	 * Recovery in general, and these fields specifically, are described
50 	 * in recover.c.
51 	 */
52 #define	RCV_PERIOD	120		/* Sync every two minutes. */
53 	char	*rcv_path;		/* Recover file name. */
54 	char	*rcv_mpath;		/* Recover mail file name. */
55 	int	 rcv_fd;		/* Locked mail file descriptor. */
56 
57 #define	F_DEVSET	0x001		/* mdev/minode fields initialized. */
58 #define	F_FIRSTMODIFY	0x002		/* File not yet modified. */
59 #define	F_MODIFIED	0x004		/* File is currently dirty. */
60 #define	F_MULTILOCK	0x008		/* Multiple processes running, lock. */
61 #define	F_NOLOG		0x010		/* Logging turned off. */
62 #define	F_RCV_NORM	0x020		/* Don't delete recovery files. */
63 #define	F_RCV_ON	0x040		/* Recovery is possible. */
64 #define	F_UNDO		0x080		/* No change since last undo. */
65 	u_int8_t flags;
66 };
67 
68 /* Flags to db_get(). */
69 #define	DBG_FATAL	0x001	/* If DNE, error message. */
70 #define	DBG_NOCACHE	0x002	/* Ignore the front-end cache. */
71 
72 /* Flags to file_init() and file_write(). */
73 #define	FS_ALL		0x001	/* Write the entire file. */
74 #define	FS_APPEND	0x002	/* Append to the file. */
75 #define	FS_FORCE	0x004	/* Force is set. */
76 #define	FS_OPENERR	0x008	/* Open failed, try it again. */
77 #define	FS_POSSIBLE	0x010	/* Force could have been set. */
78 #define	FS_SETALT	0x020	/* Set alternate file name. */
79 
80 /* Flags to rcv_sync(). */
81 #define	RCV_EMAIL	0x01	/* Send the user email, IFF file modified. */
82 #define	RCV_ENDSESSION	0x02	/* End the file session. */
83 #define	RCV_PRESERVE	0x04	/* Preserve backup file, IFF file modified. */
84 #define	RCV_SNAPSHOT	0x08	/* Snapshot the recovery, and send email. */
85