installboot.c File Reference

#include <stdio.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <a.out.h>
#include <minix/config.h>
#include <minix/const.h>
#include <minix/partition.h>
#include <minix/u64.h>
#include "rawfs.h"
#include "image.h"

Include dependency graph for installboot.c:

Go to the source code of this file.

Defines

#define nil   0
#define _POSIX_SOURCE   1
#define _MINIX   1
#define BOOTBLOCK   0
#define SECTOR_SIZE   512
#define RATIO(b)   ((b)/SECTOR_SIZE)
#define SIGNATURE   0xAA55
#define BOOT_MAX   64
#define SIGPOS   510
#define PARTPOS   446
#define between(a, c, z)   ((unsigned) ((c) - (a)) <= ((z) - (a)))
#define control(c)   between('\0', (c), '\37')
#define BOOT_BLOCK_SIZE   1024
#define align(n)   (((n) + ((SECTOR_SIZE) - 1)) & ~((SECTOR_SIZE) - 1))

Enumerations

enum  howto { FS, BOOT }

Functions

void report (char *label)
void fatal (char *label)
char * basename (char *name)
void bread (FILE *f, char *name, void *buf, size_t len)
void bwrite (FILE *f, char *name, void *buf, size_t len)
void read_header (int talk, char *proc, FILE *procf, struct image_header *ihdr)
void padimage (char *image, FILE *imagef, int n)
void copyexec (char *proc, FILE *procf, char *image, FILE *imagef, long n)
void make_image (char *image, char **procv)
void extractexec (FILE *imagef, char *image, FILE *procf, char *proc, long count, off_t *alen)
void extract_image (char *image)
void readblock (off_t blk, char *buf, int block_size)
void writeblock (off_t blk, char *buf, int block_size)
int raw_install (char *file, off_t *start, off_t *len, int block_size)
void make_bootable (enum howto how, char *device, char *bootblock, char *bootcode, char **imagev)
void install_master (char *device, char *masterboot, char **guide)
void usage (void)
int isoption (char *option, char *test)
int main (int argc, char **argv)

Variables

long total_text = 0
long total_data = 0
long total_bss = 0
int making_image = 0
int rawfd
char * rawdev


Define Documentation

#define _MINIX   1
 

Definition at line 8 of file installboot.c.

#define _POSIX_SOURCE   1
 

Definition at line 7 of file installboot.c.

#define align n   )     (((n) + ((SECTOR_SIZE) - 1)) & ~((SECTOR_SIZE) - 1))
 

Definition at line 172 of file installboot.c.

#define between a,
c,
z   )     ((unsigned) ((c) - (a)) <= ((z) - (a)))
 

Definition at line 38 of file installboot.c.

#define BOOT_BLOCK_SIZE   1024
 

Definition at line 41 of file installboot.c.

Referenced by install_master(), and raw_install().

#define BOOT_MAX   64
 

Definition at line 32 of file installboot.c.

Referenced by make_bootable().

#define BOOTBLOCK   0
 

Definition at line 28 of file installboot.c.

Referenced by install_master().

#define control c   )     between('\0', (c), '\37')
 

Definition at line 39 of file installboot.c.

Referenced by print().

#define nil   0
 

Definition at line 6 of file installboot.c.

#define PARTPOS   446
 

Definition at line 34 of file installboot.c.

Referenced by install_master().

#define RATIO b   )     ((b)/SECTOR_SIZE)
 

Definition at line 30 of file installboot.c.

#define SECTOR_SIZE   512
 

Definition at line 29 of file installboot.c.

#define SIGNATURE   0xAA55
 

Definition at line 31 of file installboot.c.

#define SIGPOS   510
 

Definition at line 33 of file installboot.c.

Referenced by install_master().


Enumeration Type Documentation

enum howto
 

Enumerator:
FS 
BOOT 

Definition at line 417 of file installboot.c.


Function Documentation

char* basename char *  name  ) 
 

Definition at line 55 of file installboot.c.

References base, bp, IM_NAME_MAX, nil, p, strchr, and strrchr().

void bread FILE f,
char *  name,
void *  buf,
size_t  len
 

Definition at line 78 of file installboot.c.

References exit(), f, fatal(), ferror, fprintf(), fread(), and stderr.

Referenced by add_file(), copy(), extract_image(), extractexec(), install_master(), mread(), read_header(), and skip_entry().

void bwrite FILE f,
char *  name,
void *  buf,
size_t  len
 

Definition at line 88 of file installboot.c.

References f, fatal(), and fwrite().

Referenced by extract_image(), extractexec(), make_image(), and mwrite().

void copyexec char *  proc,
FILE procf,
char *  image,
FILE imagef,
long  n
 

Definition at line 174 of file installboot.c.

References align, c, EOF, exit(), fatal(), ferror, fprintf(), getc, pad, padimage(), putc, and stderr.

Referenced by make_image().

void extract_image char *  image  ) 
 

Definition at line 284 of file installboot.c.

References exec::a_data, exec::a_flags, exec::a_hdrlen, A_PAL, A_SEP, exec::a_text, bread(), bwrite(), EOF, extractexec(), fatal(), fclose(), fopen(), memcpy(), nil, read_header(), S_ISREG, SECTOR_SIZE, st, stat::st_mode, stat::st_size, and stat.

Referenced by main().

void extractexec FILE imagef,
char *  image,
FILE procf,
char *  proc,
long  count,
off_t alen
 

Definition at line 268 of file installboot.c.

References bread(), bwrite(), and SECTOR_SIZE.

Referenced by extract_image().

static void fatal char *  label  ) 
 

Definition at line 49 of file installboot.c.

Referenced by ack_emit_init(), ack_printf(), ack_putchar(), addpath(), advertize(), alloc(), allocate(), bread(), bwrite(), cachedhcp(), check(), check_ln(), check_mknod(), check_rm(), checkarg(), checkdiff(), checkstate(), chkdev(), chkinode(), chksuper(), chksymlinkzone(), chktree(), cmp(), commitpool(), copy(), copyexec(), copyout(), counterror(), delete_all(), devclose(), devio(), devopen(), devread(), devwrite(), do_ocnf(), do_opasc(), do_open(), do_set(), doexp(), dyndep(), expand(), extract_image(), fill_iftab(), filter(), find_exist(), finddev(), flush(), fmode(), geometry(), get_prog(), getcommand(), getdesc(), getdevices(), getline(), getstr(), getsuper(), gnu_emit_init(), gnu_printf(), gnu_putchar(), haunt(), ichk(), implmacros(), init(), init_config(), install_master(), job(), job_connect(), job_read_query(), job_read_reply(), job_read_udp(), job_setup_connect(), job_setup_listen(), job_write_query(), job_write_reply(), joberr(), keyboard(), keypress(), lock_device(), lp(), main(), make_bootable(), make_image(), Malloc(), modtime(), named_probe(), nametoipaddr(), new_state(), newcmd(), newdep(), newline(), newname(), number(), openpool(), pack_vector(), padimage(), printdata(), range(), raw_install(), read_conf(), read_header(), readblock(), readpool(), readtc(), restore_ttyflags(), save_ttyflags(), secondary(), send(), send_brk(), set_goto_map(), set_ipconf(), setDFmacro(), show_all(), show_one(), simple(), spoolerr(), strrealloc(), time_functions(), tok_init(), tty_raw(), video_base(), work(), write_table(), writeblock(), and writepool().

void install_master char *  device,
char *  masterboot,
char **  guide
 

Definition at line 687 of file installboot.c.

References _MAX_BLOCK_SIZE, exec::a_data, exec::a_text, partition::base, between, BOOT_BLOCK_SIZE, BOOTBLOCK, bread(), DIOCGETP, div64u(), exit(), fatal(), fileno(), fopen(), fprintf(), fstat, geometry, i, ioctl, memcpy(), memset(), nil, O_RDONLY, O_RDWR, offset, open, PARTPOS, image_header::process, read_header(), readblock(), S_ISBLK, SECTOR_SIZE, SIGNATURE, SIGPOS, size, st, stat::st_mode, stderr, and writeblock().

Referenced by main().

int isoption char *  option,
char *  test
 

Definition at line 795 of file installboot.c.

References strcmp, and strlen().

Referenced by main().

int main int  argc,
char **  argv
 

Definition at line 807 of file installboot.c.

References exit(), extract_image(), FS, install_master(), isoption(), make_bootable(), make_image(), and usage.

void make_bootable enum howto  how,
char *  device,
char *  bootblock,
char *  bootcode,
char **  imagev
 

Definition at line 419 of file installboot.c.

References _MAX_BLOCK_SIZE, addr, address(), block_size, BOOT_MAX, count, dummy, exit(), fatal(), fflush(), fprintf(), fputc(), FS, image, labels, O_RDWR, open, pos, printf, r_super(), s, sector, sleep, st, stderr, and stdout.

Referenced by main().

void make_image char *  image,
char **  procv
 

Definition at line 195 of file installboot.c.

References exec::a_data, exec::a_flags, exec::a_hdrlen, A_NSYM, A_PAL, A_SEP, exec::a_syms, exec::a_text, bwrite(), copyexec(), EISDIR, errno, fatal(), fclose(), fopen(), making_image, nil, padimage(), image_header::process, read_header(), rewind(), S_ISREG, SECTOR_SIZE, st, stat::st_mode, stat, and strchr.

Referenced by main().

void padimage char *  image,
FILE imagef,
int  n
 

Definition at line 163 of file installboot.c.

References EOF, fatal(), and putc.

Referenced by copyexec(), and make_image().

int raw_install char *  file,
off_t start,
off_t len,
int  block_size
 

Definition at line 362 of file installboot.c.

References _MAX_BLOCK_SIZE, banner, BOOT_BLOCK_SIZE, cv64ul(), DIOCGETP, entry, f, fatal(), fclose(), ferror, file, fopen(), fprintf(), fread(), ioctl, nil, off, printf, RATIO, SECTOR_SIZE, entry::size, stderr, and writeblock().

void read_header int  talk,
char *  proc,
FILE procf,
struct image_header ihdr
 

Definition at line 96 of file installboot.c.

References exec::a_bss, exec::a_cpu, exec::a_data, exec::a_flags, exec::a_hdrlen, A_I8086, A_MINHDR, A_SEP, exec::a_text, BADMAG, banner, basename, bread(), data, exit(), fatal(), ferror, fprintf(), fread(), IM_NAME_MAX, memset(), n, nil, printf, image_header::process, stderr, strncpy(), total_bss, total_data, and total_text.

Referenced by do_exec(), extract_image(), install_master(), make_image(), nm(), and strip().

void readblock off_t  blk,
char *  buf,
int  block_size
 

Definition at line 339 of file installboot.c.

References exit(), fatal(), fprintf(), lseek, n, read, SEEK_SET, and stderr.

static void report char *  label  ) 
 

Definition at line 43 of file installboot.c.

void usage void   ) 
 

Definition at line 784 of file installboot.c.

void writeblock off_t  blk,
char *  buf,
int  block_size
 

Definition at line 354 of file installboot.c.

References fatal(), lseek, SEEK_SET, and write.

Referenced by install_master(), and raw_install().


Variable Documentation

int making_image = 0
 

Definition at line 94 of file installboot.c.

Referenced by make_image().

char* rawdev
 

Definition at line 337 of file installboot.c.

int rawfd
 

Definition at line 336 of file installboot.c.

long total_bss = 0
 

Definition at line 93 of file installboot.c.

Referenced by read_header().

long total_data = 0
 

Definition at line 93 of file installboot.c.

Referenced by read_header().

long total_text = 0
 

Definition at line 93 of file installboot.c.

Referenced by read_header().


Generated on Fri Apr 14 22:57:40 2006 for minix by  doxygen 1.4.6