亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? exec.c

?? 一個簡單的操作系統minix的核心代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				src/mm/exec.c	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

17100	/* This file handles the EXEC system call.  It performs the work as follows:
17101	 *    - see if the permissions allow the file to be executed
17102	 *    - read the header and extract the sizes
17103	 *    - fetch the initial args and environment from the user space
17104	 *    - allocate the memory for the new process
17105	 *    - copy the initial stack from MM to the process
17106	 *    - read in the text and data segments and copy to the process
17107	 *    - take care of setuid and setgid bits
17108	 *    - fix up 'mproc' table
17109	 *    - tell kernel about EXEC
17110	 *    - save offset to initial argc (for ps)
17111	 *
17112	 * The entry points into this file are:
17113	 *   do_exec:    perform the EXEC system call
17114	 *   find_share: find a process whose text segment can be shared
17115	 */
17116	
17117	#include "mm.h"
17118	#include <sys/stat.h>
17119	#include <minix/callnr.h>
17120	#include <a.out.h>
17121	#include <signal.h>
17122	#include <string.h>
17123	#include "mproc.h"
17124	#include "param.h"
17125	
17126	FORWARD _PROTOTYPE( void load_seg, (int fd, int seg, vir_bytes seg_bytes) );
17127	FORWARD _PROTOTYPE( int new_mem, (struct mproc *sh_mp, vir_bytes text_bytes,
17128	                vir_bytes data_bytes, vir_bytes bss_bytes,
17129	                vir_bytes stk_bytes, phys_bytes tot_bytes)              );
17130	FORWARD _PROTOTYPE( void patch_ptr, (char stack [ARG_MAX ], vir_bytes base) );
17131	FORWARD _PROTOTYPE( int read_header, (int fd, int *ft, vir_bytes *text_bytes,
17132	                vir_bytes *data_bytes, vir_bytes *bss_bytes,
17133	                phys_bytes *tot_bytes, long *sym_bytes, vir_clicks sc,
17134	                vir_bytes *pc)                                          );
17135	
17136	
17137	/*===========================================================================*
17138	 *                              do_exec                                      *
17139	 *===========================================================================*/
17140	PUBLIC int do_exec()
17141	{
17142	/* Perform the execve(name, argv, envp) call.  The user library builds a
17143	 * complete stack image, including pointers, args, environ, etc.  The stack
17144	 * is copied to a buffer inside MM, and then to the new core image.
17145	 */
17146	
17147	  register struct mproc *rmp;
17148	  struct mproc *sh_mp;
17149	  int m, r, fd, ft, sn;
17150	  static char mbuf[ARG_MAX];    /* buffer for stack and zeroes */
17151	  static char name_buf[PATH_MAX]; /* the name of the file to exec */
17152	  char *new_sp, *basename;
17153	  vir_bytes src, dst, text_bytes, data_bytes, bss_bytes, stk_bytes, vsp;
17154	  phys_bytes tot_bytes;         /* total space for program, including gap */
17155	  long sym_bytes;
17156	  vir_clicks sc;
17157	  struct stat s_buf;
17158	  vir_bytes pc;
17159	
17160	  /* Do some validity checks. */
17161	  rmp = mp;
17162	  stk_bytes = (vir_bytes) stack_bytes;
17163	  if (stk_bytes > ARG_MAX) return(ENOMEM);      /* stack too big */
17164	  if (exec_len <= 0 || exec_len > PATH_MAX) return(EINVAL);
17165	
17166	  /* Get the exec file name and see if the file is executable. */
17167	  src = (vir_bytes) exec_name;
17168	  dst = (vir_bytes) name_buf;
17169	  r = sys_copy(who, D, (phys_bytes) src,
17170	                MM_PROC_NR, D, (phys_bytes) dst, (phys_bytes) exec_len);
17171	  if (r != OK) return(r);       /* file name not in user data segment */
17172	  tell_fs(CHDIR, who, FALSE, 0);        /* switch to the user's FS environ. */
17173	  fd = allowed(name_buf, &s_buf, X_BIT);        /* is file executable? */
17174	  if (fd < 0) return(fd);       /* file was not executable */
17175	
17176	  /* Read the file header and extract the segment sizes. */
17177	  sc = (stk_bytes + CLICK_SIZE - 1) >> CLICK_SHIFT;
17178	  m = read_header(fd, &ft, &text_bytes, &data_bytes, &bss_bytes, 
17179	                                        &tot_bytes, &sym_bytes, sc, &pc);
17180	  if (m < 0) {
17181	        close(fd);              /* something wrong with header */
17182	        return(ENOEXEC);
17183	  }
17184	
17185	  /* Fetch the stack from the user before destroying the old core image. */
17186	  src = (vir_bytes) stack_ptr;
17187	  dst = (vir_bytes) mbuf;
17188	  r = sys_copy(who, D, (phys_bytes) src,
17189	                        MM_PROC_NR, D, (phys_bytes) dst, (phys_bytes)stk_bytes);
17190	  if (r != OK) {
17191	        close(fd);              /* can't fetch stack (e.g. bad virtual addr) */
17192	        return(EACCES);
17193	  }
17194	
17195	  /* Can the process' text be shared with that of one already running? */
17196	  sh_mp = find_share(rmp, s_buf.st_ino, s_buf.st_dev, s_buf.st_ctime);
17197	
17198	  /* Allocate new memory and release old memory.  Fix map and tell kernel. */
17199	  r = new_mem(sh_mp, text_bytes, data_bytes, bss_bytes, stk_bytes, tot_bytes);
17200	  if (r != OK) {
17201	        close(fd);              /* insufficient core or program too big */
17202	        return(r);
17203	  }
17204	
17205	  /* Save file identification to allow it to be shared. */
17206	  rmp->mp_ino = s_buf.st_ino;
17207	  rmp->mp_dev = s_buf.st_dev;
17208	  rmp->mp_ctime = s_buf.st_ctime;
17209	
17210	  /* Patch up stack and copy it from MM to new core image. */
17211	  vsp = (vir_bytes) rmp->mp_seg[S].mem_vir << CLICK_SHIFT;
17212	  vsp += (vir_bytes) rmp->mp_seg[S].mem_len << CLICK_SHIFT;
17213	  vsp -= stk_bytes;
17214	  patch_ptr(mbuf, vsp);
17215	  src = (vir_bytes) mbuf;
17216	  r = sys_copy(MM_PROC_NR, D, (phys_bytes) src,
17217	                        who, D, (phys_bytes) vsp, (phys_bytes)stk_bytes);
17218	  if (r != OK) panic("do_exec stack copy err", NO_NUM);
17219	
17220	  /* Read in text and data segments. */
17221	  if (sh_mp != NULL) {
17222	        lseek(fd, (off_t) text_bytes, SEEK_CUR);  /* shared: skip text */
17223	  } else {
17224	        load_seg(fd, T, text_bytes);
17225	  }
17226	  load_seg(fd, D, data_bytes);
17227	
17228	
17229	  close(fd);                    /* don't need exec file any more */
17230	
17231	  /* Take care of setuid/setgid bits. */
17232	  if ((rmp->mp_flags & TRACED) == 0) { /* suppress if tracing */
17233	        if (s_buf.st_mode & I_SET_UID_BIT) {
17234	                rmp->mp_effuid = s_buf.st_uid;
17235	                tell_fs(SETUID,who, (int)rmp->mp_realuid, (int)rmp->mp_effuid);
17236	        }
17237	        if (s_buf.st_mode & I_SET_GID_BIT) {
17238	                rmp->mp_effgid = s_buf.st_gid;
17239	                tell_fs(SETGID,who, (int)rmp->mp_realgid, (int)rmp->mp_effgid);
17240	        }
17241	  }
17242	
17243	  /* Save offset to initial argc (for ps) */
17244	  rmp->mp_procargs = vsp;
17245	
17246	  /* Fix 'mproc' fields, tell kernel that exec is done,  reset caught sigs. */
17247	  for (sn = 1; sn <= _NSIG; sn++) {
17248	        if (sigismember(&rmp->mp_catch, sn)) {
17249	                sigdelset(&rmp->mp_catch, sn);
17250	                rmp->mp_sigact[sn].sa_handler = SIG_DFL;
17251	                sigemptyset(&rmp->mp_sigact[sn].sa_mask);
17252	        }
17253	  }
17254	
17255	  rmp->mp_flags &= ~SEPARATE;   /* turn off SEPARATE bit */
17256	  rmp->mp_flags |= ft;          /* turn it on for separate I & D files */
17257	  new_sp = (char *) vsp;
17258	
17259	  tell_fs(EXEC, who, 0, 0);     /* allow FS to handle FD_CLOEXEC files */
17260	
17261	  /* System will save command line for debugging, ps(1) output, etc. */
17262	  basename = strrchr(name_buf, '/');
17263	  if (basename == NULL) basename = name_buf; else basename++;
17264	  sys_exec(who, new_sp, rmp->mp_flags & TRACED, basename, pc);
17265	  return(OK);
17266	}
	
	
17269	/*===========================================================================*
17270	 *                              read_header                                  *
17271	 *===========================================================================*/
17272	PRIVATE int read_header(fd, ft, text_bytes, data_bytes, bss_bytes, 
17273	                                                tot_bytes, sym_bytes, sc, pc)
17274	int fd;                         /* file descriptor for reading exec file */
17275	int *ft;                        /* place to return ft number */
17276	vir_bytes *text_bytes;          /* place to return text size */
17277	vir_bytes *data_bytes;          /* place to return initialized data size */
17278	vir_bytes *bss_bytes;           /* place to return bss size */
17279	phys_bytes *tot_bytes;          /* place to return total size */
17280	long *sym_bytes;                /* place to return symbol table size */
17281	vir_clicks sc;                  /* stack size in clicks */
17282	vir_bytes *pc;                  /* program entry point (initial PC) */
17283	{
17284	/* Read the header and extract the text, data, bss and total sizes from it. */
17285	
17286	  int m, ct;
17287	  vir_clicks tc, dc, s_vir, dvir;
17288	  phys_clicks totc;
17289	  struct exec hdr;              /* a.out header is read in here */
17290	
17291	  /* Read the header and check the magic number.  The standard MINIX header 
17292	   * is defined in <a.out.h>.  It consists of 8 chars followed by 6 longs.
17293	   * Then come 4 more longs that are not used here.
17294	   *    Byte 0: magic number 0x01
17295	   *    Byte 1: magic number 0x03
17296	   *    Byte 2: normal = 0x10 (not checked, 0 is OK), separate I/D = 0x20
17297	   *    Byte 3: CPU type, Intel 16 bit = 0x04, Intel 32 bit = 0x10, 
17298	   *            Motorola = 0x0B, Sun SPARC = 0x17
17299	   *    Byte 4: Header length = 0x20
17300	   *    Bytes 5-7 are not used.
17301	   *
17302	   *    Now come the 6 longs
17303	   *    Bytes  8-11: size of text segments in bytes
17304	   *    Bytes 12-15: size of initialized data segment in bytes
17305	   *    Bytes 16-19: size of bss in bytes
17306	   *    Bytes 20-23: program entry point
17307	   *    Bytes 24-27: total memory allocated to program (text, data + stack)
17308	   *    Bytes 28-31: size of symbol table in bytes
17309	   * The longs are represented in a machine dependent order,
17310	   * little-endian on the 8088, big-endian on the 68000.
17311	   * The header is followed directly by the text and data segments, and the 
17312	   * symbol table (if any). The sizes are given in the header. Only the 
17313	   * text and data segments are copied into memory by exec. The header is 
17314	   * used here only. The symbol table is for the benefit of a debugger and 
17315	   * is ignored here.
17316	   */
17317	
17318	  if (read(fd, (char *) &hdr, A_MINHDR) != A_MINHDR) return(ENOEXEC);
17319	
17320	  /* Check magic number, cpu type, and flags. */
17321	  if (BADMAG(hdr)) return(ENOEXEC);
17322	#if (CHIP == INTEL && _WORD_SIZE == 2)
17323	  if (hdr.a_cpu != A_I8086) return(ENOEXEC);
17324	#endif
17325	#if (CHIP == INTEL && _WORD_SIZE == 4)
17326	  if (hdr.a_cpu != A_I80386) return(ENOEXEC);
17327	#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人激情小说乱人伦| 欧美蜜桃一区二区三区| 中文字幕一区二区三区av| 成人国产一区二区三区精品| 色综合色综合色综合色综合色综合| 最新高清无码专区| 欧美性高清videossexo| 日韩精品三区四区| 久久婷婷综合激情| www.久久精品| 亚洲图片欧美视频| 日韩一区国产二区欧美三区| 国产伦精品一区二区三区视频青涩| 国产欧美日韩在线| 色综合咪咪久久| 日日夜夜一区二区| 久久久精品tv| 色老综合老女人久久久| 日本欧美加勒比视频| 久久久青草青青国产亚洲免观| 成人福利视频网站| 亚洲国产一区视频| 日韩一区二区不卡| 播五月开心婷婷综合| 亚洲一区影音先锋| 精品国产乱码久久久久久免费| 成人av午夜电影| 日韩精品一区二区三区在线播放 | 免费在线一区观看| 国产视频亚洲色图| 欧美在线高清视频| 国产原创一区二区三区| 亚洲日本青草视频在线怡红院| 在线不卡中文字幕| 成人精品视频网站| 午夜在线成人av| 欧美激情一区二区三区不卡| 在线观看视频一区| 久久97超碰国产精品超碰| 亚洲图片激情小说| 日韩精品一区二区三区视频播放| 成人av网站在线观看免费| 视频一区视频二区中文字幕| 欧美激情一区二区三区全黄| 欧美日韩国产色站一区二区三区| 日本一区二区成人| 91精品黄色片免费大全| 成人av午夜电影| 免费观看成人av| 亚洲欧美日韩在线| 久久久久久影视| 欧美日韩高清一区二区不卡| 成人中文字幕电影| 麻豆91精品视频| 一区二区三区精品久久久| 久久久精品一品道一区| 欧美福利视频一区| 91网页版在线| 国产精品中文字幕日韩精品| 天堂一区二区在线| 亚洲欧美日韩国产手机在线| 久久夜色精品国产噜噜av| 欧美色图在线观看| 99久久久久免费精品国产| 国产在线一区二区综合免费视频| 亚洲不卡在线观看| 精品视频在线免费看| 成人免费黄色在线| 激情丁香综合五月| 日本中文字幕一区二区视频| 亚洲人成在线观看一区二区| 久久久久久久久久久久久女国产乱| 欧美日本韩国一区二区三区视频| 99精品1区2区| 国产成人8x视频一区二区| 美女诱惑一区二区| 亚洲不卡av一区二区三区| 亚洲欧美色综合| 国产精品久久久久四虎| 欧美精品一区二| 日韩精品一区二区三区四区| 欧美日韩亚洲综合在线| 91看片淫黄大片一级在线观看| 国产91精品免费| 国产乱对白刺激视频不卡| 裸体健美xxxx欧美裸体表演| 日日夜夜精品免费视频| 欧美一区三区四区| 欧美日韩一区二区三区高清| 91免费版在线| 91蜜桃在线观看| 成人黄色国产精品网站大全在线免费观看 | 国产河南妇女毛片精品久久久 | 久久国产精品免费| 日韩av在线发布| 五月天丁香久久| 亚洲成人一区二区在线观看| 亚洲精品老司机| 日韩理论电影院| 亚洲免费观看高清完整版在线| 国产精品美女久久久久久久| 欧美经典三级视频一区二区三区| 久久久噜噜噜久噜久久综合| 久久综合久久鬼色中文字| 精品久久国产字幕高潮| 精品国产精品一区二区夜夜嗨| 欧美r级在线观看| 精品欧美一区二区三区精品久久| 日韩午夜精品视频| 日韩欧美电影在线| 精品久久久久99| 亚洲精品在线一区二区| 久久亚洲私人国产精品va媚药| 26uuu另类欧美亚洲曰本| 久久看人人爽人人| 国产日韩欧美电影| 中文字幕一区二区日韩精品绯色| 色婷婷精品大视频在线蜜桃视频| 99视频精品全部免费在线| 99re这里只有精品首页| 一本色道久久综合亚洲精品按摩| 欧美最猛性xxxxx直播| 欧美日韩电影在线播放| 3d动漫精品啪啪1区2区免费 | 亚洲一卡二卡三卡四卡无卡久久| 一区二区三区蜜桃网| 午夜精品免费在线| 老司机免费视频一区二区三区| 精品一区二区久久久| 国产精品系列在线播放| av激情综合网| 在线免费观看日本一区| 56国语精品自产拍在线观看| 91精品福利在线一区二区三区| 精品国产露脸精彩对白| 国产欧美日韩激情| 亚洲免费观看高清在线观看| 亚洲成人av在线电影| 精品在线免费视频| 风间由美中文字幕在线看视频国产欧美| heyzo一本久久综合| 欧美丝袜自拍制服另类| 日韩视频免费观看高清在线视频| 99免费精品视频| 欧美又粗又大又爽| 日韩欧美国产一区二区三区| 国产午夜精品在线观看| 亚洲免费观看高清完整版在线观看熊 | 91精品在线免费观看| 久久精品一区二区三区不卡牛牛| 日韩一区在线免费观看| 亚洲高清久久久| 国产露脸91国语对白| 色素色在线综合| 日韩精品一区二区三区视频| 国产精品久久久久永久免费观看 | 亚洲视频在线一区观看| 午夜不卡av免费| 国产乱对白刺激视频不卡| 色老汉一区二区三区| 国产麻豆日韩欧美久久| 99视频精品全部免费在线| 欧美精品免费视频| 日本一区免费视频| 香港成人在线视频| 成人午夜激情影院| 欧美久久免费观看| 国产精品女人毛片| 蜜臀av性久久久久蜜臀aⅴ流畅 | 亚洲香蕉伊在人在线观| 韩国成人在线视频| 欧美亚洲日本一区| 久久亚洲精品国产精品紫薇| 一区二区不卡在线播放 | 欧美韩国日本综合| 偷偷要91色婷婷| 成人app下载| 日韩欧美一区在线| 亚洲精品国产a| 国产乱对白刺激视频不卡| 欧美日韩视频在线一区二区| 久久久久国产精品厨房| 亚洲成人av电影| a级精品国产片在线观看| 日韩一卡二卡三卡国产欧美| 亚洲免费毛片网站| 国产成人精品www牛牛影视| 欧美精品tushy高清| 亚洲少妇屁股交4| 国产精品综合视频| 91精品久久久久久久99蜜桃| 欧美色手机在线观看| 国产三级欧美三级日产三级99 | 国产美女娇喘av呻吟久久| 欧美日韩一区二区三区四区| 中文字幕日韩av资源站| 黄网站免费久久| 在线播放中文字幕一区| 亚洲精品国产a久久久久久| 成人激情文学综合网|