Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/include/filedesc.h
2093 views
1
#ifndef __FILEDESCH__
2
#define __FILEDESCH__
3
4
#include <file.h>
5
6
#define MAX_OPEN_FILES 8
7
#define FD_RESERVED_SPOT 0xcafebabe
8
9
struct filedesc {
10
struct file *fd_ofiles[MAX_OPEN_FILES]; /* array of open files */
11
struct lock *fd_lk; /* a lock protecting the file descriptor table */
12
uint16_t fd_nfiles; /* how many open files we have */
13
};
14
15
void fd_clone( struct filedesc *, struct filedesc * );
16
int fd_create( struct filedesc ** );
17
void fd_destroy( struct filedesc * );
18
int fd_attach( struct filedesc *, struct file *, int * );
19
void fd_detach( struct filedesc *, int );
20
int fd_attach_into( struct filedesc *, struct file *, int );
21
22
#define FD_LOCK(x) (lock_acquire((x)->fd_lk))
23
#define FD_UNLOCK(x) (lock_release((x)->fd_lk))
24
25
#endif
26
27