LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-25-2008, 09:00 AM   #1
sam_vde
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Rep: Reputation: 0
Linux: get low-level file structure information in userspace using C


Hi,

Is anyone aware if there is a way to get low-level file structure information available in userspace C using system calls or whatever? Or is this info only available in kernel mode using a module?

What I would like to do is get a list of all block pointers back from the inode.

Second to that: is it possible to see which block was written to disk last?


Thanks
Krgds
Sam
 
Old 07-25-2008, 09:19 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Not entirely sure, but it sounds as kernel-only stuff to me...
 
Old 07-25-2008, 12:09 PM   #3
FranDango
Member
 
Registered: Jun 2008
Posts: 101

Rep: Reputation: 15
Open a pipe within your C application to the 'stat' command-line tool and read it's output.
Something like
Quote:
fp = popen ("stat myfile", "r");
while (!feof (fp)) {
fgets(buffer, maxsize, fp);
// do something here ...
}
Linux Archive

Last edited by FranDango; 09-20-2008 at 06:25 AM.
 
Old 07-25-2008, 03:04 PM   #4
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Quote:
Originally Posted by FranDango View Post
Open a pipe within your C application to the 'stat' command-line tool and read it's output.
Something like
errm, that's a pretty roundabout way of doing it...

stat() and fstatat() are better choices.

man 2 stat
man 2 fstatat
 
Old 07-25-2008, 04:02 PM   #5
sam_vde
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by raconteur View Post
errm, that's a pretty roundabout way of doing it...

stat() and fstatat() are better choices.

man 2 stat
man 2 fstatat
Thanks, but this does not give back the details I am looking for. I would really like to get an insight of all blocks contained in a file, and if possible a way to check when they are written (either on-the-fly or using some time stamps I did not discover yet).
 
Old 07-25-2008, 04:15 PM   #6
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
If you really need more detail than stat() returns (unlikely, in my opinion, unless you're writing a low-level file system utility) then check out the source for fsck.
 
Old 07-25-2008, 04:42 PM   #7
sam_vde
LQ Newbie
 
Registered: Mar 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by raconteur View Post
If you really need more detail than stat() returns (unlikely, in my opinion, unless you're writing a low-level file system utility) then check out the source for fsck.
Yeah it's a bit academic at the moment but I need it to implement some of the ideas I have on some new storage routines I was thinking of...
Thank you for the suggestion, I will look into that!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
CPU information structure alltime Programming 2 10-31-2005 05:58 AM
WANTED: Low Level Disc Sector editor for LINUX SAB Linux - General 4 04-24-2005 08:24 PM
Low-level format under Linux with an AHA-1522 rcase5 Linux - Hardware 2 04-12-2005 02:33 PM
Problem with MAC-level multicasts in userspace protocol elrusso Linux - Networking 0 02-01-2005 06:57 AM
How do I low-level format a SCSI drive on Aurora Sparc Linux v1.0? JustinCase Linux - Hardware 3 03-02-2004 11:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:16 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