2022-09-12 23:56:31 +08:00

41 lines
1.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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);