Search     or:     and:
 LINUX 
 Language 
 Kernel 
 Package 
 Book 
 Test 
 OS 
 Forum 
 iakovlev.org 
      Languages 
      Kernels 
      Packages 
      Books 
      Tests 
      OS 
      Forum 
      Математика 
NEWS
Последние статьи :
  Rust 07.11   
  Go 25.12   
  EXT4 10.11   
  FS benchmark 15.09   
  Сетунь 23.07   
  Trees 25.06   
  Apache 03.02   
  SQL 30.07   
  JFS 10.06   
  B-trees 01.06   
 
TOP 20
 Go Web ...1117 
 Secure Programming for Li...320 
 B-trees...251 
 Ethreal 1...182 
 Advanced Bash Scripting G...174 
 Steve Pate 3...139 
 Стивенс 9...137 
 Ethreal 3...135 
 Daniel Bovet 2...134 
 C++ Faq 3...134 
 Cluster 4...127 
 C++ Patterns 1...125 
 Mod_perl 1...125 
 Robert Love 5...123 
 2.6-> Kernel 2.6.19...122 
 Advanced Bash Scripting G...122 
 Rodriguez 8...121 
 Intel 386...121 
 Rodriguez 3...120 
 B.Blunden 1...119 
 
  01.08.2019 : 2762444 посещений 

www.iakovlev.org
#include < stdio.h>	/* fprintf */
#include < stdlib.h>	/* contains exit */
#include < sys/types.h>	/* unistd.h needs this */
#include < unistd.h>	/* contains read/write */
#include < fcntl.h>

#define MINIX_HEADER 32
#define GCC_HEADER 1024

void die(char * str)
{
	fprintf(stderr,"%s\n",str);
	exit(1);
}

void usage(void)
{
	die("Usage: build boot system [> image]");
}

int main(int argc, char ** argv)
{
	int i,c,id;
	char buf[1024];

	if (argc != 3)
		usage();
	for (i=0;i510)
		die("Boot block may not exceed 510 bytes");
	buf[510]=0x55;
	buf[511]=0xAA;
	i=write(1,buf,512);
	if (i!=512)
		die("Write call failed");
	close (id);
	
	if ((id=open(argv[2],O_RDONLY,0))<0)
		die("Unable to open 'system'");
	if (read(id,buf,GCC_HEADER) != GCC_HEADER)
		die("Unable to read header of 'system'");
	if (((long *) buf)[5] != 0)
		die("Non-GCC header of 'system'");
	for (i=0 ; (c=read(id,buf,sizeof buf))>0 ; i+=c )
		if (write(1,buf,c)!=c)
			die("Write call failed");
	close(id);
	fprintf(stderr,"System %d bytes.\n",i);
	return(0);
}