Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type inconsistent between struct dirent's inum(ushort) and its usage(uint). #164

Open
zhouzilong2020 opened this issue Feb 2, 2023 · 1 comment

Comments

@zhouzilong2020
Copy link

inum defined inside struct dirent is a ushort, suggesting the dirent can only reference up to 4 inode on disk.

xv6-riscv/kernel/fs.h

Lines 56 to 59 in f5b93ef

struct dirent {
ushort inum;
char name[DIRSIZ];
};

However, in function dirlink(), it tries to set inum with a unit.
de.inum = inum;

I further checked all the usage of the user space function link(), and it turns out none tried to open a file via its linked name.
Is this a delicate design or a bug?

@zhouzilong2020
Copy link
Author

Since each dinode has 64 bytes right now, and there are 13 blocks for inode on disk, xv6 chould at most have 208 inode.

To make the data type of inum consistent, I suggest:

  1. Changing struct dirent as follows:
#define DIRSIZ 12
struct dirent {
  uint inum;
  char name[DIRSIZ];
};
  1. Changing inum to ushort everywhere, which includes much more modifications to the code.

@zhouzilong2020 zhouzilong2020 changed the title Type inconsistent between struct dirent's inum(ushort) and its usage. Type inconsistent between struct dirent's inum(ushort) and its usage(uint). Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant