mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
file: change fd_new and flag converter
This commit is contained in:
@@ -59,7 +59,7 @@ void fd_release(file_t *file) {
|
|||||||
FILE_RELEASE(file);
|
FILE_RELEASE(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd_new(vnode_t *vnode, int flags, file_t **rfile, int *rfd) {
|
int fd_new(int flags, file_t **rfile, int *rfd) {
|
||||||
file_t *file = newfile();
|
file_t *file = newfile();
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
@@ -93,8 +93,6 @@ int fd_new(vnode_t *vnode, int flags, file_t **rfile, int *rfd) {
|
|||||||
|
|
||||||
spinlock_release(&proc->fdlock);
|
spinlock_release(&proc->fdlock);
|
||||||
|
|
||||||
VOP_HOLD(vnode);
|
|
||||||
file->vnode = vnode;
|
|
||||||
*rfile = file;
|
*rfile = file;
|
||||||
*rfd = fd;
|
*rfd = fd;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -20,8 +20,24 @@ typedef struct fd_t {
|
|||||||
|
|
||||||
file_t *fd_get(int fd);
|
file_t *fd_get(int fd);
|
||||||
void fd_release(file_t *file);
|
void fd_release(file_t *file);
|
||||||
int fd_new(vnode_t *node, int flags, file_t **file, int *fd);
|
int fd_new(int flags, file_t **file, int *fd);
|
||||||
int fd_close(int fd);
|
int fd_close(int fd);
|
||||||
int fd_dup(int oldfd, int newfd, bool exact, int flags, int *ret);
|
int fd_dup(int oldfd, int newfd, bool exact, int flags, int *ret);
|
||||||
|
|
||||||
|
#define FILE_READ 1
|
||||||
|
#define FILE_WRITE 2
|
||||||
|
#define FILE_KNOWN_FLAGS 3
|
||||||
|
|
||||||
|
static inline int fileflagstovnodeflags(int flags) {
|
||||||
|
int vnflags = 0;
|
||||||
|
if (flags & FILE_READ)
|
||||||
|
vnflags |= V_FFLAGS_READ;
|
||||||
|
if (flags & FILE_WRITE)
|
||||||
|
vnflags |= V_FFLAGS_WRITE;
|
||||||
|
|
||||||
|
return vnflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define AT_FDCWD -100
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user