Exemplo n.º 1
0
static int sniff_plugin_destroy() {
	plugin_unregister(&sniff_plugin);

	ekg_recode_cp_dec();
	ekg_recode_utf8_dec();
	return 0;
}
Exemplo n.º 2
0
static int xmsg_plugin_destroy(void)
{
	plugin_unregister(&xmsg_plugin);

	close(in_fd);
	xfree(ev);

return 0;
}
Exemplo n.º 3
0
static int do_erase(char *dev)
{
	int fd;
	size_t i;
	mtd_info_t mtd;

	fd = open(dev, O_RDWR | O_SYNC);
	if (-1 == fd)
		return 1;

	memset(&mtd, 0, sizeof(mtd));
	if (ioctl(fd, MEMGETINFO, &mtd) < 0 || mtd.erasesize <= 0) {
		close(fd);
		return 1;
	}
		
	for (i = 0; i < mtd.size / mtd.erasesize; i++) {
		erase_info_t this = {
			.start  = i * mtd.erasesize,
			.length = mtd.erasesize
		};

		/* Yield CPU once in a while, to not starve watchdogd */
		sched_yield();

		if (ioctl(fd, MEMERASE, &this) < 0) {
			close(fd);
			return 1;
		}
	}
	
	return close(fd);
}

static void mount_error (void *UNUSED(arg))
{
   struct mtd_info_user mtd;
   char dev[10];

   if (is_mounted("mtd:" MTD_CONFIG_LABEL))
      return;

   if (!find_mtd(MTD_CONFIG_LABEL, dev, sizeof(dev)))
      return;

   print_desc("Erasing corrupt configuration partition", NULL);
   print_result(do_erase(dev));

   /* Finit has not setup any signals yet, sys_reboot() won't work */
   reboot(RB_AUTOBOOT);
}

static plugin_t plugin = {
	.hook[HOOK_MOUNT_ERROR] = { .cb = mount_error },
};

PLUGIN_INIT(plugin_init)
{
	plugin_register(&plugin);
}

PLUGIN_EXIT(plugin_exit)
{
	plugin_unregister(&plugin);
}