bugfix: 修复了fat32_mkdir的bug(在非根目录下创建文件夹会出错)(在/dev中创建子文件夹,opendir时属性设置错误的bug)

This commit is contained in:
fslongjin
2022-07-06 17:10:54 +08:00
parent 52b5c2731d
commit b79ba099df
6 changed files with 98 additions and 45 deletions

View File

@ -156,10 +156,13 @@ uint64_t sys_open(struct pt_regs *regs)
// 暂时遇到设备文件的话就将其first clus设置为特定值
if (path_len >= 5 && filename[0] == '/' && filename[1] == 'd' && filename[2] == 'e' && filename[3] == 'v' && filename[4] == '/')
{
// 对于fat32文件系统上面的设备文件设置其起始扇区
((struct fat32_inode_info_t *)(dentry->dir_inode->private_inode_info))->first_clus |= 0xf0000000;
dentry->dir_inode->sb->sb_ops->write_inode(dentry->dir_inode);
dentry->dir_inode->attribute |= VFS_ATTR_DEVICE;
if (dentry->dir_inode->attribute & VFS_ATTR_FILE)
{
// 对于fat32文件系统上面的设备文件设置其起始扇区
((struct fat32_inode_info_t *)(dentry->dir_inode->private_inode_info))->first_clus |= 0xf0000000;
dentry->dir_inode->sb->sb_ops->write_inode(dentry->dir_inode);
dentry->dir_inode->attribute |= VFS_ATTR_DEVICE;
}
}
// 创建文件描述符
@ -483,7 +486,7 @@ uint64_t sys_reboot(struct pt_regs *regs)
uint64_t sys_chdir(struct pt_regs *regs)
{
char *dest_path = (char *)regs->r8;
// kdebug("dest_path=%s", dest_path);
kdebug("dest_path=%s", dest_path);
// 检查目标路径是否为NULL
if (dest_path == NULL)
return -EFAULT;
@ -517,14 +520,14 @@ uint64_t sys_chdir(struct pt_regs *regs)
}
else
strncpy(path, dest_path, dest_path_len + 1);
kdebug("chdir: path = %s", path);
struct vfs_dir_entry_t *dentry = vfs_path_walk(path, 0);
kfree(path);
if (dentry == NULL)
return -ENOENT;
kdebug("dentry->name=%s, namelen=%d", dentry->name, dentry->name_length);
// 目标不是目录
if (dentry->dir_inode->attribute != VFS_ATTR_DIR)
return -ENOTDIR;