VFS problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

VFS problem

Post by mariuszp »

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.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

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?
User avatar
Combuster
Member
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

Post by Combuster »

can someone help me track down this new bug?
Ask bochs debugger, or ask proper questions.

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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

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.
User avatar
Combuster
Member
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

Post by Combuster »

And I debugged everything
I don't believe you did that in 6 hours. And besides if you really did debug everything you would have found the problem.

Not buying it, try harder.

(And really do read the link posted)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

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..
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

Problem solved. Just in case someone is as noob as me:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + 19
should PROBABLY be:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + 19)
lol.
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: VFS problem

Post by fronty »

mariuszp wrote:do NOT listen to the comments in makerd.c!
mariuszp wrote:i figured out the problem was in makerd.c, but i didn't know what exactly it was.
I hope you learned something.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

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).
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: VFS problem

Post by JamesM »

Hi,
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).
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.

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?
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: VFS problem

Post by mariuszp »

Well, during compilation, gcc decided not to tell me of the syntax error.
I wrote:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
but it should be:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + offset);
(the brackets)
Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

Re: VFS problem

Post by Ready4Dis »

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.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: VFS problem

Post by JamesM »

mariuszp wrote:Well, during compilation, gcc decided not to tell me of the syntax error.
I wrote:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) initrd_loc + offset;
but it should be:

Code: Select all

struct initrd_entry * ent = (struct initrd_entry *) (initrd_loc + offset);
(the brackets)
Both of those are completely valid pointer arithmetic.
Post Reply