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.15 2001/06/25 15:19:18 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:18 $";
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 *));
34 ex_preserve(SCR
*sp
, EXCMD
*cmdp
)
40 if (!F_ISSET(sp
->ep
, F_RCV_ON
)) {
41 msgq(sp
, M_ERR
, "142|Preservation of this file not possible");
45 /* If recovery not initialized, do so. */
46 if (F_ISSET(sp
->ep
, F_FIRSTMODIFY
) && rcv_init(sp
))
49 /* Force the file to be read in, in case it hasn't yet. */
50 if (db_last(sp
, &lno
))
54 if (rcv_sync(sp
, RCV_SNAPSHOT
))
57 msgq(sp
, M_INFO
, "143|File preserved");
62 * ex_recover -- :rec[over][!] file
65 * PUBLIC: int ex_recover __P((SCR *, EXCMD *));
68 ex_recover(SCR
*sp
, EXCMD
*cmdp
)
77 /* Set the alternate file name. */
78 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
82 * Check for modifications. Autowrite did not historically
85 if (file_m2(sp
, FL_ISSET(cmdp
->iflags
, E_C_FORCE
)))
88 /* Get a file structure for the file. */
89 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
90 if ((frp
= file_add(sp
, np
)) == 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
);