[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Filename to "inode" pointer in C
i wrote some stuff for accessing ffs partitions/files ages ago, but didnt
really do anything with it.
http://www.ifost.org.au/~peterw/fs.tar.gz
# make
# ./dfs /dev/wd0f
dfs> ls
2 .
2 ..
3 da
4 bar
dfs>
the codes a bit of a mess/crappy, just kill the printfs. it should be a bit
clearer than the fsck/fsdb (which is useful too). you could probably use
parts of it to write the utility you mention below.
-pete
-----Original Message-----
From: John D. [mailto:lists@webcrunchers.com]
Sent: Sunday, November 03, 2002 7:18 PM
To: Sergey Lyubka
Cc: tech@openbsd.org
Subject: Re: Filename to "inode" pointer in C
Thanx a lot for your help you guys... this is what I came up with,
thanx to your help. For those also interested, this following function
does exactly what I want.
// Given the path of a file, return the inode
ino_t getInode(char *fname) {
FILE f;
struct stat mystat;
stat(fname, &mystat);
return mystat.st_ino;
}
Ok, now that I have the inode number of the file, the next thing I need
to know, is now to find all the raw physical sectors used by the data in
this file.
Is there a utility (preferrably in C) that given the inode of a file,
would return an array of the physical sectors belonging to that file?
Or, better yet, given a specific sector, to determine what file
references this sector (or node). I think I can get the filename from the
inode already.
By the way, if anything useful comes out of this, I'll post the code.
John