1 /* $NetBSD: ex_preserve.c,v 1.2 2013/11/22 15:52:05 christos Exp $ */
3 * Copyright (c) 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
14 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 ";
17 #include <sys/types.h>
18 #include <sys/queue.h>
20 #include <bitstring.h>
26 #include "../common/common.h"
29 * ex_preserve -- :pre[serve]
30 * Push the file to recovery.
32 * PUBLIC: int ex_preserve __P((SCR *, EXCMD *));
35 ex_preserve(SCR
*sp
, EXCMD
*cmdp
)
41 if (!F_ISSET(sp
->ep
, F_RCV_ON
)) {
42 msgq(sp
, M_ERR
, "142|Preservation of this file not possible");
46 /* If recovery not initialized, do so. */
47 if (F_ISSET(sp
->ep
, F_FIRSTMODIFY
) && rcv_init(sp
))
50 /* Force the file to be read in, in case it hasn't yet. */
51 if (db_last(sp
, &lno
))
55 if (rcv_sync(sp
, RCV_SNAPSHOT
))
58 msgq(sp
, M_INFO
, "143|File preserved");
63 * ex_recover -- :rec[over][!] file
66 * PUBLIC: int ex_recover __P((SCR *, EXCMD *));
69 ex_recover(SCR
*sp
, EXCMD
*cmdp
)
78 /* Set the alternate file name. */
79 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
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 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
91 if ((frp
= file_add(sp
, np
)) == NULL
)
94 /* Set the recover bit. */
95 F_SET(frp
, FR_RECOVER
);
98 if (file_init(sp
, frp
, NULL
, FS_SETALT
|
99 (FL_ISSET(cmdp
->iflags
, E_C_FORCE
) ? FS_FORCE
: 0)))
102 F_SET(sp
, SC_FSWITCH
);