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.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
22 #include "../common/common.h"
25 * ex_preserve -- :pre[serve]
26 * Push the file to recovery.
28 * PUBLIC: int ex_preserve(SCR *, EXCMD *);
31 ex_preserve(SCR
*sp
, EXCMD
*cmdp
)
37 if (!F_ISSET(sp
->ep
, F_RCV_ON
)) {
38 msgq(sp
, M_ERR
, "142|Preservation of this file not possible");
42 /* If recovery not initialized, do so. */
43 if (F_ISSET(sp
->ep
, F_FIRSTMODIFY
) && rcv_init(sp
))
46 /* Force the file to be read in, in case it hasn't yet. */
47 if (db_last(sp
, &lno
))
51 if (rcv_sync(sp
, RCV_SNAPSHOT
))
54 msgq(sp
, M_INFO
, "143|File preserved");
59 * ex_recover -- :rec[over][!] file
62 * PUBLIC: int ex_recover(SCR *, EXCMD *);
65 ex_recover(SCR
*sp
, EXCMD
*cmdp
)
74 /* Set the alternate file name. */
75 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
79 * Check for modifications. Autowrite did not historically
82 if (file_m2(sp
, FL_ISSET(cmdp
->iflags
, E_C_FORCE
)))
85 /* Get a file structure for the file. */
86 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
87 if ((frp
= file_add(sp
, np
)) == NULL
)
90 /* Set the recover bit. */
91 F_SET(frp
, FR_RECOVER
);
94 if (file_init(sp
, frp
, NULL
, FS_SETALT
|
95 (FL_ISSET(cmdp
->iflags
, E_C_FORCE
) ? FS_FORCE
: 0)))
98 F_SET(sp
, SC_FSWITCH
);