Esempio n. 1
0
static int load_aout(struct exec_info *execi)
{
  int r;
  struct vnode *vp;
  int proc_e;
  off_t off;
  int hdrlen;
  int sep_id;
  vir_bytes text_bytes, data_bytes, bss_bytes;
  phys_bytes tot_bytes;		/* total space for program, including gap */

  assert(execi != NULL);
  assert(execi->hdr != NULL);
  assert(execi->vp != NULL);

  proc_e = execi->proc_e;
  vp = execi->vp;

  /* Read the file header and extract the segment sizes. */
  r = read_header_aout(execi->hdr, execi->vp->v_size, &sep_id,
		       &text_bytes, &data_bytes, &bss_bytes,
		       &tot_bytes, &execi->pc, &hdrlen);
  if (r != OK) return(r);

  r = exec_newmem(proc_e, 0 /* text_addr */, text_bytes,
		  0 /* data_addr */, data_bytes + bss_bytes, tot_bytes,
		  execi->frame_len, sep_id, 0 /* is_elf */, vp->v_dev, vp->v_inode_nr,
		  execi->sb.st_ctime,
		  execi->progname, execi->new_uid, execi->new_gid,
		  &execi->stack_top, &execi->load_text, &execi->setugid);

  if (r != OK) {
        printf("VFS: load_aout: exec_newmem failed: %d\n", r);
        return(r);
  }

  off = hdrlen;

  /* Read in text and data segments. */
  if (execi->load_text) r = read_seg(vp, off, proc_e, T, 0, text_bytes);
  off += text_bytes;
  if (r == OK) r = read_seg(vp, off, proc_e, D, 0, data_bytes);

  return (r);
}
Esempio n. 2
0
File: exec.c Progetto: mwilbur/minix
static int load_aout(struct exec_info *execi)
{
	int r;
	int hdrlen, sep_id, load_text, allow_setuid;
	vir_bytes text_bytes, data_bytes, bss_bytes;
	phys_bytes tot_bytes;
	off_t off;
	uid_t new_uid;
	gid_t new_gid;
	int proc_e;

	assert(execi != NULL);
	assert(execi->image != NULL);

	proc_e = execi->proc_e;

	/* Read the file header and extract the segment sizes. */
	r = read_header_aout(execi->image, execi->image_len, &sep_id,
		&text_bytes, &data_bytes, &bss_bytes,
		&tot_bytes, &execi->pc, &hdrlen);
	if (r != OK)
	{
		return r;
	}

	new_uid= getuid();
	new_gid= getgid();

	/* XXX what should we use to identify the executable? */
	r= exec_newmem(proc_e, 0 /*text_addr*/, text_bytes,
		0 /*data_addr*/, data_bytes + bss_bytes, tot_bytes,
		execi->frame_len, sep_id, 0 /*is_elf*/, 0 /*dev*/, proc_e /*inum*/, 0 /*ctime*/,
		execi->progname, new_uid, new_gid, &execi->stack_top, &load_text,
		&allow_setuid);
	if (r != OK)
	{
		printf("RS: load_aout: exec_newmem failed: %d\n", r);
		exec_restart(proc_e, r, execi->pc);
		return r;
	}

	off = hdrlen;

	/* Read in text and data segments. */
	if (load_text) {
		r= read_seg(execi, off, proc_e, T, 0, text_bytes);
		if (r != OK)
		{
			printf("RS: load_aout: read_seg failed: %d\n", r);
			exec_restart(proc_e, r, execi->pc);
			return r;
		}
	}
	else
		printf("RS: load_aout: not loading text segment\n");

	off += text_bytes;
	r= read_seg(execi, off, proc_e, D, 0, data_bytes);
	if (r != OK)
	{
		printf("RS: load_aout: read_seg failed: %d\n", r);
		exec_restart(proc_e, r, execi->pc);
		return r;
	}

	return OK;
}