2 * Copyright (c) 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid[] = "@(#)ex_preserve.c 10.12 (Berkeley) 4/27/96";
16 #include <sys/types.h>
17 #include <sys/queue.h>
19 #include <bitstring.h>
25 #include "../common/common.h"
28 * ex_preserve -- :pre[serve]
29 * Push the file to recovery.
31 * PUBLIC: int ex_preserve __P((SCR *, EXCMD *));
42 if (!F_ISSET(sp->ep, F_RCV_ON)) {
43 msgq(sp, M_ERR, "142|Preservation of this file not possible");
47 /* If recovery not initialized, do so. */
48 if (F_ISSET(sp->ep, F_FIRSTMODIFY) && rcv_init(sp))
51 /* Force the file to be read in, in case it hasn't yet. */
52 if (db_last(sp, &lno))
56 if (rcv_sync(sp, RCV_SNAPSHOT))
59 msgq(sp, M_INFO, "143|File preserved");
64 * ex_recover -- :rec[over][!] file
67 * PUBLIC: int ex_recover __P((SCR *, EXCMD *));
79 /* Set the alternate file name. */
80 set_alt_name(sp, ap->bp);
83 * Check for modifications. Autowrite did not historically
86 if (file_m2(sp, FL_ISSET(cmdp->iflags, E_C_FORCE)))
89 /* Get a file structure for the file. */
90 if ((frp = file_add(sp, ap->bp)) == NULL)
93 /* Set the recover bit. */
94 F_SET(frp, FR_RECOVER);
97 if (file_init(sp, frp, NULL, FS_SETALT |
98 (FL_ISSET(cmdp->iflags, E_C_FORCE) ? FS_FORCE : 0)))
101 F_SET(sp, SC_FSWITCH);