new: devfs删除文件夹

This commit is contained in:
fslongjin
2022-09-12 23:56:31 +08:00
parent d60f1a8f80
commit 9f2b080cda
24 changed files with 366 additions and 92 deletions

View File

@ -0,0 +1,41 @@
#pragma once
#include "VFS.h"
#include "mount.h"
/**
* @brief 判断是否可以删除指定的dentry
*
* 1、我们不能删除一个只读的dentry
* 2、我们应当对这个dentry拥有写、执行权限暂时还没有实现权限
* 3、如果dentry指向的是文件夹而isdir为false则不能删除
* 3、如果dentry指向的是文件而isdir为true则不能删除
* @param dentry 将要被删除的dentry
* @param isdir 是否要删除文件夹
* @return int 错误码
*/
int vfs_may_delete(struct vfs_dir_entry_t *dentry, bool isdir);
#define D_ISDIR(dentry) ((dentry)->dir_inode->attribute & VFS_IF_DIR)
// 判断是否为根目录
#define IS_ROOT(x) ((x) == (x)->parent)
/**
* @brief 判断当前dentry是否为挂载点
*
* @param dentry
*/
static inline bool is_local_mountpoint(struct vfs_dir_entry_t *dentry)
{
if (D_MOUNTED(dentry))
return true;
else
return false;
}
/**
* @brief 释放dentry
*
* @param dentry 目标dentry
*/
void vfs_dentry_put(struct vfs_dir_entry_t * dentry);