91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 23KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-14
  • 語言: C/C++
  • 標簽: shell??c++??編程??

資源簡介

一個簡單的shell實現,包括了shell所以的基本功能,容易理解,適合初學者下載學習。

資源截圖

代碼片段和文件信息

/*?syscalls.c
?*? Nachos?system?call?interface.??These?are?the?enveloped?Nachos?kernel?
?*??????operations?that?can?be?invoked?from?user?programs.
?*??????Each?NachOS?system?call?is?translated?to?an?apropriate?LIBC?call.?
?*??????Hopefully?this?works?on?MacOS?X?*nix?and?Windows
?*/


#include?“nachos_syscall.h“

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?

#include?
#include?
#include?



#ifdef?HAVE_CONFIG_H
#include?“config.h“
#endif

#define?SHELL?“/bin/sh“

/*
?*?The?system?call?interface.??These?are?the?operations?the?Nachos
?*?kernel?needs?to?support?to?be?able?to?run?user?programs.
?*/

/*?Stop?Nachos?and?print?out?performance?stats?*/
void?Halt()
{
Exit(0);
}
?
?
/*
?*?Add?the?two?operants?and?return?the?result
?*/?

int?Add(int?op1?int?op2)
{?
return?op1?+?op2;
}


/*?This?user?program?is?done?(status?=?0?means?exited?normally).?*/
void?Exit(int?status)
{
exit(status);
}

/*?Address?space?control?operations:?Exit?Exec?Execv?and?Join?*/

/*?Run?the?specified?executable?with?no?args?*/
/*?This?can?be?implemented?as?a?call?to?ExecV.
?*/?
SpaceId?Exec(char*?exec_name)
{
????pid_t?child;
????child?=?vfork();
????if(child?==?0)
????{
execl?(SHELL?SHELL?“-c“?exec_name?NULL);
_exit?(EXIT_FAILURE);
????}
????else?if(child? return?EPERM;
????return?(SpaceId)?child;
}


/*?
?*?Run?the?executable?stored?in?the?Nachos?file?“argv[0]“?with
?*?parameters?stored?in?argv[1..argc-1]?and?return?the?
?*?address?space?identifier
?*?For?this?the?incoming?string?has?to?be?seperated?by?replacing?“?“?
?*?with?“\n“?and?building?the?appropriate?pointer?structure?argv.
?*/
SpaceId?ExecV(int?argc?char*?argv[])
{
????pid_t?child;
????child?=?vfork();
????if(child?==?0){
execl?(SHELL?SHELL?“-c“?argv?NULL);
_exit?(EXIT_FAILURE);
????}
????else?if(child? return?EPERM;
????return?(SpaceId)?child;
}

/*?Only?return?once?the?user?program?“id“?has?finished.??
?*?Return?the?exit?status.
?*/
int?Join(SpaceId?id)
{
????return?waitpid((pid_t)?id?(int*)?0?0);
}
?

/*?File?system?operations:?Create?Remove?Open?Read?Write?Close
?*?These?functions?are?patterned?after?UNIX?--?files?represent
?*?both?files?*and*?hardware?I/O?devices.
?*
?*?Note?that?the?Nachos?file?system?has?a?stub?implementation?which
?*?can?be?used?to?support?these?system?calls?if?the?regular?Nachos
?*?file?system?has?not?been?implemented.
?*/
?

/*?when?an?address?space?starts?up?it?has?two?open?files?representing?
?*?keyboard?input?and?display?output?(in?UNIX?terms?stdin?and?stdout).
?*?Read?and?Write?can?be?used?directly?on?these?without?first?opening
?*?the?console?device.
?*/

/*?Create?a?Nachos?file?with?name?“name“?*/
/*?Note:?Create?does?not?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????535??2008-04-27?23:42??shell\shell.dsw

?????文件??????33792??2008-04-27?23:49??shell\shell.ncb

?????文件??????33792??2008-04-27?23:47??shell\Debug\vc60.idb

?????文件??????45056??2008-04-27?23:47??shell\Debug\vc60.pdb

?????文件?????167636??2008-04-27?23:46??shell\Debug\shell.pch

?????文件???????3083??2008-04-27?23:46??shell\Debug\shell.obj

?????文件??????????0??2008-04-27?23:45??shell\nachos_syscall.cpp

?????文件???????4929??2008-04-27?23:46??shell\nachos_syscall.h

?????文件????????726??2008-04-27?23:46??shell\shell.c

?????文件????????892??2008-04-27?23:47??shell\shell.plg

?????文件???????7325??2008-04-27?23:49??shell\nachos_syscall.c

?????文件??????48640??2008-04-27?23:49??shell\shell.opt

?????文件???????4408??2008-04-27?23:49??shell\shell.dsp

?????目錄??????????0??2008-04-27?23:42??shell\Debug

?????目錄??????????0??2008-04-27?23:42??shell

-----------?---------??----------?-----??----

???????????????350814????????????????????15


評論

共有 條評論