예제 #1
0
/*===========================================================================*
 *				blockdriver_announce			     *
 *===========================================================================*/
void blockdriver_announce(int type)
{
/* Announce we are up after a fresh start or a restart. */
  int r;
  char key[DS_MAX_KEYLEN];
  char label[DS_MAX_KEYLEN];
  char *driver_prefix = "drv.blk.";

  /* Callers are allowed to use ipc_sendrec to communicate with drivers.
   * For this reason, there may blocked callers when a driver restarts.
   * Ask the kernel to unblock them (if any). Note that most block drivers
   * will not restart statefully, and thus will skip this code.
   */
  if (type == SEF_INIT_RESTART) {
	if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK)
		panic("blockdriver_init: sys_statectl failed: %d", r);
  }

  /* Publish a driver up event. */
  if ((r = ds_retrieve_label_name(label, sef_self())) != OK)
	panic("blockdriver_init: unable to get own label: %d", r);

  snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
  if ((r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE)) != OK)
	panic("blockdriver_init: unable to publish driver up event: %d", r);

  /* Expect an open for any device before serving regular driver requests. */
  clear_open_devs();

  /* Initialize or reset the message queue. */
  mq_init();
}
예제 #2
0
파일: chardriver.c 프로젝트: grd/minix
/*===========================================================================*
 *				chardriver_announce			     *
 *===========================================================================*/
void chardriver_announce(void)
{
/* Announce we are up after a fresh start or restart. */
  int r;
  char key[DS_MAX_KEYLEN];
  char label[DS_MAX_KEYLEN];
  char *driver_prefix = "drv.chr.";

  /* Callers are allowed to use sendrec to communicate with drivers.
   * For this reason, there may blocked callers when a driver restarts.
   * Ask the kernel to unblock them (if any).
   */
#if USE_STATECTL
  if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK)
	panic("chardriver_init: sys_statectl failed: %d", r);
#endif

  /* Publish a driver up event. */
  if ((r = ds_retrieve_label_name(label, getprocnr())) != OK)
	panic("chardriver_init: unable to get own label: %d", r);

  snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
  if ((r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE)) != OK)
	panic("chardriver_init: unable to publish driver up event: %d", r);

  /* Expect a DEV_OPEN for any device before serving regular driver requests. */
  clear_open_devs();
}
예제 #3
0
파일: dstest.c 프로젝트: AgamAgarwal/minix
/*===========================================================================*
 *				test_label				     *
 *===========================================================================*/
void test_label(void)
{
	int r;
	char label[DS_MAX_KEYLEN];
	endpoint_t endpoint;

	/* Retrieve own label and endpoint. */
	r = ds_retrieve_label_name(label, getprocnr());
	assert(r == OK);
	r = ds_retrieve_label_endpt(label, &endpoint);
	assert(r == OK && endpoint == getprocnr());

	/* Publish and delete. */
	r = ds_publish_label(label, endpoint, 0);
	assert(r == EPERM);
	r = ds_delete_label(label);
	assert(r == EPERM);

	printf("DSTEST: LABEL test successful!\n");
}
예제 #4
0
파일: netdriver.c 프로젝트: mwilbur/minix
/*===========================================================================*
 *			    netdriver_announce				     *
 *===========================================================================*/
PUBLIC void netdriver_announce()
{
/* Announce we are up after a fresh start or restart. */
  int r;
  char key[DS_MAX_KEYLEN];
  char label[DS_MAX_KEYLEN];
  char *driver_prefix = "drv.net.";

  /* Publish a driver up event. */
  r = ds_retrieve_label_name(label, getprocnr());
  if (r != OK) {
	panic("driver_announce: unable to get own label: %d\n", r);
  }
  snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
  r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE);
  if (r != OK) {
	panic("driver_announce: unable to publish driver up event: %d\n", r);
  }

  conf_expected = TRUE;
}
예제 #5
0
/*===========================================================================*
 *				test_label				     *
 *===========================================================================*/
void test_label(void)
{
	int r;
	char get_label[DS_MAX_KEYLEN];
	unsigned long num;

	/* Publish and retrieve. */
	r = ds_publish_label(key_label, 1234, 0);
	assert(r == OK);
	r = ds_retrieve_label_num(key_label, &num);
	assert(r == OK && num == 1234);

	/* Here are the differences w.r.t. U32. */
	r = ds_publish_label("hello", 1234, 0);
	assert(r == EEXIST);
	r = ds_retrieve_label_name(get_label, 1234);
	assert(r == OK && strcmp(key_label, get_label) == 0);

	r = ds_delete_label(key_label);
	assert(r == OK);

	printf("DSTEST: LABEL test successful!\n");
}