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