+
+int
+vfs_dup_fd(struct v_fd* old, struct v_fd** new);
+
+int
+vfs_getfd(int fd, struct v_fd** fd_s);
+
+int
+vfs_get_dtype(int itype);
+
+int
+vfs_get_path(struct v_dnode* dnode, char* buf, size_t size, int depth);
+
+void
+pcache_init(struct pcache* pcache);
+
+int
+pcache_write(struct v_inode* inode, void* data, u32_t len, u32_t fpos);
+
+int
+pcache_read(struct v_inode* inode, void* data, u32_t len, u32_t fpos);
+
+void
+pcache_release(struct pcache* pcache);
+
+int
+pcache_commit(struct v_inode* inode, struct pcache_pg* page);
+
+void
+pcache_commit_all(struct v_inode* inode);
+
+void
+pcache_invalidate(struct pcache* pcache, struct pcache_pg* page);
+
+/**
+ * @brief 将挂载点标记为繁忙
+ *
+ * @param mnt
+ */
+void
+mnt_mkbusy(struct v_mount* mnt);
+
+/**
+ * @brief 将挂载点标记为清闲
+ *
+ * @param mnt
+ */
+void
+mnt_chillax(struct v_mount* mnt);
+
+int
+vfs_mount_root(const char* fs_name, struct device* device);
+
+static inline bool
+mnt_check_busy(struct v_mount* mnt)
+{
+ return mnt->busy_counter > 1;
+}
+
+static inline void
+vfs_ref_dnode(struct v_dnode* dnode)
+{
+ dnode->ref_count++;
+
+ if (likely(dnode->mnt)) {
+ mnt_mkbusy(dnode->mnt);
+ }
+}
+
+static inline void
+vfs_unref_dnode(struct v_dnode* dnode)
+{
+ dnode->ref_count--;
+
+ if (likely(dnode->mnt)) {
+ mnt_chillax(dnode->mnt);
+ }
+}
+
+static inline void
+vfs_ref_file(struct v_file* file)
+{
+ file->ref_count++;
+}
+
+static inline void
+vfs_unref_file(struct v_file* file)
+{
+ file->ref_count--;
+}
+
+static inline bool
+vfs_check_duped_file(struct v_file* file)
+{
+ return file->ref_count > 1;
+}
+
+int
+vfs_check_writable(struct v_dnode* dnode);
+
+int
+default_file_read(struct v_inode* inode, void* buffer, size_t len, size_t fpos);
+
+int
+default_file_write(struct v_inode* inode,
+ void* buffer,
+ size_t len,
+ size_t fpos);
+
+int
+default_file_read_page(struct v_inode* inode, void* buffer, size_t fpos);
+
+int
+default_file_write_page(struct v_inode* inode, void* buffer, size_t fpos);
+
+int
+default_file_readdir(struct v_file* file, struct dir_context* dctx);
+
+int
+default_inode_dirlookup(struct v_inode* this, struct v_dnode* dnode);
+
+int
+default_inode_rename(struct v_inode* from_inode,
+ struct v_dnode* from_dnode,
+ struct v_dnode* to_dnode);
+
+int
+default_file_close(struct v_file* file);
+
+int
+default_file_seek(struct v_file* file, size_t offset);
+
+int
+default_inode_open(struct v_inode* this, struct v_file* file);
+
+int
+default_inode_rmdir(struct v_inode* this, struct v_dnode* dir);
+
+int
+default_inode_mkdir(struct v_inode* this, struct v_dnode* dir);
+
+struct v_xattr_entry*
+xattr_new(struct hstr* name);
+
+struct v_xattr_entry*
+xattr_getcache(struct v_inode* inode, struct hstr* name);
+
+void
+xattr_addcache(struct v_inode* inode, struct v_xattr_entry* xattr);
+
+
+/* --- misc stuff --- */
+
+#define check_itype(to_check, itype) \
+ (((to_check) & (itype)) == (itype))
+
+/**
+ * @brief Check if node represent a regular file (nothing but a file)
+ *
+ * @param inode
+ * @return true
+ * @return false
+ */
+static inline bool
+check_regfile_node(struct v_inode* inode)
+{
+ return inode->itype == VFS_IFFILE;
+}
+
+/**
+ * @brief Check if node represent a file.
+ * This is basically everything within file system (dir, dev, etc.)
+ *
+ * @param inode
+ * @return true
+ * @return false
+ */
+static inline bool
+check_file_node(struct v_inode* inode)
+{
+ return check_itype(inode->itype, VFS_IFFILE);
+}
+
+static inline bool
+check_directory_node(struct v_inode* inode)
+{
+ return check_itype(inode->itype, VFS_IFDIR);
+}
+
+static inline bool
+check_device_node(struct v_inode* inode)
+{
+ return check_itype(inode->itype, VFS_IFDEV);
+}
+
+static inline bool
+check_seqdev_node(struct v_inode* inode)
+{
+ return check_device_node(inode);
+}
+
+static inline bool
+check_voldev_node(struct v_inode* inode)
+{
+ return check_itype(inode->itype, VFS_IFVOLDEV);
+}
+
+static inline bool
+check_symlink_node(struct v_inode* inode)
+{
+ return check_itype(inode->itype, VFS_IFSYMLINK);
+}
+
+static inline bool
+check_allow_ops(struct v_inode* inode, unsigned int perm)
+{
+ return fsacl_allow_ops(perm, inode->acl, inode->uid, inode->gid);
+}
+
+static inline bool
+check_allow_read(struct v_inode* inode)
+{
+ return check_allow_ops(inode, FSACL_aR);
+}
+
+static inline bool
+check_allow_write(struct v_inode* inode)
+{
+ return check_allow_ops(inode, FSACL_aW);
+}
+
+static inline bool
+check_allow_execute(struct v_inode* inode)
+{
+ return check_allow_ops(inode, FSACL_aX);
+}
+