summaryrefslogtreecommitdiff
path: root/src/sys/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/include')
-rw-r--r--src/sys/include/compat/unix/syscall.h8
-rw-r--r--src/sys/include/os/filedesc.h12
-rw-r--r--src/sys/include/os/vnode.h20
-rw-r--r--src/sys/include/sys/proc.h17
-rw-r--r--src/sys/include/sys/syscall.h1
5 files changed, 52 insertions, 6 deletions
diff --git a/src/sys/include/compat/unix/syscall.h b/src/sys/include/compat/unix/syscall.h
index be351e8..a031872 100644
--- a/src/sys/include/compat/unix/syscall.h
+++ b/src/sys/include/compat/unix/syscall.h
@@ -68,6 +68,11 @@ scret_t sys_open(struct syscall_args *scargs);
*/
scret_t sys_read(struct syscall_args *scargs);
+/*
+ * Close a file
+ */
+scret_t sys_close(struct syscall_args *scargs);
+
#ifdef _NEED_UNIX_SCTAB
scret_t(*g_unix_sctab[])(struct syscall_args *) = {
[SYS_none] = NULL,
@@ -83,7 +88,8 @@ scret_t(*g_unix_sctab[])(struct syscall_args *) = {
[SYS_reboot] = sys_reboot,
[SYS_waitpid] = sys_waitpid,
[SYS_dmsio] = sys_dmsio,
- [SYS_read] = sys_read
+ [SYS_read] = sys_read,
+ [SYS_close] = sys_close
};
#endif /* !_NEED_UNIX_SCTAB */
diff --git a/src/sys/include/os/filedesc.h b/src/sys/include/os/filedesc.h
index 8cdf161..a6a2ac5 100644
--- a/src/sys/include/os/filedesc.h
+++ b/src/sys/include/os/filedesc.h
@@ -39,11 +39,13 @@ struct proc;
* Represents a file descriptor
*
* @fdno: File descriptor index
+ * @off: Current file offset
* @vp: Vnode this fd is linked with
* @mode: File attributes
*/
struct filedesc {
int fdno;
+ off_t off;
struct vnode *vp;
mode_t mode;
};
@@ -82,6 +84,16 @@ int fdtab_init(struct proc *procp);
int fd_open(const char *path, mode_t mode);
/*
+ * Close a file
+ *
+ * @fd: File descriptor to close
+ *
+ * Returns zero on success, otherwise a less than
+ * zero value on failure
+ */
+int fd_close(int fd);
+
+/*
* Write to a file descriptor
*
* @fd: File descriptor to write to
diff --git a/src/sys/include/os/vnode.h b/src/sys/include/os/vnode.h
index 868e137..1bef1e2 100644
--- a/src/sys/include/os/vnode.h
+++ b/src/sys/include/os/vnode.h
@@ -72,11 +72,13 @@ struct vop_lookup_args {
*
* @data: Buffer containing I/O data
* @len: Length of buffer
+ * @off: Offset of operation
* @vp: Current vnode
*/
struct vop_rw_data {
void *data;
size_t len;
+ off_t off;
struct vnode *vp;
};
@@ -86,6 +88,7 @@ struct vop_rw_data {
*/
struct vop {
int(*lookup)(struct vop_lookup_args *args);
+ int(*reclaim)(struct vnode *vp, int flags);
ssize_t(*write)(struct vop_rw_data *data);
ssize_t(*read)(struct vop_rw_data *data);
};
@@ -141,23 +144,36 @@ int vfs_vrel(struct vnode *vp, int flags);
*
* @vp: Vnode to write to
* @data: Data to write
+ * @off: Offset to write at
* @len: Length of bytes to write
*
* Returns the number of bytes written on success, otherwise
* a less than zero value on failure.
*/
-ssize_t vop_write(struct vnode *vp, char *data, size_t len);
+ssize_t vop_write(struct vnode *vp, char *data, off_t off, size_t len);
/*
* Wrapper for the read write callback
*
* @vp: Vnode to read from
* @data: Read data written here
+ * @off: Offset to read at
* @len: Length of bytes to read
*
* Returns the number of bytes read on success, otherwise
* a less than zero value on failure.
*/
-ssize_t vop_read(struct vnode *vp, char *data, size_t len);
+ssize_t vop_read(struct vnode *vp, char *data, off_t off, size_t len);
+
+/*
+ * Reclaim the resources tied to a specific vnode
+ *
+ * @vp: Vnode to reclaim
+ * @flags: Optional flags
+ *
+ * Returns zero on success, otherwise a less than zero value
+ * on failure.
+ */
+int vop_reclaim(struct vnode *vp, int flags);
#endif /* !_OS_VNODE_H_ */
diff --git a/src/sys/include/sys/proc.h b/src/sys/include/sys/proc.h
index 618ddf3..a547233 100644
--- a/src/sys/include/sys/proc.h
+++ b/src/sys/include/sys/proc.h
@@ -101,6 +101,10 @@ struct proc {
#define PROC_EXITING BIT(0) /* Process is exiting */
#define PROC_SLEEPING BIT(1) /* Process is sleeping */
+#define PROC_KTD BIT(2) /* Process is kernel thread */
+
+/* Flags for PROC_SPAWN */
+#define SPAWN_KTD BIT(0) /* Spawn kernel thread */
/*
* Initialize a process into a basic minimal
@@ -136,6 +140,14 @@ struct proc *proc_self(void);
int proc_add_range(struct proc *procp, vaddr_t va, paddr_t pa, size_t len);
/*
+ * Spawn a kernel thread
+ *
+ * @procp_res: Result is written here
+ * @fn: Function where kernel thread should end up
+ */
+int proc_ktd(struct proc **procp_res, void(*fn)(void *));
+
+/*
* Kill a process with a specific status code
*
* @procp: Process to kill
@@ -210,8 +222,7 @@ int proc_check_addr(struct proc *proc, uintptr_t addr, size_t len);
*
* @proc: Process to put to sleep
*
- * Returns zero if the address is within the process bounds,
- * otherwise a less than zero value on failure.
+ * Returns zero on success
*/
int proc_sleep(struct proc *proc);
@@ -244,7 +255,7 @@ void md_proc_sleep(void);
* Put the current process into a halt loop
* until the next one runs.
*/
-__dead void md_proc_yield(void);
+__dead void md_proc_idle(void);
/*
* Kick a process into a user context
diff --git a/src/sys/include/sys/syscall.h b/src/sys/include/sys/syscall.h
index 1138029..77b7505 100644
--- a/src/sys/include/sys/syscall.h
+++ b/src/sys/include/sys/syscall.h
@@ -57,6 +57,7 @@
#define SYS_waitpid 0x0C /* wait for child to exit */
#define SYS_dmsio 0x0D /* DMS I/O */
#define SYS_read 0x0E /* read a file descriptor */
+#define SYS_close 0x0F /* close a file */
typedef __ssize_t scret_t;
typedef __ssize_t scarg_t;