Exemplo n.º 1
0
int load_dep(const char *name)
{
	char buffer[1024];
	char path[1024];
	int size=strlen(name);
	cprintf("load_dep\n");
	snprintf(path, size + KERN_MODULE_ADDITIONAL_LEN + 5,
			 KERN_MODULE_PREFIX "%s.dep", name);
	cprintf("%s\n",path);
	int fd = open(path, O_RDONLY);
	int s = 0;
	int p = 0;
	char c;
	while ((s = read(fd, &c, sizeof(char))) >= 0) {
		if (s == 0 || c==' ' || c == '\n' || c == '\r') {
			buffer[p] = '\0';
			if (p > 0 && !query_module(buffer)) {
				cprintf("%s\n",buffer);
				load(buffer, strlen(buffer));
			}
			p = 0;
		}
		else buffer[p++] = c;
		if (s == 0)
			break;
		}
	return 1;
}
Exemplo n.º 2
0
int lsmod_main(int argc, char **argv)
{
	struct module_info info;
	char *module_names, *mn, *deps, *dn;
	size_t bufsize, depsize, nmod, count, i, j;

	module_names = xmalloc(bufsize = 256);
	if (my_query_module(NULL, QM_MODULES, (void **)&module_names, &bufsize,
				&nmod)) {
		bb_perror_msg_and_die("QM_MODULES");
	}

	deps = xmalloc(depsize = 256);
	printf("Module                  Size  Used by");
	check_tainted();

	for (i = 0, mn = module_names; i < nmod; mn += strlen(mn) + 1, i++) {
		if (query_module(mn, QM_INFO, &info, sizeof(info), &count)) {
			if (errno == ENOENT) {
				/* The module was removed out from underneath us. */
				continue;
			}
			/* else choke */
			bb_perror_msg_and_die("module %s: QM_INFO", mn);
		}
		if (my_query_module(mn, QM_REFS, (void **)&deps, &depsize, &count)) {
			if (errno == ENOENT) {
				/* The module was removed out from underneath us. */
				continue;
			}
			bb_perror_msg_and_die("module %s: QM_REFS", mn);
		}
		printf("%-20s%8lu%4ld", mn, info.size, info.usecount);
		if (info.flags & NEW_MOD_DELETED)
			printf(" (deleted)");
		else if (info.flags & NEW_MOD_INITIALIZING)
			printf(" (initializing)");
		else if (!(info.flags & NEW_MOD_RUNNING))
			printf(" (uninitialized)");
		else {
			if (info.flags & NEW_MOD_AUTOCLEAN)
				printf(" (autoclean) ");
			if (!(info.flags & NEW_MOD_USED_ONCE))
				printf(" (unused)");
		}
		if (count) printf(" [");
		for (j = 0, dn = deps; j < count; dn += strlen(dn) + 1, j++) {
			printf("%s%s", dn, (j==count-1)? "":" ");
		}
		if (count) printf("]");

		printf("\n");
	}

#ifdef CONFIG_FEATURE_CLEAN_UP
	free(module_names);
#endif

	return( 0);
}
Exemplo n.º 3
0
static int my_query_module(const char *name, int which, void **buf,
		size_t *bufsize, size_t *ret)
{
	int my_ret;

	my_ret = query_module(name, which, *buf, *bufsize, ret);

	if (my_ret == -1 && errno == ENOSPC) {
		*buf = xrealloc(*buf, *ret);
		*bufsize = *ret;

		my_ret = query_module(name, which, *buf, *bufsize, ret);
	}

	return my_ret;
}
Exemplo n.º 4
0
int
main(int argc, char **argv)
{
	int lc;				/* loop counter */
	char *msg;			/* message returned from parse_opts */

	/* parse standard options */
	if ((msg = parse_opts(argc, argv, NULL, NULL)) !=
	    (char *)NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
	}

	if (STD_COPIES != 1) {
		tst_resm(TINFO, "-c option has no effect for this testcase - "
			"doesn't allow running more than one instance "
			"at a time");
		STD_COPIES = 1;
	}

	tst_tmpdir();
	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		/* reset Tst_count in case we are looping */
		Tst_count = 0;

		for (testno = 0; testno < TST_TOTAL; ++testno) {

			if ((tdat[testno].setup) && (tdat[testno].setup())) {
				/* setup() failed, skip this test */
				continue;
			}
			TEST(query_module(tdat[testno].modname,
				tdat[testno].which, tdat[testno].buf,
				tdat[testno].bufsize, tdat[testno].ret_size));
			TEST_ERROR_LOG(TEST_ERRNO);
			if ((TEST_RETURN == EXP_RET_VAL) &&
				(TEST_ERRNO == tdat[testno].experrno) ) {
				tst_resm(TPASS, "Expected %s, errno: %d",
					tdat[testno].desc, TEST_ERRNO);
			} else {
				tst_resm(TFAIL, "Unexpected %s ; returned"
					" %d (expected %d), errno %d (expected"
					" %d)", tdat[testno].desc,
					TEST_RETURN, EXP_RET_VAL,
					TEST_ERRNO, tdat[testno].experrno);
			}
			if (tdat[testno].cleanup) {
				tdat[testno].cleanup();
			}
		}
	}
	cleanup();
	tst_exit();
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	int lc;

	tst_parse_opts(argc, argv, NULL, NULL);

	tst_tmpdir();
	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		/* reset tst_count in case we are looping */
		tst_count = 0;

		for (testno = 0; testno < TST_TOTAL; ++testno) {

			if ((tdat[testno].setup) && (tdat[testno].setup())) {
				/* setup() failed, skip this test */
				continue;
			}
			TEST(query_module(tdat[testno].modname,
					  tdat[testno].which, tdat[testno].buf,
					  tdat[testno].bufsize,
					  tdat[testno].ret_size));
			if ((TEST_RETURN == EXP_RET_VAL) &&
			    (TEST_ERRNO == tdat[testno].experrno)) {
				tst_resm(TPASS, "Expected %s, errno: %d",
					 tdat[testno].desc, TEST_ERRNO);
			} else {
				tst_resm(TFAIL, "Unexpected %s ; returned"
					 " %d (expected %d), errno %d (expected"
					 " %d)", tdat[testno].desc,
					 TEST_RETURN, EXP_RET_VAL,
					 TEST_ERRNO, tdat[testno].experrno);
			}
			if (tdat[testno].cleanup) {
				tdat[testno].cleanup();
			}
		}
	}
	cleanup();
	tst_exit();
}
Exemplo n.º 6
0
int main (int argc, char **argv)
{
  char *cwd;
  int i;
  char *path;
  gboolean error = FALSE;
  gchar *cache_file = NULL;
  gint first_file = 1;
  GString *contents;

  if (argc > 1 && strcmp (argv[1], "--update-cache") == 0)
    {
      cache_file = gtk_rc_get_im_module_file ();
      first_file = 2;
    }

  contents = g_string_new ("");
  g_string_append_printf (contents,
                          "# GTK+ Input Method Modules file\n"
                          "# Automatically generated file, do not edit\n"
                          "# Created by %s from gtk+-%d.%d.%d\n"
                          "#\n",
                          argv[0],
                          GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);

  if (argc == first_file)  /* No file arguments given */
    {
      char **dirs;
      int i;
      GHashTable *dirs_done;

      path = gtk_rc_get_im_module_path ();

      g_string_append_printf (contents, "# ModulesPath = %s\n#\n", path);

      dirs = pango_split_file_list (path);
      dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);

      for (i = 0; dirs[i]; i++)
        if (!g_hash_table_lookup (dirs_done, dirs[i]))
          {
            GDir *dir = g_dir_open (dirs[i], 0, NULL);
            if (dir)
              {
                const char *dent;

                while ((dent = g_dir_read_name (dir)))
                  {
                    if (g_str_has_suffix (dent, SOEXT))
                      error |= query_module (dirs[i], dent, contents);
                  }

                g_dir_close (dir);
              }

            g_hash_table_insert (dirs_done, dirs[i], GUINT_TO_POINTER (TRUE));
          }

      g_hash_table_destroy (dirs_done);
    }
  else
    {
      cwd = g_get_current_dir ();

      for (i = first_file; i < argc; i++)
        error |= query_module (cwd, argv[i], contents);

      g_free (cwd);
    }

  if (!error)
    {
      if (cache_file)
        {
          GError *err;

          err = NULL;
          if (!g_file_set_contents (cache_file, contents->str, -1, &err))
            {
                g_fprintf (stderr, "%s\n", err->message);
                error = 1;
            }
        }
      else
        g_print ("%s\n", contents->str);
    }

  return error ? 1 : 0;
}
Exemplo n.º 7
0
int main (int argc, char **argv)
{
  char *cwd;
  int i;
  char *path;
  gboolean error = FALSE;

  g_printf ("# GTK+ Input Method Modules file\n"
	    "# Automatically generated file, do not edit\n"
	    "# Created by %s from gtk+-%d.%d.%d\n"
	    "#\n",
	    argv[0],
	    GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);


  if (argc == 1)		/* No arguments given */
    {
      char **dirs;
      int i;
      GHashTable *dirs_done;

      path = gtk_rc_get_im_module_path ();

      g_printf ("# ModulesPath = %s\n#\n", path);

      dirs = pango_split_file_list (path);
      dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);

      for (i=0; dirs[i]; i++)
        if (!g_hash_table_lookup (dirs_done, dirs[i]))
          {
	    GDir *dir = g_dir_open (dirs[i], 0, NULL);
	    if (dir)
	      {
	        const char *dent;

	        while ((dent = g_dir_read_name (dir)))
	          {
	            if (g_str_has_suffix (dent, SOEXT))
	              error |= query_module (dirs[i], dent);
	          }
	        
	        g_dir_close (dir);
	      }

            g_hash_table_insert (dirs_done, dirs[i], GUINT_TO_POINTER (TRUE));
          }

      g_hash_table_destroy (dirs_done);
    }
  else
    {
      cwd = g_get_current_dir ();
      
      for (i=1; i<argc; i++)
	error |= query_module (cwd, argv[i]);

      g_free (cwd);
    }
  
  return error ? 1 : 0;
}