显示标签为“minix”的博文。显示所有博文
显示标签为“minix”的博文。显示所有博文

2009年3月31日星期二

My a small Shell.

/* You can see here */
/* a simple shell */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <string.h>
#include <errno.h>

#define SHELL_NAME "sh1"
#define PROMPT_ENVIRONMENT_VARIABLE "PROMPT"

char *prompt;

int main(int argc,char **argv)
{
char cmd[80];
int statval;

/*Dtermine prompt value.*/
if((prompt=getenv(PROMPT_ENVIRONMENT_VARIABLE))==NULL)
prompt=SHELL_NAME":";

/*Process commands until exit,or death by signal.*/
while(1) {
/*Prompt and read a command.*/
printf(prompt);
gets(cmd);

/*Process built-in commands.*/
if(strcasecmp(cmd,"exit")==0)
break;

/*Process non-built-in commands.*/
if(fork()==0) {
execlp(cmd,cmd,NULL);
fprintf(stderr,"%s:Exec%sfailed:%s\n",argv[0],cmd,strerror(errno));
exit(1);
}
wait(&statval);
if(WIFEXITED(statval)) {
if(WEXITSTATUS(statval)) {
fprintf(stderr,"%s:child exited with status %d.\n",argv[0],WEXITSTATUS(statval));
}
}
else {
fprintf(stderr,"%s:child died unexpectedly.\n",argv[0]);
}
}

}

My friend help me modify it, as follows:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <string.h>
#include <errno.h>

#define SHELL_NAME "sh1"
#define SHELL_GETS(var) printf(prompt); gets(var)
#define SHELL_CMD(str) strcasecmp(cmd, str) == 0

char *prompt;

int main(int argc,char **argv)
{
char cmd[80];
int statval;

if(!(prompt = getenv("PROMPT")))
prompt = SHELL_NAME ": ";

while(1) {
SHELL_GETS(cmd);

if (SHELL_CMD("exit"))
break;

if (fork() == 0) {
execlp(cmd, cmd, NULL);
fprintf(stderr, "%s:Exec %sfailed:%s\n", argv[0], cmd, strerror(errno));
exit(1);
}

wait(&statval);

if (WIFEXITED(statval)) {
if (WEXITSTATUS(statval)) {
fprintf(stderr, "%s:child exited with status %d.\n", argv[0], WEXITSTATUS(statval));
}
}
else {
fprintf(stderr, "%s:child died unexpectedly.\n", argv[0]);
}
}

}

2009年3月30日星期一

My application

My name: gaowei
My email: xiyou.gaowei@gmail.com
My IRC nickname: weiwei
My Phone number: 13772035412
My Web page: http://gaoweige.blogspot.com/ 
My group club website: http://www.xiyoulinux.cn/

  I am a junior student in the Computer Network Department at Xi'an Institute of Post and Telecommunications in China.

  I have been using open source software on my computer for three years, and I like it because it helps me complete my work and studies every day.It helps me to learn much about software and computer devices.I can modify them to satisfy my needs.When I learned about operating systems, I wanted to program a small operating system.At the moment,I read a lot of library books and searched a sea of information on the internet. I know the Linux0.01 architecture and how to implement and compile it into my computer. In addition, I not only have some experience with Linux0.11 and Linux2.6.26, but I am also learning Linux2.6.28.So I have a great interest in the kernels of operating system. Of course, I skimmed over the codes of Minix and Free BSD. 

  I know that Minix is an excellent OS and is a new open-source OS designed to be highly reliable, flexible, secure, and what's more,is intended as a teaching tool. I programmed a simple shell and a small File System and wanted to use fewer lines of executable code to implement an OS. So I want to apply to take part in a program concerning the OS project. Then I can only utilise my knowledge, but also share my ideas and skills.

2009年3月28日星期六

install MINIX

Runnig Minix 3 on QEmu

You can download a Minix 3 ISO from the Download page, and set QEmu to install a machine from that ISO.
These instructions are to get MINIX 3 running under qemu 0.10-0-1 under Ubuntu Linux, but it should generally apply to other qemu installations under linux as well. First, use your package manager or other means to install qemu on your host operating system. Under Ubuntu you can use aptitude to install qemu as follows.

[root@localhost VMWARE]# qemu-img create minix.img 2G
Formating 'minix.img', fmt=raw, size=2097152 kB
[root@localhost VMWARE]# qemu -localtime -net user -net nic -m 128 -cdrom minix3_1_3a_ide_r2964.iso -hda minix.img -boot d
Could not open '/dev/kqemu' - QEMU acceleration layer not activated
[root@localhost VMWARE]#qemu -localtime -net user -net nic -m 256 -cdrom minix3_1_3a_ide_r2964.iso -hda minix.img -boot -c

Note:Don't move your *img to other place. If you do it,then it will error and don't boot in qemu for minix.

time