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
[] = "$Id: ex_preserve.c,v 10.14 2000/07/14 14:29:20 skimo Exp $ (Berkeley) $Date: 2000/07/14 14:29:20 $";
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 *));
81 /* Set the alternate file name. */
82 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
86 * Check for modifications. Autowrite did not historically
89 if (file_m2(sp
, FL_ISSET(cmdp
->iflags
, E_C_FORCE
)))
92 /* Get a file structure for the file. */
93 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
94 if ((frp
= file_add(sp
, np
)) == NULL
)
97 /* Set the recover bit. */
98 F_SET(frp
, FR_RECOVER
);
101 if (file_init(sp
, frp
, NULL
, FS_SETALT
|
102 (FL_ISSET(cmdp
->iflags
, E_C_FORCE
) ? FS_FORCE
: 0)))
105 F_SET(sp
, SC_FSWITCH
);