-#include <lunaix/dirent.h>
#include <lunaix/fs/taskfs.h>
#include <lunaix/fs/twimap.h>
#include <lunaix/mm/valloc.h>
#include <lunaix/process.h>
#include <lunaix/sched.h>
-#include <klibc/stdio.h>
+#include <klibc/strfmt.h>
#include <klibc/string.h>
+#include <usr/lunaix/dirent_defs.h>
+
#define COUNTER_MASK ((1 << 16) - 1)
static struct hbucket* attr_export_table;
return 0;
}
+// ascii to pid
pid_t
taskfs_atop(const char* str)
{
if (!tattr || !(proc = get_process(pid)))
return ENOENT;
- int errno = taskfs_mknod(dnode, pid, taskfs_next_counter(), VFS_IFFILE);
+ int errno =
+ taskfs_mknod(dnode, pid, taskfs_next_counter(), VFS_IFSEQDEV);
if (!errno) {
tattr->map_file->data = proc;
dnode->inode->data = tattr->map_file;
return ENOENT;
}
- return taskfs_mknod(dnode, pid, 0, VFS_IFDIR);
+ return taskfs_mknod(dnode, pid, 0, F_DIR);
}
static struct v_file_ops taskfs_file_ops = { .close = default_file_close,
.read = default_file_read,
+ .read_page = default_file_read,
.write = default_file_write,
+ .write_page = default_file_write,
.readdir = taskfs_readdir,
.seek = default_file_seek };
static struct v_inode_ops taskfs_inode_ops = { .dir_lookup = taskfs_dirlookup,
inode->ops = &taskfs_inode_ops;
}
+static volatile struct v_superblock* taskfs_sb;
+
int
taskfs_mount(struct v_superblock* vsb, struct v_dnode* mount_point)
{
+ taskfs_sb = vsb;
vsb->ops.init_inode = taskfs_init_inode;
return taskfs_mknod(mount_point, 0, 0, VFS_IFDIR);
}
+void
+taskfs_invalidate(pid_t pid)
+{
+ struct v_dnode *pos, *n;
+ struct v_inode* inode = vfs_i_find(taskfs_sb, taskfs_inode_id(pid, 0));
+
+ if (!inode)
+ return;
+
+ llist_for_each(pos, n, &inode->aka_dnodes, aka_list)
+ {
+ if (pos->ref_count > 1) {
+ continue;
+ }
+ vfs_d_free(pos);
+ }
+}
+
#define ATTR_TABLE_LEN 16
void
attr_export_table = vcalloc(ATTR_TABLE_LEN, sizeof(struct hbucket));
export_task_attr();
-}
\ No newline at end of file
+}
+EXPORT_FILE_SYSTEM(taskfs, taskfs_init);
\ No newline at end of file