Home | History | Annotate | Line # | Download | only in arch
ews4800mips.c revision 1.1
      1 
      2 #if HAVE_NBTOOL_CONFIG_H
      3 #include "nbtool_config.h"
      4 #endif
      5 
      6 #include <sys/cdefs.h>
      7 #if !defined(__lint)
      8 __RCSID("$NetBSD: ews4800mips.c,v 1.1 2005/12/29 15:32:20 tsutsui Exp $");
      9 #endif	/* !__lint */
     10 
     11 #include <sys/param.h>
     12 #include <unistd.h>
     13 #include <err.h>
     14 #include <stdio.h>
     15 #include "installboot.h"
     16 
     17 struct bbinfo_params ews4800mips_bbparams = {
     18 	EWS4800MIPS_BBINFO_MAGIC,
     19 	EWS4800MIPS_BOOT_BLOCK_OFFSET,
     20 	EWS4800MIPS_BOOT_BLOCK_BLOCKSIZE,
     21 	EWS4800MIPS_BOOT_BLOCK_MAX_SIZE,
     22 	0,
     23 	BBINFO_BIG_ENDIAN,
     24 };
     25 
     26 int
     27 ews4800mips_setboot(ib_params *params)
     28 {
     29 	u_int8_t buf[EWS4800MIPS_BOOT_BLOCK_MAX_SIZE];
     30 	int rv;
     31 
     32 	rv = pread(params->s1fd, buf, sizeof buf, 0);
     33 	if (rv == -1) {
     34 		warn("Reading `%s'", params->stage1);
     35 		return 0;
     36 	} else if (rv != sizeof buf) {
     37 		warnx("Reading `%s' : short read", params->stage1);
     38 		return 0;
     39 	}
     40 
     41 	if (params->flags & IB_NOWRITE)
     42 		return 1;
     43 
     44 	if (params->flags & IB_VERBOSE)
     45 		printf("Writing boot block\n");
     46 
     47 	rv = pwrite(params->fsfd, buf, sizeof buf, 0);
     48 	if (rv == -1) {
     49 		warn("Writing `%s'", params->filesystem);
     50 		return 0;
     51 	} else if (rv != sizeof buf) {
     52 		warnx("Writing `%s': short write", params->filesystem);
     53 		return 0;
     54 	}
     55 
     56 	return 1;
     57 }
     58