1 /* $NetBSD: ckckp.c,v 1.5 2006/07/21 00:29:23 perseant Exp $ */
4 * Copyright (c) 2006 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/param.h>
37 #include <sys/mount.h>
38 #include <ufs/ufs/dinode.h>
39 #include <ufs/lfs/lfs.h>
41 int main(int argc
, char **argv
)
44 char cmd
[BUFSIZ
], s
[BUFSIZ
];
49 errx(1, "usage: %s <fs-root> <raw-dev> <save-filename> "
50 "<work-filename>\n", argv
[0]);
52 fd
= open(argv
[1], 0, 0);
56 /* Give the writer a head start */
59 /* Loop forever calling LFCNWRAP{STOP,GO} */
62 printf("Waiting until fs wraps\n");
63 fcntl(fd
, LFCNWRAPSTOP
, &dowait
);
66 * When the fcntl exits, the wrap is about to occur (but
67 * is waiting for the signal to go). Call our mass-check
68 * script, and if all is well, continue. The output
69 * of the script should end with a line that begins with a
70 * numeric code: zero for okay, nonzero for a failure.
72 printf("Verifying all checkpoints from s/n %d\n", sno
);
73 sprintf(cmd
, "./check-all %s %s %s %d", argv
[2], argv
[3],
77 while(fgets(s
, BUFSIZ
, pp
) != NULL
)
80 printf("No checkpoints found or script exited\n");
83 sscanf(s
, "%d %d", &e
, &sno
);
85 printf("Script exited with error code %d\n", e
);
91 printf("Waiting until fs continues\n");
92 fcntl(fd
, LFCNWRAPGO
, &dowait
);