2020-01-06 20:25:06 +01:00
|
|
|
#include <kernel/fs/vfs.h>
|
|
|
|
#include <kernel/process.h>
|
|
|
|
|
|
|
|
int sys_close(int fd)
|
|
|
|
{
|
2020-01-14 18:41:28 +01:00
|
|
|
extern struct process *process_current;
|
|
|
|
|
2020-03-20 22:47:05 +01:00
|
|
|
// Check fd validity
|
2020-05-01 11:23:56 +02:00
|
|
|
if (fd < 0 || fd >= PROCESS_NB_OPEN_FILE)
|
2020-01-14 18:41:28 +01:00
|
|
|
return (-1);
|
|
|
|
|
2020-03-20 22:47:05 +01:00
|
|
|
// Call VFS close primitive
|
2020-05-01 11:23:56 +02:00
|
|
|
return (vfs_close(&process_current->opfile[fd].file));
|
2020-01-06 20:25:06 +01:00
|
|
|
}
|