예제 #1
0
파일: state.c 프로젝트: Zolok/refos
void
fileserv_init(void) {
    dprintf("RefOS Fileserver initialising...\n");
    struct fs_state *s = &fileServ;
    fileServCommon = &fileServ.commonState;

    /* Set up the server common config. */
    srv_common_config_t cfg = {
        .maxClients = SRV_DEFAULT_MAX_CLIENTS,
        .clientBadgeBase = FS_CLIENT_BADGE_BASE,
        .clientMagic = FS_CLIENT_MAGIC,
        .notificationBufferSize = FILESERVER_NOTIFICATION_BUFFER_SIZE,
        .paramBufferSize = SRV_DEFAULT_PARAM_BUFFER_SIZE, 
        .serverName = "fileserver",
        .mountPointPath = FILESERVER_MOUNTPOINT,
        .nameServEP = REFOS_NAMESERV_EP,
        .faultDeathNotifyBadge = FS_ASYNC_NOTIFY_BADGE
    };

    /* Set up file server common state. */
    srv_common_init(fileServCommon, cfg);

    /* Set up file server book keeping data structures. */

    dprintf("    initialising pager frame block...\n");
    pager_init(&s->pageFrameBlock, FILESERVER_MAX_PAGE_FRAMES * REFOS_PAGE_SIZE);

    dprintf("    initialising dataspace allocation table...\n");
    dspace_table_init(&s->dspaceTable);
}
예제 #2
0
파일: schema.c 프로젝트: tho068/database-2
int open_db ( void )
{
  pager_terminate (); /* first clean up for a fresh start */
  pager_init ();
  read_tbl_descs ();
  return 0;
}
예제 #3
0
void test_page_read_with_offset (  const char *fname )
{
  put_msg (INFO, "test_page_read_with_offset() ...\n");
  pager_init ();
  /* put_pager_info (DEBUG, "After pager_init"); */
	
  page_p pg;
  int int_out;
  char str_out[14];

  int bnr;
  for (bnr = 0; bnr < NUM_BLOCKS_IN_FILE; bnr++)
    {
      pg = get_page ( fname, bnr );
      if ( pg == NULL)
	{
	  put_msg (FATAL, "get_page %d fails\n", bnr);
	  put_pager_info (FATAL, "After get_page");
	  exit (EXIT_FAILURE);
	}

      /* put_pager_info (DEBUG, "After get_page"); */

      int i = 0;
      while (!eob(pg))
	{
	  int offset = PAGE_HEADER_SIZE + i*(INT_SIZE + str_len);
	  int_out = page_get_int_at(pg, offset);
	  if ( int_out != ints_in[i] + bnr )
	    {
	      put_msg (FATAL,
		       "test_page_read fails: (read: %d, should be %d)\n",
		       int_out, ints_in[i] + bnr);
	      put_pager_info (FATAL, "After page_get_int_at");
	      exit (EXIT_FAILURE);
	    }
	  offset += INT_SIZE;
	  page_get_str_at (pg, offset, str_out, str_len);
	  if ( strcmp (str_out, strs_in[i]) != 0 )
	    {
	      put_msg (FATAL,
		       "test_page_read fails: (read: \"%s\", should be \"%s\")\n",
		       str_out, strs_in[i] + bnr);
	      put_pager_info (FATAL, "After page_get_str_at");
	      exit (EXIT_FAILURE);
	    }
	  i++;
	}
      unpin (pg);
    }

  put_pager_profiler_info (INFO);
  pager_terminate ();
  /* put_pager_info (DEBUG, "After pager_terminate"); */
  put_msg (INFO, "test_page_read_with_offset() succeeds.\n");
}
예제 #4
0
void test_page_write (  const char *fname )
{
  put_msg (INFO, "test_page_write() ...\n");
  pager_init ();
  /* put_pager_info (DEBUG, "After pager_init"); */
	
  page_p pg;
  int bnr;
  for (bnr = 0; bnr < NUM_BLOCKS_IN_FILE; bnr++)
    {
      pg = get_page ( fname, bnr );
      /* alternatively, append. But beware that the file grows
	 with every run of the test
	 pg = get_page_for_append ( fname );
      */
      if ( pg == NULL)
	{
	  put_msg (FATAL, "get_page %d fails\n", bnr);
	  put_pager_info (FATAL, "After get_page");
	  exit (EXIT_FAILURE);
	}

      /* put_pager_info (DEBUG, "After get_page"); */

      int i;
      for (i=0; i<NUM_RECORDS_IN_BLOCK; i++)
	{
	  page_put_int(pg, ints_in[i] + bnr);
	  page_put_str(pg, strs_in[i], str_len);
	  /* put_pager_info (DEBUG, "After writing a record"); */
	}

      /* put_pager_info (DEBUG, "Before write_page"); */
      write_page (pg);
      unpin (pg);
      /* put_pager_info (DEBUG, "After unpin"); */
    }

  put_pager_profiler_info (INFO);	
  pager_terminate ();
  /* put_pager_info (DEBUG, "After pager_terminate"); */
  put_msg (INFO, "test_page_write() done.\n");
}
예제 #5
0
int main(int argc, const char **argv)
{
	static const char *UNUSED = "OBJTOOL_NOT_IMPLEMENTED";

	/* libsubcmd init */
	exec_cmd_init("objtool", UNUSED, UNUSED, UNUSED);
	pager_init(UNUSED);

	argv++;
	argc--;
	handle_options(&argc, &argv);

	if (!argc || help)
		cmd_usage();

	handle_internal_command(argc, argv);

	return 0;
}
예제 #6
0
void test_page_write_with_offset (  const char *fname )
{
  put_msg (INFO, "test_page_write_with_offset() ...\n");
  pager_init ();
  /* put_pager_info (DEBUG, "After pager_init"); */
	
  page_p pg;
  int bnr;
  for (bnr = 0; bnr < NUM_BLOCKS_IN_FILE; bnr++)
    {
      pg = get_page ( fname, bnr );
      if ( pg == NULL)
	{
	  put_msg (FATAL, "get_page %d fails\n", bnr);
	  put_pager_info (FATAL, "After get_page");
	  exit (EXIT_FAILURE);
	}

      /* put_pager_info (DEBUG, "After get_page"); */

      int i;
      for (i=0; i<NUM_RECORDS_IN_BLOCK; i++)
	{
	  int offset = PAGE_HEADER_SIZE + i*(INT_SIZE + str_len);
	  page_put_int_at(pg, offset, ints_in[i] + bnr);
	  offset += INT_SIZE;
	  page_put_str_at(pg, offset, strs_in[i], str_len);
	  /* put_pager_info (DEBUG, "After writing a record"); */
	}

      /* put_pager_info (DEBUG, "Before write_page"); */
      write_page (pg);
      unpin (pg);
      /* put_pager_info (DEBUG, "After unpin"); */
    }

  put_pager_profiler_info (INFO);
  pager_terminate ();
  /* put_pager_info (DEBUG, "After pager_terminate"); */
  put_msg (INFO, "test_page_write_with_offset() done.\n");
}
예제 #7
0
int main(int argc, const char **argv)
{
	int err;
	const char *cmd;
	char sbuf[STRERR_BUFSIZE];
	int value;

	/* libsubcmd init */
	exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
	pager_init(PERF_PAGER_ENVIRONMENT);

	/* The page_size is placed in util object. */
	page_size = sysconf(_SC_PAGE_SIZE);
	cache_line_size(&cacheline_size);

	if (sysctl__read_int("kernel/perf_event_max_stack", &value) == 0)
		sysctl_perf_event_max_stack = value;

	if (sysctl__read_int("kernel/perf_event_max_contexts_per_stack", &value) == 0)
		sysctl_perf_event_max_contexts_per_stack = value;

	cmd = extract_argv0_path(argv[0]);
	if (!cmd)
		cmd = "perf-help";

	srandom(time(NULL));

	perf_config__init();
	err = perf_config(perf_default_config, NULL);
	if (err)
		return err;
	set_buildid_dir(NULL);

	/* get debugfs/tracefs mount point from /proc/mounts */
	tracing_path_mount();

	/*
	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
	 *
	 *  - cannot take flags in between the "perf" and the "xxxx".
	 *  - cannot execute it externally (since it would just do
	 *    the same thing over again)
	 *
	 * So we just directly call the internal command handler. If that one
	 * fails to handle this, then maybe we just run a renamed perf binary
	 * that contains a dash in its name. To handle this scenario, we just
	 * fall through and ignore the "xxxx" part of the command string.
	 */
	if (strstarts(cmd, "perf-")) {
		cmd += 5;
		argv[0] = cmd;
		handle_internal_command(argc, argv);
		/*
		 * If the command is handled, the above function does not
		 * return undo changes and fall through in such a case.
		 */
		cmd -= 5;
		argv[0] = cmd;
	}
	if (strstarts(cmd, "trace")) {
#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)
		setup_path();
		argv[0] = "trace";
		return cmd_trace(argc, argv);
#else
		fprintf(stderr,
			"trace command not available: missing audit-libs devel package at build time.\n");
		goto out;
#endif
	}
	/* Look for flags.. */
	argv++;
	argc--;
	handle_options(&argv, &argc, NULL);
	commit_pager_choice();

	if (argc > 0) {
		if (strstarts(argv[0], "--"))
			argv[0] += 2;
	} else {
		/* The user didn't specify a command; give them help */
		printf("\n usage: %s\n\n", perf_usage_string);
		list_common_cmds_help();
		printf("\n %s\n\n", perf_more_info_string);
		goto out;
	}
	cmd = argv[0];

	test_attr__init();

	/*
	 * We use PATH to find perf commands, but we prepend some higher
	 * precedence paths: the "--exec-path" option, the PERF_EXEC_PATH
	 * environment, and the $(perfexecdir) from the Makefile at build
	 * time.
	 */
	setup_path();
	/*
	 * Block SIGWINCH notifications so that the thread that wants it can
	 * unblock and get syscalls like select interrupted instead of waiting
	 * forever while the signal goes to some other non interested thread.
	 */
	pthread__block_sigwinch();

	perf_debug_setup();

	while (1) {
		static int done_help;

		run_argv(&argc, &argv);

		if (errno != ENOENT)
			break;

		if (!done_help) {
			cmd = argv[0] = help_unknown_cmd(cmd);
			done_help = 1;
		} else
			break;
	}

	fprintf(stderr, "Failed to run command '%s': %s\n",
		cmd, str_error_r(errno, sbuf, sizeof(sbuf)));
out:
	return 1;
}
예제 #8
0
파일: compare.c 프로젝트: elopez/EDyA-I
int myrepo_compare(char *catalogpath1, char *catalogpath2)
{
    unsigned int latest1;
    unsigned int latest2;
    HashTreeNode *tree1;
    HashTreeNode *tree2;
    const char **differences1;
    const char **differences2;
    const char **tmp1;
    const char **tmp2;
    FILE *out;

    assert(catalogpath1 != NULL);
    assert(catalogpath2 != NULL);

    /* Remove any possible end slash */
    catalogpath1[strlen(catalogpath1) - 2] = '\0';
    catalogpath2[strlen(catalogpath2) - 2] = '\0';

    /* Remove last component (.index) */
    catalogpath1 = dirname(catalogpath1);
    catalogpath2 = dirname(catalogpath2);

    latest1 = commit_latest(catalogpath1, 0);

    /* The directory is likely not a valid repo */
    if (latest1 == 0)
        return 1;

    latest2 = commit_latest(catalogpath2, 0);

    /* The directory is likely not a valid repo */
    if (latest2 == 0)
        return 1;

    /* Load the hash trees */
    tree1 = commit_loadtree(catalogpath1, latest1);
    tree2 = commit_loadtree(catalogpath2, latest2);

    if (tree1 == NULL || tree2 == NULL)
        return 1;

    /* Are the trees the same? */
    if (!strcmp(tree1->hash, tree2->hash)) {
        printf("The trees are identical.\n");
        return 0;
    }

    /* Trees are different */

    /* Open a pager to print the diff to */
    out = pager_init();

    /* Compare one way */
    differences1 = hashtree_compare(tree1, tree2);
    tmp1 = differences1;

    /* Process the differences */
    while (*tmp1 != NULL) {
        compare_diff(catalogpath1, latest1, catalogpath2, latest2, *tmp1, out);
        tmp1++;
    }

    /* Now compare the reverse way, to catch files only on the old repo.
     * Make sure we don't process files twice. */
    differences2 = hashtree_compare(tree2, tree1);
    tmp2 = differences2;

    while (*tmp2 != NULL) {
        tmp1 = differences1;
        while (*tmp1 != NULL && strcmp(*tmp2, *tmp1))
            tmp1++;

        if (*tmp1 == NULL)
            compare_diff(catalogpath1, latest1, catalogpath2, latest2, *tmp2,
                         out);

        tmp2++;
    }

    pager_close(out);
    free(differences1);
    free(differences2);

    return 0;
}
예제 #9
0
파일: perf.c 프로젝트: a2hojsjsjs/linux
int main(int argc, const char **argv)
{
	const char *cmd;
	char sbuf[STRERR_BUFSIZE];

	/* libsubcmd init */
	exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT);
	pager_init(PERF_PAGER_ENVIRONMENT);

	/* The page_size is placed in util object. */
	page_size = sysconf(_SC_PAGE_SIZE);
	cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);

	cmd = extract_argv0_path(argv[0]);
	if (!cmd)
		cmd = "perf-help";

	srandom(time(NULL));

	/* get debugfs/tracefs mount point from /proc/mounts */
	tracing_path_mount();

	/*
	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
	 *
	 *  - cannot take flags in between the "perf" and the "xxxx".
	 *  - cannot execute it externally (since it would just do
	 *    the same thing over again)
	 *
	 * So we just directly call the internal command handler, and
	 * die if that one cannot handle it.
	 */
	if (!prefixcmp(cmd, "perf-")) {
		cmd += 5;
		argv[0] = cmd;
		handle_internal_command(argc, argv);
		fprintf(stderr, "cannot handle %s internally", cmd);
		goto out;
	}
	if (!prefixcmp(cmd, "trace")) {
#ifdef HAVE_LIBAUDIT_SUPPORT
		set_buildid_dir(NULL);
		setup_path();
		argv[0] = "trace";
		return cmd_trace(argc, argv, NULL);
#else
		fprintf(stderr,
			"trace command not available: missing audit-libs devel package at build time.\n");
		goto out;
#endif
	}
	/* Look for flags.. */
	argv++;
	argc--;
	handle_options(&argv, &argc, NULL);
	commit_pager_choice();
	set_buildid_dir(NULL);

	if (argc > 0) {
		if (!prefixcmp(argv[0], "--"))
			argv[0] += 2;
	} else {
		/* The user didn't specify a command; give them help */
		printf("\n usage: %s\n\n", perf_usage_string);
		list_common_cmds_help();
		printf("\n %s\n\n", perf_more_info_string);
		goto out;
	}
	cmd = argv[0];

	test_attr__init();

	/*
	 * We use PATH to find perf commands, but we prepend some higher
	 * precedence paths: the "--exec-path" option, the PERF_EXEC_PATH
	 * environment, and the $(perfexecdir) from the Makefile at build
	 * time.
	 */
	setup_path();
	/*
	 * Block SIGWINCH notifications so that the thread that wants it can
	 * unblock and get syscalls like select interrupted instead of waiting
	 * forever while the signal goes to some other non interested thread.
	 */
	pthread__block_sigwinch();

	while (1) {
		static int done_help;
		int was_alias = run_argv(&argc, &argv);

		if (errno != ENOENT)
			break;

		if (was_alias) {
			fprintf(stderr, "Expansion of alias '%s' failed; "
				"'%s' is not a perf-command\n",
				cmd, argv[0]);
			goto out;
		}
		if (!done_help) {
			cmd = argv[0] = help_unknown_cmd(cmd);
			done_help = 1;
		} else
			break;
	}

	fprintf(stderr, "Failed to run command '%s': %s\n",
		cmd, strerror_r(errno, sbuf, sizeof(sbuf)));
out:
	return 1;
}