Пример #1
0
/*===========================================================================*
 *				send_reply				     *
 *===========================================================================*/
PRIVATE void send_reply(int err, int transid)
{
	/* Send a reply to the caller.
	 */
	int r;

	fs_m_out.m_type = err;
	if (IS_VFS_FS_TRANSID(transid)) {
		fs_m_out.m_type = TRNS_ADD_ID(fs_m_out.m_type, transid);
	}

	if ((r = send(fs_m_in.m_source, &fs_m_out)) != OK)
		panic(__FILE__, "unable to send reply", r);
}
Пример #2
0
/*===========================================================================*
 *				sendmsg					     *
 *===========================================================================*/
static int sendmsg(struct vmnt *vmp, endpoint_t dst, struct worker_thread *wp)
{
/* This is the low level function that sends requests.
 * Currently to FSes or VM.
 */
  int r, transid;

  if(vmp) vmp->m_comm.c_cur_reqs++;	/* One more request awaiting a reply */
  transid = wp->w_tid + VFS_TRANSID;
  wp->w_sendrec->m_type = TRNS_ADD_ID(wp->w_sendrec->m_type, transid);
  wp->w_task = dst;
  if ((r = asynsend3(dst, wp->w_sendrec, AMF_NOREPLY)) != OK) {
	printf("VFS: sendmsg: error sending message. "
		"dest: %d req_nr: %d err: %d\n", dst,
			wp->w_sendrec->m_type, r);
	util_stacktrace();
	return(r);
  }

  return(r);
}
Пример #3
0
/*===========================================================================*
 *				main                                         *
 *===========================================================================*/
PUBLIC int main(int argc, char *argv[])
{
/* This is the main routine of this service. The main loop consists of
 * three major activities: getting new work, processing the work, and
 * sending the reply. The loop never terminates, unless a panic occurs.
 */
  int error = OK, ind, transid;
  unsigned short test_endian = 1;

  /* SEF local startup. */
  env_setargs(argc, argv);
  sef_local_startup();

  le_CPU = (*(unsigned char *) &test_endian == 0 ? 0 : 1);

  /* Server isn't tested on big endian CPU */
  ASSERT(le_CPU == 1);

  while(!unmountdone || !exitsignaled) {
	endpoint_t src;

	/* Wait for request message. */
	get_work(&fs_m_in);

	transid = TRNS_GET_ID(fs_m_in.m_type);
	fs_m_in.m_type = TRNS_DEL_ID(fs_m_in.m_type);
	if (fs_m_in.m_type == 0) {
		assert(!IS_VFS_FS_TRANSID(transid));
		fs_m_in.m_type = transid;       /* Backwards compat. */
		transid = 0;
	} else
		assert(IS_VFS_FS_TRANSID(transid));

	src = fs_m_in.m_source;
	caller_uid = INVAL_UID;	/* To trap errors */
	caller_gid = INVAL_GID;
	req_nr = fs_m_in.m_type;

	if (req_nr < VFS_BASE) {
		fs_m_in.m_type += VFS_BASE;
		req_nr = fs_m_in.m_type;
	}
	ind = req_nr - VFS_BASE;

	if (ind < 0 || ind >= NREQS) {
		printf("mfs: bad request %d\n", req_nr);
		printf("ind = %d\n", ind);
		error = EINVAL;
	} else {
		error = (*fs_call_vec[ind])();
	}

	fs_m_out.m_type = error;
	if (IS_VFS_FS_TRANSID(transid)) {
		/* If a transaction ID was set, reset it */
		fs_m_out.m_type = TRNS_ADD_ID(fs_m_out.m_type, transid);
	}
	reply(src, &fs_m_out);

	if (error == OK)
		read_ahead(); /* do block read ahead */
  }

  return 0;
}
Пример #4
0
/*===========================================================================*
 *				main                                         *
 *===========================================================================*/
PUBLIC int main(int argc, char *argv[])
{
/* This is the main routine of this service. The main loop consists of 
 * three major activities: getting new work, processing the work, and
 * sending the reply. The loop never terminates, unless a panic occurs.
 */
  int ind, transid;
  message pfs_m_in;
  message pfs_m_out;

  /* SEF local startup. */
  env_setargs(argc, argv);
  sef_local_startup();

  while(!exitsignaled || busy) {
	endpoint_t src;

	/* Wait for request message. */
	get_work(&pfs_m_in);

	transid = TRNS_GET_ID(pfs_m_in.m_type);
	pfs_m_in.m_type = TRNS_DEL_ID(pfs_m_in.m_type);
	if (pfs_m_in.m_type == 0) {
		assert(!IS_VFS_FS_TRANSID(transid));
		pfs_m_in.m_type = transid;
		transid = 0;
	} else
		assert(IS_VFS_FS_TRANSID(transid) || transid == 0);

	src = pfs_m_in.m_source;
	caller_uid = INVAL_UID;	/* To trap errors */
	caller_gid = INVAL_GID;
	req_nr = pfs_m_in.m_type;

	if (IS_DEV_RQ(req_nr)) {
		ind = req_nr - DEV_RQ_BASE;
		if (ind < 0 || ind >= DEV_CALL_VEC_SIZE) {
			printf("pfs: bad DEV request %d\n", req_nr);
			pfs_m_out.m_type = EINVAL;
		} else {
			(*dev_call_vec[ind])(&pfs_m_in, &pfs_m_out);
		}
	} else if (IS_VFS_RQ(req_nr)) {
		ind = req_nr - VFS_BASE;
		if (ind < 0 || ind >= FS_CALL_VEC_SIZE) {
			printf("pfs: bad FS request %d\n", req_nr);
			pfs_m_out.m_type = EINVAL;
		} else {
			pfs_m_out.m_type =
				(*fs_call_vec[ind])(&pfs_m_in, &pfs_m_out);
		}
	} else {
		printf("pfs: bad request %d\n", req_nr);
		pfs_m_out.m_type = EINVAL;
	}

	if (IS_VFS_RQ(req_nr) && IS_VFS_FS_TRANSID(transid)) {
		pfs_m_out.m_type = TRNS_ADD_ID(pfs_m_out.m_type, transid);
	}
	reply(src, &pfs_m_out);
  }
  return(OK);
}