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
Unifying the Lunaix's Physical Memory Model (#28)
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
ramfs
/
ramfs.c
diff --git
a/lunaix-os/kernel/fs/ramfs/ramfs.c
b/lunaix-os/kernel/fs/ramfs/ramfs.c
index 37f8869ac6ca3ec322d3f87e4dc4a610adcaa4a3..ca40efb4a2128ef33fd4df9c7b9a1e8bf55e1f22 100644
(file)
--- a/
lunaix-os/kernel/fs/ramfs/ramfs.c
+++ b/
lunaix-os/kernel/fs/ramfs/ramfs.c
@@
-41,7
+41,7
@@
'mountibility' for other fs.
*/
'mountibility' for other fs.
*/
-
volatile static
inode_t ino = 0;
+
static volatile
inode_t ino = 0;
extern const struct v_inode_ops ramfs_inode_ops;
extern const struct v_file_ops ramfs_file_ops;
extern const struct v_inode_ops ramfs_inode_ops;
extern const struct v_file_ops ramfs_file_ops;
@@
-65,9
+65,7
@@
__ramfs_mknod(struct v_dnode* dnode, struct v_inode** nod_out, u32_t flags)
rinode->flags = flags;
inode->data = rinode;
rinode->flags = flags;
inode->data = rinode;
- if ((flags & RAMF_DIR)) {
- inode->itype = VFS_IFDIR;
- } else {
+ if (!(flags & RAMF_DIR)) {
inode->itype = VFS_IFFILE;
}
inode->itype = VFS_IFFILE;
}
@@
-119,8
+117,8
@@
void
ramfs_inode_init(struct v_superblock* vsb, struct v_inode* inode)
{
inode->id = ino++;
ramfs_inode_init(struct v_superblock* vsb, struct v_inode* inode)
{
inode->id = ino++;
- inode->ops = &ramfs_inode_ops;
- inode->default_fops = &ramfs_file_ops;
+ inode->ops =
(struct v_inode_ops*)
&ramfs_inode_ops;
+ inode->default_fops =
(struct v_file_ops*)
&ramfs_file_ops;
}
int
}
int
@@
-146,6
+144,7
@@
ramfs_init()
fsm_register(ramfs);
}
fsm_register(ramfs);
}
+EXPORT_FILE_SYSTEM(ramfs, ramfs_init);
int
ramfs_mksymlink(struct v_inode* this, const char* target)
int
ramfs_mksymlink(struct v_inode* this, const char* target)
@@
-154,7
+153,7
@@
ramfs_mksymlink(struct v_inode* this, const char* target)
assert(!(rinode->flags & RAMF_SYMLINK));
assert(!(rinode->flags & RAMF_SYMLINK));
- size_t len = strlen(target);
+ size_t len = strlen(target)
+ 1
;
char* symlink = valloc(len);
if (!symlink) {
char* symlink = valloc(len);
if (!symlink) {
@@
-192,8
+191,10
@@
ramfs_unlink(struct v_inode* this)
if ((rinode->flags & RAMF_SYMLINK)) {
rinode->flags &= ~RAMF_SYMLINK;
this->itype &= ~VFS_IFSYMLINK;
if ((rinode->flags & RAMF_SYMLINK)) {
rinode->flags &= ~RAMF_SYMLINK;
this->itype &= ~VFS_IFSYMLINK;
+
vfree(rinode->symlink);
vfree(rinode->symlink);
- return;
+
+ return 0;
}
// TODO
}
// TODO
@@
-215,7
+216,8
@@
const struct v_inode_ops ramfs_inode_ops = { .mkdir = ramfs_mkdir,
const struct v_file_ops ramfs_file_ops = { .readdir = ramfs_readdir,
.close = default_file_close,
.read = default_file_read,
const struct v_file_ops ramfs_file_ops = { .readdir = ramfs_readdir,
.close = default_file_close,
.read = default_file_read,
- .read_page = default_file_read,
+ .read_page = default_file_read
_page
,
.write = default_file_write,
.write = default_file_write,
- .write_page = default_file_write,
+ .write_page =
+ default_file_write_page,
.seek = default_file_seek };
\ No newline at end of file
.seek = default_file_seek };
\ No newline at end of file