LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-24-2015, 04:38 PM   #1
yashgovin19
LQ Newbie
 
Registered: Nov 2014
Posts: 6

Rep: Reputation: Disabled
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.

Last edited by yashgovin19; 06-24-2015 at 07:55 PM. Reason: Got the answer
 
Old 06-25-2015, 09:13 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Poor attitude.
You ask for help, but refuse to share the answer you found. Won't encourage others to help you in future.
 
Old 06-25-2015, 11:38 AM   #3
yashgovin19
LQ Newbie
 
Registered: Nov 2014
Posts: 6

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply

Tags
ext3, filesystem, kernel, linux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows vista can't read my ntfs partition created by mkfs Leo Simon Linux - Hardware 1 10-16-2010 10:55 AM
[SOLVED] can I do mkfs after transferring data to HD LaQuirreLL Linux - Hardware 2 03-06-2010 11:27 PM
read jpg metadata in c myrmidon Programming 3 01-21-2007 08:36 PM
using profs_example.c to read data from kernel android_online Linux - Kernel 5 06-06-2006 09:10 AM
C & kernel data structure & shell script vishalbutte Programming 7 01-13-2006 08:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration