return(ret_val);
}
+
+/*
+ * proc_get_fd() - Look up a file descriptor using its number
+ *
+ * SYNOPSIS
+ * int proc_get_fd(struct proc *proc, const int fd, struct filedesc **dst);
+ *
+ * DESCRIPTION
+ * The proc_get_fd() function retrieves the file descriptor structure that is associated with the
+ * descriptor number `fd' in the process pointed to by `proc'. Upon success, the pointer pointed
+ * to by `dst' will be adjusted to point to the file descriptor.
+ *
+ * RETURN VALUE
+ * Upon success, zero is returned. Otherwise, a negative error number is returned and the value
+ * of `*dst' is undefined.
+ *
+ * ERRORS
+ * -EINVAL Invalid arguments have been passed to the function
+ * -ENOENT There is no file descriptor associated with the file descriptor number `fd'
+ */
+int proc_get_fd(struct proc *proc, const int fd, struct filedesc **dst)
+{
+ int ret_val;
+
+ ret_val = -EINVAL;
+
+ if(proc && fd >= 0 && dst) {
+ ret_val = -ENOENT;
+
+ if(!cx_array_get(proc->p_fds, fd, (void**)dst)) {
+ ret_val = 0;
+ }
+ }
+
+ return(ret_val);
+}
void proc_free(struct proc*);
int proc_add_fd(struct proc*, struct filedesc*);
+int proc_get_fd(struct proc*, const int, struct filedesc**);
#endif /* PROC_H */