Ejemplo n.º 1
0
static int get_index(struct sock *sk) {
	struct idesc_table *it;

	it = task_resource_idesc_table(task_self());
	assert(it);

	return idesc_table_add(it, (struct idesc *)sk, 0);
}
Ejemplo n.º 2
0
int diag_fd(void) {
	struct idesc_table *idesc_table;

	idesc_table = task_resource_idesc_table(task_self());
	if (!idesc_table) {
		return -ENOSYS;
	}

	idesc_init(&diag_idesc, &diag_idx_ops, FS_MAY_READ | FS_MAY_WRITE);

	return idesc_table_add(idesc_table, &diag_idesc, 0);
}
Ejemplo n.º 3
0
int diag_fd(void) {
	struct idesc_table *idesc_table;

	idesc_table = task_resource_idesc_table(task_self());
	if (!idesc_table) {
		return -ENOSYS;
	}

	idesc_init(&diag_idesc, &diag_idx_ops, S_IROTH | S_IWOTH);

	return idesc_table_add(idesc_table, &diag_idesc, 0);
}
Ejemplo n.º 4
0
int pipe2(int pipefd[2], int flags) {
	struct idesc_table *it;
	struct pipe *pipe;
	int res = 0;

	it = task_resource_idesc_table(task_self());
	assert(it);


	pipe = pipe_alloc();
	if (!pipe) {
		res = ENOMEM;
		goto out_err;
	}


	idesc_pipe_init(&pipe->read_desc, pipe, FS_MAY_READ);
	idesc_pipe_init(&pipe->write_desc, pipe, FS_MAY_WRITE);


	pipefd[0] = idesc_table_add(it, &pipe->read_desc.idesc, flags);
	pipefd[1] = idesc_table_add(it, &pipe->write_desc.idesc, flags);

	if (pipefd[0] < 0 || pipefd[1] < 0) {
		res = ENOMEM;
		goto out_err;
	}

	return 0;

out_err:
	if (pipefd[1] >= 0) {
		idesc_table_del(it, pipefd[1]);
	}
	if (pipefd[0] >= 0) {
		idesc_table_del(it, pipefd[0]);
	}
	if (pipe) {
		pipe_free(pipe);
	}

	SET_ERRNO(res);
	return -1;
}
Ejemplo n.º 5
0
int open(const char *path, int __oflag, ...) {
	struct file *file;
	struct idesc_table *it;
	int res;

	file = dvfs_alloc_file();
	if (file == NULL)
		return SET_ERRNO(ENOMEM);

	res = dvfs_open(path, file, __oflag);
	if (res) {
		dvfs_destroy_file(file);
		return SET_ERRNO(-res);
	}

	it = task_resource_idesc_table(task_self());
	res = idesc_table_add(it, (struct idesc *) file, 0);

	if (res >= 0)
		return res;

	dvfs_destroy_file(file);
	return SET_ERRNO(ENOMEM);
}