/* Returns the domainname which the specified PID is in on success, empty string otherwise. The PID is specified by tomoyo_write_pid() so that the user can obtain using read()/write() interface rather than sysctl() interface.  */
static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
/* Returns the domainname which the specified PID is in on success, empty string otherwise. The PID is specified by tomoyo_write_pid() so that the user can obtain using read()/write() interface rather than sysctl() interface.  */
static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
{
	if (head->read_avail == 0 && !head->read_eof) {
		const int pid = head->read_step;
		struct task_struct *p;
		struct tomoyo_domain_info *domain = NULL;
		read_lock(&tasklist_lock);
		p = find_task_by_vpid(pid);
		if (p)
			domain = tomoyo_real_domain(p);
		read_unlock(&tasklist_lock);
		if (domain)
			tomoyo_io_printf(head, "%d %u %s", pid, domain->profile,
					 domain->domainname->name);
		head->read_eof = true;
	}
	return 0;
}