Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/include/file.h
2093 views
1
#ifndef __FILEH__
2
#define __FILEH__
3
4
#include <vnode.h>
5
#include <synch.h>
6
#include <proc.h>
7
8
#define MAX_FILE_NAME 32
9
10
struct proc;
11
12
struct file {
13
struct vnode *f_vnode; /* vnode associated with the file */
14
uint16_t f_oflags; /* open flags */
15
uint16_t f_refcount; /* reference count */
16
off_t f_offset; /* file offset */
17
struct lock *f_lk; /* lock for IO atomicity */
18
};
19
20
int file_get(struct proc *, int, struct file ** );
21
int file_close_descriptor( struct proc *, int );
22
int file_close( struct proc *, struct file * );
23
int file_create( struct vnode *, int, struct file ** );
24
bool file_descriptor_exists( struct proc *, int );
25
void file_destroy( struct file * );
26
int file_close_all( struct proc * );
27
28
29
//helper function to open() files from inside the kernel.
30
int ___open( struct proc *, char *, int, int *);
31
32
#define F_LOCK(x) (lock_acquire((x)->f_lk))
33
#define F_UNLOCK(x) (lock_release((x)->f_lk))
34
35
#endif
36
37