Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
vfsuio.h File Reference
#include <sys/handle.h>
Include dependency graph for vfsuio.h:

Go to the source code of this file.

Functions

int VFSUIO_Open (const char *path, Handle **handle)
 

Function Documentation

◆ VFSUIO_Open()

int VFSUIO_Open ( const char *  path,
Handle **  handle 
)

Definition at line 56 of file vfsuio.c.

57{
58 int status;
59
60 Handle *hdl = Handle_Alloc();
61 if (!hdl) {
62 return -ENOMEM;
63 }
64
65 VNode *vn = VFS_Lookup(path);
66 if (!vn) {
67 Handle_Free(hdl);
68 return -ENOENT;
69 }
70
71 status = VFS_Open(vn);
72 if (status != 0) {
73 // XXX: Release VNode
74 Handle_Free(hdl);
75 return status;
76 }
77
78 hdl->vnode = vn;
80 hdl->read = VFSUIO_Read;
81 hdl->write = VFSUIO_Write;
82 hdl->flush = VFSUIO_Flush;
83 hdl->close = VFSUIO_Close;
84
85 *handle = hdl;
86
87 return 0;
88}
#define ENOENT
Definition: errno.h:15
#define ENOMEM
Definition: errno.h:14
#define HANDLE_TYPE_FILE
Definition: handle.h:12
Definition: handle.h:17
uint64_t type
Definition: handle.h:19
int(* close)(Handle *)
Definition: handle.h:26
VNode * vnode
Definition: handle.h:21
int(* write)(Handle *, void *, uint64_t, uint64_t)
Definition: handle.h:24
int(* read)(Handle *, void *, uint64_t, uint64_t)
Definition: handle.h:23
int(* flush)(Handle *)
Definition: handle.h:25
VNode * VFS_Lookup(const char *path)
Definition: vfs.c:63
int VFS_Open(VNode *fn)
Definition: vfs.c:147
Definition: vfs.h:24
static int VFSUIO_Write(Handle *handle, void *buf, uint64_t len, uint64_t off)
Definition: vfsuio.c:26
static int VFSUIO_Read(Handle *handle, void *buf, uint64_t len, uint64_t off)
Definition: vfsuio.c:16
static int VFSUIO_Flush(Handle *handle)
Definition: vfsuio.c:36
static int VFSUIO_Close(Handle *handle)
Definition: vfsuio.c:43
Here is the call graph for this function:
Here is the caller graph for this function: