kfusd/kfusd.c
static void fusd_status_build_text(fusd_statcontext_t *fs)
{
	int buf_size = 512;
	char *buf = KMALLOC(buf_size, GFP_KERNEL);
	int len = 0, total_clients = 0, total_files = 0;
	struct list_head *tmp;

	if (buf == NULL) {
		RDEBUG(1, "fusd_status_build: out of memory!");
		return;
	}

	len += snprintf(buf + len, buf_size - len,
	                "  PID  Open Name\n"
	                "------ ---- -----------------\n");

	down(&fusd_devlist_sem);

	list_for_each(tmp, &fusd_devlist_head)
	{
		fusd_dev_t *d = list_entry(tmp, fusd_dev_t, devlist);

		if (!d)
			continue;

		/* Possibly expand the buffer if we need more space */
		if (maybe_expand_buffer(&buf, &buf_size, len, FUSD_MAX_NAME_LENGTH + 120) < 0)
			goto out;

		len += snprintf(buf + len, buf_size - len,
		                "%6d %4d %s%s\n", d->pid, d->num_files,
		                d->zombie ? "<zombie>" : "", NAME(d));

		total_files++;
		total_clients += d->num_files;
	}

	len += snprintf(buf + len, buf_size - len,
	                "\nFUSD %s - %d devices used by %d clients\n",
	                GIT_DESCRIBE,
	                total_files, total_clients);

out:
	fs->last_version_seen = last_version;
	up(&fusd_devlist_sem);

	if (fs->curr_status)
		KFREE(fs->curr_status);

	fs->curr_status = buf;
	fs->curr_status_len = len;
	fs->need_new_status = 0;
}
/* Build a text buffer containing current fusd status. */
Build a text buffer containing current fusd status.
Build a text buffer containing current fusd status .
static void fusd_status_build_text(fusd_statcontext_t *fs)
{
	int buf_size = 512;
	char *buf = KMALLOC(buf_size, GFP_KERNEL);
	int len = 0, total_clients = 0, total_files = 0;
	struct list_head *tmp;
	if (buf == NULL) {
		RDEBUG(1, "fusd_status_build: out of memory!");
		return;
	}
	len += snprintf(buf + len, buf_size - len,
	                "  PID  Open Name\n"
	                "------ ---- -----------------\n");
	down(&fusd_devlist_sem);
	list_for_each(tmp, &fusd_devlist_head)
	{
		fusd_dev_t *d = list_entry(tmp, fusd_dev_t, devlist);
		if (!d)
			continue;
		if (maybe_expand_buffer(&buf, &buf_size, len, FUSD_MAX_NAME_LENGTH + 120) < 0)
			goto out;
		len += snprintf(buf + len, buf_size - len,
		                "%6d %4d %s%s\n", d->pid, d->num_files,
		                d->zombie ? "<zombie>" : "", NAME(d));
		total_files++;
		total_clients += d->num_files;
	}
	len += snprintf(buf + len, buf_size - len,
	                "\nFUSD %s - %d devices used by %d clients\n",
	                GIT_DESCRIBE,
	                total_files, total_clients);
out:
	fs->last_version_seen = last_version;
	up(&fusd_devlist_sem);
	if (fs->curr_status)
		KFREE(fs->curr_status);
	fs->curr_status = buf;
	fs->curr_status_len = len;
	fs->need_new_status = 0;
}
static void fusd_status_build_text ( fusd_statcontext_t * fs ) { int buf_size = 512 ; char * buf = KMALLOC ( buf_size , GFP_KERNEL ) ; int len = 0 , total_clients = 0 , total_files = 0 ; struct list_head * tmp ; if ( buf == NULL ) { RDEBUG ( 1 , " " ) ; return ; } len += snprintf ( buf + len , buf_size - len , " \n " " \n " ) ; down ( & fusd_devlist_sem ) ; list_for_each ( tmp , & fusd_devlist_head ) { fusd_dev_t * d = list_entry ( tmp , fusd_dev_t , devlist ) ; if ( ! d ) continue ; if ( maybe_expand_buffer ( & buf , & buf_size , len , FUSD_MAX_NAME_LENGTH + 120 ) < 0 ) goto out ; len += snprintf ( buf + len , buf_size - len , " \n " , d -> pid , d -> num_files , d -> zombie ? " " : " " , NAME ( d ) ) ; total_files ++ ; total_clients += d -> num_files ; } len += snprintf ( buf + len , buf_size - len , " \n \n " , GIT_DESCRIBE , total_files , total_clients ) ; out : fs -> last_version_seen = last_version ; up ( & fusd_devlist_sem ) ; if ( fs -> curr_status ) KFREE ( fs -> curr_status ) ; fs -> curr_status = buf ; fs -> curr_status_len = len ; fs -> need_new_status = 0 ; }
Build a text buffer containing current fusd status.
Build a text buffer containing current fusd status .
/* Possibly expand the buffer if we need more space */