Skip to content

Commit

Permalink
🐛 iso9660 readdir
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenBaby committed Oct 25, 2023
1 parent 3557848 commit a3fce18
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/fs/iso9660/iso9660.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define ISO_FLAG_EXTUSR 0x10 // 扩展所有者和组权限
#define ISO_FLAG_LONG 0x80 // 大文件

#define MAX_DENTRY_SIZE 256

typedef struct iso_dentry_t
{
u8 length; // 目录记录的长度
Expand Down Expand Up @@ -439,19 +441,23 @@ int iso_read(inode_t *inode, char *data, int size, off_t offset)

int iso_readdir(inode_t *inode, dentry_t *entry, size_t count, off_t offset)
{
void *buf = kmalloc(256);
void *buf = kmalloc(MAX_DENTRY_SIZE);
int ret = EOF;
iso_dentry_t *desc = inode->desc;
if (offset >= desc->size)
goto rollback;

if ((ret = iso_read(inode, (char *)buf, 256, offset)) < 0)
if ((ret = iso_read(inode, (char *)buf, MAX_DENTRY_SIZE, offset)) < 0)
goto rollback;

iso_dentry_t *mentry = buf;
if (mentry->length == 0)
{
ret = EOF;
entry->length = 0;
entry->namelen = 0;
entry->nr = 0;
ret = ((offset / BLOCK_SIZE) + 1) * BLOCK_SIZE;
ret -= offset;
goto rollback;
}

Expand Down

0 comments on commit a3fce18

Please sign in to comment.