VFS problem
VFS problem
My OS has problems reading the initrd. I created an initrd with just 1 file on it (/hello.txt) and it fails to open. I was attempting to fix it for 3 days now, and it still don't know where the problem is. It keeps saying that the file doesn't exist, and debugging revealed that some function said that hello.txt has inode 0 (the actual inode is 1) and that it has no name, and reported it as "correct" to some other function for no reason.
Can someone have a look at my source code (https://sourceforge.net/projects/asmadian/files/) and at least give me a hint on what's wrong?
I'll give credit. Thanks!
P.S. the VFS code is in kernel/vfs.h and initrd code is in kernel/initrd.h. makerd.c creates the initrd (do NOT listen to the comments in makerd.c!), myrd is the created initrd and its also put on the floppy image.
Can someone have a look at my source code (https://sourceforge.net/projects/asmadian/files/) and at least give me a hint on what's wrong?
I'll give credit. Thanks!
P.S. the VFS code is in kernel/vfs.h and initrd code is in kernel/initrd.h. makerd.c creates the initrd (do NOT listen to the comments in makerd.c!), myrd is the created initrd and its also put on the floppy image.
Re: VFS problem
Hey! I just found a syntax error in the initrd code, but now there is another problem.
I get a page fault because for some strange reason the data is corrupt.
I uploaded the new source code, can someone help me track down this new bug?
I get a page fault because for some strange reason the data is corrupt.
I uploaded the new source code, can someone help me track down this new bug?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: VFS problem
Ask bochs debugger, or ask proper questions.can someone help me track down this new bug?
Apparently you solved one bug, found a new one, and tried fixing the second one in under 6 hours time. We have somewhat higher standards as far as personal effort is concerned. Simply put, if you did debug you'd know much more about the problem, so you did not debug. Because all noobs work the same way, realize that everything you do not tell us implies you never even bothered to find out. So I dare you to prove us wrong.
Re: VFS problem
First of all, I used QEMU. Secondly, let me correct he first post: it's not 3 days, it was actually about 1 week i think.
And I debugged everything using my print(), and still didn't find the problem.
There were 3 downloads for the original code on sourceforge.net. Anyway, the reason why I posted that second post is because I didn't want anyone to think that I still have that same problem!
Thank you.
And I debugged everything using my print(), and still didn't find the problem.
There were 3 downloads for the original code on sourceforge.net. Anyway, the reason why I posted that second post is because I didn't want anyone to think that I still have that same problem!
Thank you.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: VFS problem
I don't believe you did that in 6 hours. And besides if you really did debug everything you would have found the problem.And I debugged everything
Not buying it, try harder.
(And really do read the link posted)
Re: VFS problem
Okay, my debugging revealed something, and first I didn't get what the heck was going on. guess what? after checking out the initrd file using a hex editor, i figured out the problem was in makerd.c, but i didn't know what exactly it was.
Sorry, next time i ask a question i'll make sure i do everything. I'll also be sure to remove the -w flag once in a while..
Sorry, next time i ask a question i'll make sure i do everything. I'll also be sure to remove the -w flag once in a while..
Re: VFS problem
Problem solved. Just in case someone is as noob as me:
should PROBABLY be:
lol.
Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + 19
Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + 19)
Re: VFS problem
mariuszp wrote:do NOT listen to the comments in makerd.c!
I hope you learned something.mariuszp wrote:i figured out the problem was in makerd.c, but i didn't know what exactly it was.
Re: VFS problem
What the F****?
I said you should not listen to the COMMENTS, because instead of actually copying initrd folder it creates initrd with /hello.txt on, and THEN I figured out makerd.c didn't properly make the initrd in the first place (checked with a hex editor; debugging did not reveal what the problem was until I did that).
I said you should not listen to the COMMENTS, because instead of actually copying initrd folder it creates initrd with /hello.txt on, and THEN I figured out makerd.c didn't properly make the initrd in the first place (checked with a hex editor; debugging did not reveal what the problem was until I did that).
Re: VFS problem
Hi,
Pointing us to your entire sourcebase and asking us to trawl for a bug is never going to get you results. When someone tries to narrow down a bug and provides code snippets containing the faulting code, it will get looked through. Firstly most of us don't have the time to look through a full sourcebase, and secondly it's a lot of effort to download something, unpack it, and look at each file individually, trying to work out how it all fits together.
Besides which I'm at my work computer, as I assume many others are, and I'm not downloading *anything* here.
I hope you learned something from the comments situation too. If there's a comment which reads "// Ignore all comments in this file", firstly you're telling us that you're too lazy to remove or correct incorrect comments, and secondly that there is a disparity between what code is meant to do (read: what the comments say it should do) and what it actually does. I for one am certainly not going to take the effort to dismantle that.
Short answer: You're asking for *our* help, not the other way around, so don't take the lazy option. Because we'll just take the lazy option too, and click *ignore*.
James
EDIT: Oh yeah. Also, how did you find a syntax error in the code you posted online for us to read? Surely you tried to *compile* it first? As part of your debugging?
Can I please explain some elementary errors you made with this post? You didn't make any effort to help us to help you. You claim you tried debugging the problem, yet you didn't provide the results of said debugging to narrow down the search space for us.mariuszp wrote:What the F****?
I said you should not listen to the COMMENTS, because instead of actually copying initrd folder it creates initrd with /hello.txt on, and THEN I figured out makerd.c didn't properly make the initrd in the first place (checked with a hex editor; debugging did not reveal what the problem was until I did that).
Pointing us to your entire sourcebase and asking us to trawl for a bug is never going to get you results. When someone tries to narrow down a bug and provides code snippets containing the faulting code, it will get looked through. Firstly most of us don't have the time to look through a full sourcebase, and secondly it's a lot of effort to download something, unpack it, and look at each file individually, trying to work out how it all fits together.
Besides which I'm at my work computer, as I assume many others are, and I'm not downloading *anything* here.
I hope you learned something from the comments situation too. If there's a comment which reads "// Ignore all comments in this file", firstly you're telling us that you're too lazy to remove or correct incorrect comments, and secondly that there is a disparity between what code is meant to do (read: what the comments say it should do) and what it actually does. I for one am certainly not going to take the effort to dismantle that.
Short answer: You're asking for *our* help, not the other way around, so don't take the lazy option. Because we'll just take the lazy option too, and click *ignore*.
James
EDIT: Oh yeah. Also, how did you find a syntax error in the code you posted online for us to read? Surely you tried to *compile* it first? As part of your debugging?
Re: VFS problem
Well, during compilation, gcc decided not to tell me of the syntax error.
I wrote:
but it should be:
(the brackets)
I wrote:
Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + offset);
Re: VFS problem
gcc probably didn't tell you about a syntax error, because there is no syntax error...
Contrary to popular belief, the compiler doesn't know what you intend to do, and you must tell it what to do, rather than it tell you what to do.
By casting it like this...
struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
And using order of operations... (for the compiler), it first casts initrd_loc to your initrd_entry structure. So, from this point forward, whenever you increment this variable, it will increment by a FULL struct size... so if you add offset, you really are adding offset*sizeof(struct initrd_entry), which is the proper behavoir of the compiler based on what you told it to do. If you want it to instead ADD the offset as a number, you must tell it to do that first by using the correct ( ). Don't blame the compiler for bad code. It's just like order of operations in grade school. It can't magically guess what you mean, you must actually specific an order if there is a specific order you want it done in.
Contrary to popular belief, the compiler doesn't know what you intend to do, and you must tell it what to do, rather than it tell you what to do.
By casting it like this...
struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
And using order of operations... (for the compiler), it first casts initrd_loc to your initrd_entry structure. So, from this point forward, whenever you increment this variable, it will increment by a FULL struct size... so if you add offset, you really are adding offset*sizeof(struct initrd_entry), which is the proper behavoir of the compiler based on what you told it to do. If you want it to instead ADD the offset as a number, you must tell it to do that first by using the correct ( ). Don't blame the compiler for bad code. It's just like order of operations in grade school. It can't magically guess what you mean, you must actually specific an order if there is a specific order you want it done in.
Re: VFS problem
Both of those are completely valid pointer arithmetic.mariuszp wrote:Well, during compilation, gcc decided not to tell me of the syntax error.
I wrote:but it should be:Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
(the brackets)Code: Select all
struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + offset);