LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to read data in kernel that was written to metadata structure during mkfs of FS (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-read-data-in-kernel-that-was-written-to-metadata-structure-during-mkfs-of-fs-4175546346/)

yashgovin19 06-24-2015 04:38 PM

How to read data in kernel that was written to metadata structure during mkfs of FS
 
I am adding a flag during mkfs time through which the user can enter a number between 1-8 depicting how many BG required for an abstraction. I am storing that value in ext2_super_block metadata structure (say __u16 s_new_field)
Now, how do I read that value in kernel code?
I looked into fs/ext3/super.c file and in the method ext3_fill_super the code refers to super_block structure but I am not sure how is it reading the data we saved during mkfs time. I tried replicating the structure but it shows zero value when I do dmesg and not the value I entered during mkfs. Any suggestions?

**Solution is to look closely in super.c file in fs/ext3/super.c and you will find the solution. I tried so many times and was not getting an answer and so posted this question but I have figured out that closely looking at the code and running few tests will really help you.

syg00 06-25-2015 09:13 AM

Poor attitude.
You ask for help, but refuse to share the answer you found. Won't encourage others to help you in future.

yashgovin19 06-25-2015 11:38 AM

I realized it was a dumb question and it was pretty straightforward to look into super.c file in your file system. Since, I am looking in ext3 file system the super block layout between user program and kernel program should be same and then only when you read your block you will get those values in kernel. In my case the layout was not matching - something I should have seen or picked up before.
I specifically mentioned in the solution edit that if you look closely into the super.c file you will find out a solution only by seeing comments.


All times are GMT -5. The time now is 08:06 PM.