1 /*	$OpenBSD: landisk_installboot.c,v 1.10 2021/07/20 14:51:56 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2013 Joel Sing <jsing@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <stdlib.h>
20 #include <unistd.h>
21 
22 #include "installboot.h"
23 
24 char	*bootldr;
25 
26 void
27 md_init(void)
28 {
29 	stages = 2;
30 	stage1 = "/usr/mdec/xxboot";
31 	stage2 = "/usr/mdec/boot";
32 
33 	bootldr = "/boot";
34 }
35 
36 void
37 md_loadboot(void)
38 {
39 }
40 
41 void
42 md_prepareboot(int devfd, char *dev)
43 {
44 }
45 
46 void
47 md_installboot(int devfd, char *dev)
48 {
49 	/* XXX - is this necessary? */
50 	sync();
51 
52 	bootldr = fileprefix(root, bootldr);
53 	if (bootldr == NULL)
54 		exit(1);
55 	if (!nowrite)
56 		if (filecopy(stage2, bootldr) == -1)
57 			exit(1);
58 
59 	/* Write bootblock into the superblock. */
60 	bootstrap(devfd, dev, stage1);
61 }
62