1 /* $NetBSD: ex_preserve.c,v 1.3 2014/01/26 21:43:45 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.
13 #include <sys/cdefs.h>
16 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 ";
19 __RCSID("$NetBSD: ex_preserve.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
25 #include <bitstring.h>
31 #include "../common/common.h"
34 * ex_preserve -- :pre[serve]
35 * Push the file to recovery.
37 * PUBLIC: int ex_preserve __P((SCR *, EXCMD *));
40 ex_preserve(SCR
*sp
, EXCMD
*cmdp
)
46 if (!F_ISSET(sp
->ep
, F_RCV_ON
)) {
47 msgq(sp
, M_ERR
, "142|Preservation of this file not possible");
51 /* If recovery not initialized, do so. */
52 if (F_ISSET(sp
->ep
, F_FIRSTMODIFY
) && rcv_init(sp
))
55 /* Force the file to be read in, in case it hasn't yet. */
56 if (db_last(sp
, &lno
))
60 if (rcv_sync(sp
, RCV_SNAPSHOT
))
63 msgq(sp
, M_INFO
, "143|File preserved");
68 * ex_recover -- :rec[over][!] file
71 * PUBLIC: int ex_recover __P((SCR *, EXCMD *));
74 ex_recover(SCR
*sp
, EXCMD
*cmdp
)
83 /* Set the alternate file name. */
84 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
88 * Check for modifications. Autowrite did not historically
91 if (file_m2(sp
, FL_ISSET(cmdp
->iflags
, E_C_FORCE
)))
94 /* Get a file structure for the file. */
95 INT2CHAR(sp
, ap
->bp
, ap
->len
+1, np
, nlen
);
96 if ((frp
= file_add(sp
, np
)) == NULL
)
99 /* Set the recover bit. */
100 F_SET(frp
, FR_RECOVER
);
103 if (file_init(sp
, frp
, NULL
, FS_SETALT
|
104 (FL_ISSET(cmdp
->iflags
, E_C_FORCE
) ? FS_FORCE
: 0)))
107 F_SET(sp
, SC_FSWITCH
);