Beispiel #1
0
/* Helper, copies a pathname from the process into the kernel.  Returns a string
 * on success, which you must free with free_path.  Returns 0 on failure and
 * sets errno. */
char *copy_in_path(struct proc *p, const char *path, size_t path_l)
{
	struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
	char *t_path;

	/* PATH_MAX includes the \0 */
	if (path_l > PATH_MAX) {
		set_errno(ENAMETOOLONG);
		return 0;
	}
	t_path = user_strdup_errno(p, path, path_l);
	if (!t_path)
		return 0;
	return t_path;
}
Beispiel #2
0
ssize_t dev_stdout_write(struct file *file, const char *buf, size_t count,
                         off64_t *offset)
{
	char *t_buf;
	struct proc *p = current;
	if (p)
		t_buf = user_strdup_errno(p, buf, count);
	else
		t_buf = (char*)buf;
	if (!t_buf)
		return -1;
	/* TODO: tty hack.  they are sending us an escape sequence, and the keyboard
	 * would try to print it (which it can't do yet).  The hack is even dirtier
	 * in that we only detect it if it is the first char, and we ignore
	 * everything else. */
	if (t_buf[0] == '\033') /* 0x1b */
		return count;
	cputbuf(t_buf, count);
	return count;
}