資源簡介
哈工大 操作系統 實驗 李治軍 八個實驗 還有從網上其他地方下載的
代碼片段和文件信息
/*
?*??linux/tools/build.c
?*
?*??(C)?1991??Linus?Torvalds
?*/
/*
?*?This?file?builds?a?disk-image?from?three?different?files:
?*
?*?-?bootsect:?max?510?bytes?of?8086?machine?code?loads?the?rest
?*?-?setup:?max?4?sectors?of?8086?machine?code?sets?up?system?parm
?*?-?system:?80386?code?for?actual?system
?*
?*?It?does?some?checking?that?all?files?are?of?the?correct?type?and
?*?just?writes?the?result?to?stdout?removing?headers?and?padding?to
?*?the?right?amount.?It?also?writes?some?system?data?to?stderr.
?*/
/*
?*?Changes?by?tytso?to?allow?root?device?specification
?*/
#include? /*?fprintf?*/
#include?
#include? /*?contains?exit?*/
#include? /*?unistd.h?needs?this?*/
#include?
#include?
#include? /*?contains?read/write?*/
#include?
/*
?*?Changes?by?falcon?to?define?MAJOR?and?MINOR?for?they
?*?are?not?defined?in?current?linux?header?file?linux/fs.hI?copy?it?from
?*?include/linux/fs.h?directly.
?*/
#ifndef?MAJOR
#define?MAJOR(a)?(((unsigned)(a))>>8)
#endif
#ifndef?MINOR
#define?MINOR(a)?((a)&0xff)
#endif
#define?MINIX_HEADER?32
#define?GCC_HEADER?1024
#define?SYS_SIZE?0x3000
/*
?*?Changes?by?falcon?to?let?this?kernel?Image?file?boot
?*?with?a?root?image?file?on?the?first?hardware?device?/dev/hd1?hence?you
?*?should?prepare?a?root?image?file?and?configure?the?bochs?with
?*?the?following?lines(please?set?the?...?as?suitable?info):
?*? ...
?*??????floppya:?1_44=“Image“?status=inserted
?*??????ata0-master:?type=disk?path=“/path/to/rootimage.img“?mode=flat?...
?*??????...
?*/
#define?DEFAULT_MAJOR_ROOT?3
#define?DEFAULT_MINOR_ROOT?1
/*?max?nr?of?sectors?of?setup:?don‘t?change?unless?you?also?change
?*?bootsect?etc?*/
#define?SETUP_SECTS?4
#define?STRINGIFY(x)?#x
void?die(char?*?str)
{
fprintf(stderr“%s\n“str);
exit(1);
}
void?usage(void)
{
die(“Usage:?build?bootsect?setup?system?[rootdev]?[>?image]“);
}
int?main(int?argc?char?**?argv)
{
int?icid;
char?buf[1024];
char?major_root?minor_root;
struct?stat?sb;
if?((argc?!=?4)?&&?(argc?!=?5))
usage();
if?(argc?==?5)?{
if?(strcmp(argv[4]?“FLOPPY“))?{
if?(stat(argv[4]?&sb))?{
perror(argv[4]);
die(“Couldn‘t?stat?root?device.“);
}
major_root?=?MAJOR(sb.st_rdev);
minor_root?=?MINOR(sb.st_rdev);
}?else?{
major_root?=?0;
minor_root?=?0;
}
}?else?{
major_root?=?DEFAULT_MAJOR_ROOT;
minor_root?=?DEFAULT_MINOR_ROOT;
}
fprintf(stderr?“Root?device?is?(%d?%d)\n“?major_root?minor_root);
if?((major_root?!=?2)?&&?(major_root?!=?3)?&&
????(major_root?!=?0))?{
fprintf(stderr?“Illegal?root?device?(major?=?%d)\n“
major_root);
die(“Bad?root?device?---?major?#“);
}
for?(i=0;i if?((id=open(argv[1]O_RDONLY0))<0)
die(“Unable?to?open?‘boot‘“);
if?(read(idbufMINIX_HEADER)?!=?MINIX_HEADER)
die(“Unable?to?read?header?of?‘boot‘“);
if?(((long?*)?buf)[0]!=0x04100301)
die(“Non-Min
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-07?23:15??操作系統\
?????目錄???????????0??2015-07-07?23:15??操作系統\lab1\
?????文件????????5094??2014-10-11?16:16??操作系統\lab1\bootsect.s
?????文件????????5298??2014-10-11?12:04??操作系統\lab1\build.c
?????文件?????????482??2014-10-12?16:11??操作系統\lab1\report.txt
?????文件????????4479??2014-10-12?21:00??操作系統\lab1\setup.s
?????目錄???????????0??2015-07-07?23:15??操作系統\lab2\
?????文件?????????432??2014-10-19?11:11??操作系統\lab2\iam.c
?????文件?????????915??2014-10-19?11:55??操作系統\lab2\report.txt
?????文件????????2657??2014-10-18?23:02??操作系統\lab2\sys.h
?????文件????????5229??2014-10-18?23:02??操作系統\lab2\system_call.s
?????文件????????6462??2014-10-18?23:34??操作系統\lab2\unistd.h
?????文件?????????719??2014-10-19?11:29??操作系統\lab2\who.c
?????文件?????????407??2014-10-19?11:35??操作系統\lab2\whoami.c
?????目錄???????????0??2015-07-07?23:15??操作系統\lab3\
?????文件????????4312??2014-10-22?17:06??操作系統\lab3\exit.c
?????文件????????3846??2014-10-22?17:03??操作系統\lab3\fork.c
?????文件????????5596??2014-10-22?16:58??操作系統\lab3\main.c
?????文件????????1994??2014-10-22?17:48??操作系統\lab3\printk.c
?????文件????????2774??2014-10-26?10:19??操作系統\lab3\process.c
?????文件????????1436??2014-10-26?11:00??操作系統\lab3\report.txt.txt
?????文件????????9240??2014-10-22?17:46??操作系統\lab3\sched.c
?????目錄???????????0??2015-07-07?23:15??操作系統\lab4\
?????文件?????????327??2014-11-09?23:09??操作系統\lab4\report.txt
?????目錄???????????0??2015-07-07?23:15??操作系統\lab4\unti
?????文件????????2292??2014-11-09?22:29??操作系統\lab4\unti
?????文件?????????309??2014-11-09?23:03??操作系統\lab4\unti
?????文件?????????478??2014-11-09?23:14??操作系統\lab4\unti
?????文件????????2762??2014-11-09?19:22??操作系統\lab4\unti
?????文件????????5229??2014-11-09?19:20??操作系統\lab4\unti
?????文件????????6546??2014-11-09?23:01??操作系統\lab4\unti
............此處省略244個文件信息
評論
共有 條評論