1 /* $OpenBSD: exf.h,v 1.6 2022/02/20 19:45:51 tb 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 dev_t mdev; /* Device. */ 39 ino_t minode; /* Inode. */ 40 struct timespec mtim; /* Last modification time. */ 41 42 int fcntl_fd; /* Fcntl locking fd; see exf.c. */ 43 44 /* 45 * Recovery in general, and these fields specifically, are described 46 * in recover.c. 47 */ 48 #define RCV_PERIOD 120 /* Sync every two minutes. */ 49 char *rcv_path; /* Recover file name. */ 50 char *rcv_mpath; /* Recover mail file name. */ 51 int rcv_fd; /* Locked mail file descriptor. */ 52 53 #define F_DEVSET 0x001 /* mdev/minode fields initialized. */ 54 #define F_FIRSTMODIFY 0x002 /* File not yet modified. */ 55 #define F_MODIFIED 0x004 /* File is currently dirty. */ 56 #define F_MULTILOCK 0x008 /* Multiple processes running, lock. */ 57 #define F_NOLOG 0x010 /* Logging turned off. */ 58 #define F_RCV_NORM 0x020 /* Don't delete recovery files. */ 59 #define F_RCV_ON 0x040 /* Recovery is possible. */ 60 #define F_UNDO 0x080 /* No change since last undo. */ 61 #define F_RCV_SYNC 0x100 /* Recovery file sync needed. */ 62 u_int16_t flags; 63 }; 64 65 /* Flags to db_get(). */ 66 #define DBG_FATAL 0x001 /* If DNE, error message. */ 67 #define DBG_NOCACHE 0x002 /* Ignore the front-end cache. */ 68 69 /* Flags to file_init() and file_write(). */ 70 #define FS_ALL 0x001 /* Write the entire file. */ 71 #define FS_APPEND 0x002 /* Append to the file. */ 72 #define FS_FORCE 0x004 /* Force is set. */ 73 #define FS_OPENERR 0x008 /* Open failed, try it again. */ 74 #define FS_POSSIBLE 0x010 /* Force could have been set. */ 75 #define FS_SETALT 0x020 /* Set alternate file name. */ 76 77 /* Flags to rcv_sync(). */ 78 #define RCV_EMAIL 0x01 /* Send the user email, IFF file modified. */ 79 #define RCV_ENDSESSION 0x02 /* End the file session. */ 80 #define RCV_PRESERVE 0x04 /* Preserve backup file, IFF file modified. */ 81 #define RCV_SNAPSHOT 0x08 /* Snapshot the recovery, and send email. */ 82