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

[BUG] #35

Open
ashriram opened this issue Mar 20, 2020 · 1 comment
Open

[BUG] #35

ashriram opened this issue Mar 20, 2020 · 1 comment
Assignees
Labels

Comments

@ashriram
Copy link

Describe the bug
Jupiter does not seem to be able to read binary files
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.
It does not appear like an attach a binary file here.

Screenshots
If applicable, add screenshots to help explain your problem.

Jupiter (please complete the following information):

  • OS: [e.g. OS X]
  • Version [e.g. v3.1]
  • Mode GUI]

Additional context
When you fread from a binary file,
e.g., txt file (convert to binary before trying to fread).
5 3
1 -3 4
46 -2 -5
2 -62 0
1 3 13
26 -7 34

The first fread returns 5, but subsequent fread returns 0.

@ashriram
Copy link
Author

More details. This seems related to how readBytes is implemented. It seems to assume that the entire file is read at once by the program. This will not work, if we do not know how many bytes to read.
https://github.com/andrescv/Jupiter/blob/c51efb6bc925abb37a9c1316a40b1fc458d62ed5/src/main/java/jupiter/utils/FS.java#L160

e.g., assume file

Bytes to read

Data.....

Program
read() // Read metadata
allocate bytes
read() // Read data

Now, we first need to read a 4 byte metadata at the beginning of the file to figure out how many more bytes we want to read from the file i.e., we need to issue multiple read calls to the file descriptor.

The first read() will return # Bytes, but in the current implementation the subsequent read call will fail as it assumes the file has already been read and it will return 0 bytes.

You need to main a seek pointer for each file descriptor within the VirtualFS (just like libc would).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants