/*
*
linux/zBoot/piggyback.c
*
* (C) 1993
Hannu Savolainen
*/
/*
* This program
reads the compressed system image from stdin and
*
encapsulates it into an object file written to the
stdout.
*/
//这个程序读取压缩的system映像文件从标准输入然后压缩后写入标准输出
#include
<stdio.h>
#include <unistd.h>
#include
<a.out.h>
//主函数
int main(int argc, char
*argv[])
{
int c, n=0, len=0;
//定义缓冲区
char tmp_buf[512*1024];
//可执行文件头
struct exec obj =
{0x00640107}; /* object header */
//输入的数据和输入的长度
char string_names[] =
{"_input_data\0_input_len\0"};
//标号表,变量名
struct nlist var_names[2] = /* Symbol
table */
{
{
/* _input_data */
(char *)4, 7, 0, 0,
0
},
{ /* _input_len
*/
(char *)16, 7, 0, 0, 0
}
};
len = 0;
//从标准输入中读取数据到缓冲区
while ((n = read(0,
&tmp_buf[len], sizeof(tmp_buf)-len+1)) > 0)
len += n;
//校验读取的长度
if (n==-1)
{
perror("stdin");
exit(-1);
}
if (len >=
sizeof(tmp_buf))
{
fprintf(stderr, "%s: Input too large\n", argv[0]);
exit(-1);
}
//输出长度信息
fprintf(stderr, "Compressed size %d.\n",
len);
/*
* Output object
header
*/
//输出对象头
obj.a_data = len + sizeof(long);
obj.a_syms =
sizeof(var_names);
write(1, (char *)&obj,
sizeof(obj));
/*
* Output data segment
(compressed system & len)
*/
//输出数据段
write(1, tmp_buf, len);
write(1, (char *)&len, sizeof(len));
/*
*
Output symbol table
*/
//输出符号表
var_names[1].n_value = len;
write(1, (char *)&var_names,
sizeof(var_names));
/*
* Output string
table
*/
//输出字符表
len =
sizeof(string_names) + sizeof(len);
write(1, (char
*)&len, sizeof(len));
write(1, string_names,
sizeof(string_names));
exit(0);
}
zboot/piggyback.c
时间: 2024-11-05 16:25:20
zboot/piggyback.c的相关文章
zBoot/Makefile
#上层makefile调用执行make命令,执行的应该是第一个目标allHEAD = head.oSYSTEM = ../tools/zSystem#LD = gcc#TEST = -DTEST_DRIVERzOBJECTS = $(HEAD) inflate.o unzip.o misc.oCFLAGS = -O2 -DSTDC_HEADERS $(TEST)#.c文件编译为.s文件.c.s: $(CC) $(CFLAGS) -S -o $*.s $<#.s文件编译为.o文件.s.o:
zboot/xtract.c
/* * linux/zBoot/xtract.c * * Copyright (C) 1993 Hannu Savolainen * * Extracts the system image and writes it to the stdout. * based on tools/build.c by Linus Torvalds */#include <stdio.h> /* fprintf */#include <string.h>#include &
(寒假集训) Piggyback(最短路)
Piggyback 时间限制: 1 Sec 内存限制: 64 MB提交: 3 解决: 3[提交][状态][讨论版] 题目描述 Bessie and her sister Elsie graze in different fields during the day,and in the evening they both want to walk back to the barn to rest.Being clever bovines, they come up with a plan to
jQuery源码
/*! * jQuery JavaScript Library v1.8.3 * http://jquery.com/ * * Includes Sizzle.js * http://sizzlejs.com/ * * Copyright 2012 jQuery Foundation and other contributors * Released under the MIT license * http://jquery.org/license * * Date: Tue Nov 13 20
3891: [Usaco2014 Dec]Piggy Back
3891: [Usaco2014 Dec]Piggy Back Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 116 Solved: 92[Submit][Status][Discuss] Description Bessie and her sister Elsie graze in different fields during the day, and in the evening they both want to walk back
Ajax、服务器推和双向通信
本文由大丰哥参考自: congdepeng博文http://congdepeng.iteye.com/blog/1169481. stackoverflow问题"What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?"Steve Chambers的答案 gemantic博文http://gemantic.iteye.com/blog/1553385 李刚<疯狂HTML5/CSS3/Javascr
jquery 2.1.0 源码
/*! * jQuery JavaScript Library v2.1.0 * http://jquery.com/ * * Includes Sizzle.js * http://sizzlejs.com/ * * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors * Released under the MIT license * http://jquery.org/license * * Date: 2
boot/setup.S
!! setup.S Copyright (C) 1991, 1992 Linus Torvalds!! setup.s is responsible for getting the system data from the BIOS,! and putting them into the appropriate places in system memory.! both setup.s and system has been loaded by the bootblock.!! This c
ORACLE AWR报告之 log file sync等待事件优化的总结【转自ITPUB】
来自白大师(白鳝)对log file sync等待事件优化的总结,供各位puber们学习参考: 一. log file sync平均等待事件时间超过7ms,如果等待时间过长,说明log write每次写入的时间过长,如果能够优化redo日志文件存储,使之存放在更快的磁盘上,就可以减少这个等待事件的单次等待时间.(RAID 5--> RAID 10) 当无法通过优化redo日志的I/O性能来解决问题,或者优化了redo日志的I/O性能后还是无法达到我们的预期,那么该如何处理呢? 二. 有经验的