1 /* $OpenBSD: landisk_installboot.c,v 1.9 2018/09/01 16:55:29 krw 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_installboot(int devfd, char *dev) 43 { 44 /* XXX - is this necessary? */ 45 sync(); 46 47 bootldr = fileprefix(root, bootldr); 48 if (bootldr == NULL) 49 exit(1); 50 if (!nowrite) 51 if (filecopy(stage2, bootldr) == -1) 52 exit(1); 53 54 /* Write bootblock into the superblock. */ 55 bootstrap(devfd, dev, stage1); 56 } 57