git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
regression: mmap for fd
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
vfs.c
diff --git
a/lunaix-os/kernel/fs/vfs.c
b/lunaix-os/kernel/fs/vfs.c
index cc751b60e3537990f20c12358fd2123917dbd21b..cbe3c39ab507a8021d453b01ab38f07803858bdb 100644
(file)
--- a/
lunaix-os/kernel/fs/vfs.c
+++ b/
lunaix-os/kernel/fs/vfs.c
@@
-53,6
+53,7
@@
#include <lunaix/process.h>
#include <lunaix/spike.h>
#include <lunaix/syscall.h>
#include <lunaix/process.h>
#include <lunaix/spike.h>
#include <lunaix/syscall.h>
+#include <lunaix/syscall_utils.h>
#include <lunaix/fs/twifs.h>
#include <lunaix/fs/twifs.h>
@@
-266,11
+267,11
@@
vfs_pclose(struct v_file* file, pid_t pid)
atomic_fetch_sub(&file->dnode->ref_count, 1);
file->inode->open_count--;
atomic_fetch_sub(&file->dnode->ref_count, 1);
file->inode->open_count--;
- // Prevent dead lock.
- // This happened when process is terminated while blocking on read.
- // In that case, the process is still holding the inode lock and it will
- // never get released.
/*
/*
+ * Prevent dead lock.
+ * This happened when process is terminated while blocking on read.
+ * In that case, the process is still holding the inode lock and it
+ will never get released.
* The unlocking should also include ownership check.
*
* To see why, consider two process both open the same file both with
* The unlocking should also include ownership check.
*
* To see why, consider two process both open the same file both with
@@
-500,7
+501,12
@@
vfs_i_free(struct v_inode* inode)
pcache_release(inode->pg_cache);
vfree(inode->pg_cache);
}
pcache_release(inode->pg_cache);
vfree(inode->pg_cache);
}
- inode->ops->sync(inode);
+ // we don't need to sync inode.
+ // If an inode can be free, then it must be properly closed.
+ // Hence it must be synced already!
+ if (inode->destruct) {
+ inode->destruct(inode);
+ }
hlist_delete(&inode->hash_list);
cake_release(inode_pile, inode);
}
hlist_delete(&inode->hash_list);
cake_release(inode_pile, inode);
}
@@
-564,18
+570,17
@@
vfs_do_open(const char* path, int options)
{
int errno, fd;
struct v_dnode *dentry, *file;
{
int errno, fd;
struct v_dnode *dentry, *file;
- struct v_file* ofile =
0
;
+ struct v_file* ofile =
NULL
;
errno = __vfs_try_locate_file(
path, &dentry, &file, (options & FO_CREATE) ? FLOCATE_CREATE_EMPTY : 0);
errno = __vfs_try_locate_file(
path, &dentry, &file, (options & FO_CREATE) ? FLOCATE_CREATE_EMPTY : 0);
- if (errno || (errno = vfs_open(file, &ofile))) {
- return errno;
- }
+ if (!errno && !(errno = vfs_alloc_fdslot(&fd))) {
- struct v_inode* o_inode = ofile->inode;
+ if (errno || (errno = vfs_open(file, &ofile))) {
+ return errno;
+ }
- if (!errno && !(errno = vfs_alloc_fdslot(&fd))) {
struct v_fd* fd_s = cake_grab(fd_pile);
memset(fd_s, 0, sizeof(*fd_s));
struct v_fd* fd_s = cake_grab(fd_pile);
memset(fd_s, 0, sizeof(*fd_s));
@@
-626,7
+631,7
@@
__vfs_readdir_callback(struct dir_context* dctx,
dent->d_type = dtype;
}
dent->d_type = dtype;
}
-__DEFINE_LXSYSCALL2(int, readdir, int, fd, struct dirent*, dent)
+__DEFINE_LXSYSCALL2(int,
sys_
readdir, int, fd, struct dirent*, dent)
{
struct v_fd* fd_s;
int errno;
{
struct v_fd* fd_s;
int errno;