Skip to content

Commit a3fce18

Browse files
committed
🐛 iso9660 readdir
1 parent 3557848 commit a3fce18

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/fs/iso9660/iso9660.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define ISO_FLAG_EXTUSR 0x10 // 扩展所有者和组权限
3535
#define ISO_FLAG_LONG 0x80 // 大文件
3636

37+
#define MAX_DENTRY_SIZE 256
38+
3739
typedef struct iso_dentry_t
3840
{
3941
u8 length; // 目录记录的长度
@@ -439,19 +441,23 @@ int iso_read(inode_t *inode, char *data, int size, off_t offset)
439441

440442
int iso_readdir(inode_t *inode, dentry_t *entry, size_t count, off_t offset)
441443
{
442-
void *buf = kmalloc(256);
444+
void *buf = kmalloc(MAX_DENTRY_SIZE);
443445
int ret = EOF;
444446
iso_dentry_t *desc = inode->desc;
445447
if (offset >= desc->size)
446448
goto rollback;
447449

448-
if ((ret = iso_read(inode, (char *)buf, 256, offset)) < 0)
450+
if ((ret = iso_read(inode, (char *)buf, MAX_DENTRY_SIZE, offset)) < 0)
449451
goto rollback;
450452

451453
iso_dentry_t *mentry = buf;
452454
if (mentry->length == 0)
453455
{
454-
ret = EOF;
456+
entry->length = 0;
457+
entry->namelen = 0;
458+
entry->nr = 0;
459+
ret = ((offset / BLOCK_SIZE) + 1) * BLOCK_SIZE;
460+
ret -= offset;
455461
goto rollback;
456462
}
457463

0 commit comments

Comments
 (0)