From: sumit kalra <i_am_sumit_kalra@yahoo.com>
To: nanakos@wired-net.gr, linux-c-programming@vger.kernel.org
Subject: Re: superblock & inode's
Date: Wed, 27 Jul 2005 06:21:28 +0100 (BST) [thread overview]
Message-ID: <20050727052128.96647.qmail@web61017.mail.yahoo.com> (raw)
In-Reply-To: <40710.62.1.10.61.1122396787.squirrel@webmail.wired-net.gr>
Hi,
> lseek(fd,4096L,0); /* Is this the first inode??
> Where is the next one?*/
> /*Where is the superblock allocated in the disk */
The location of the superblock and the inodes
(including the first one) depend on the kind of
filesystem you have on the disk. Some filesystems have
the superblock immediately after the boot block
(ext2/3) and others may not have it at all (NTFS).
Also the structure of on-disk superblocks and inodes
vary with each filesystem.
If you know which filesystem your disk has then you
can read in the relevent blocks. Then you can look at
the filesystem code and find out what data structure
defines the superblock and typecast the block of data
accordingly.
I am not sure if there is a better way to do it but
this is all that came to my mind :-)
Hope it helps,
Sumit Kalra
--- Nanakos Chrysostomos <nanakos@wired-net.gr> wrote:
> Hi all,
> i want to read the superblock & inode for a block
> device.
> I dont want to use readdir to get the inode and dir
> name.I want to do it
> like the skeleton below,can someone help me??
>
>
> #include <sys/types.h>
> #include <stdio.h>
>
> int main()
> {
>
> struct what_struct d; /* What struct to use for
> inode*/
> struct what_struct_sb sb; /*What struct to use for
> superblock */
> int fd;
>
> fd=open("/dev/hda1",0);
> lseek(fd,4096L,0); /* Is this the first inode??
> Where is the next one?*/
> /*Where is the superblock allocated in the disk */
> read(fd,&d,sizeof(d));
> /*Retrieve information now ....*/
>
> return 0;
> }
>
>
> Can i have a working example please???
> Thanks in advance.
>
>
>
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
next prev parent reply other threads:[~2005-07-27 5:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-25 8:47 Unsigned off_t? Holger Kiehl
2005-07-25 8:53 ` Jeff Woods
2005-07-25 9:00 ` Holger Kiehl
2005-07-26 5:24 ` Glynn Clements
2005-07-26 7:38 ` Holger Kiehl
2005-07-26 16:53 ` superblock & inode's Nanakos Chrysostomos
2005-07-26 16:59 ` Robert P. J. Day
2005-07-27 5:21 ` sumit kalra [this message]
2005-07-27 7:24 ` Glynn Clements
2005-07-27 18:53 ` Nanakos Chrysostomos
2005-07-27 7:23 ` Unsigned off_t? Glynn Clements
2005-07-27 20:09 ` Holger Kiehl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050727052128.96647.qmail@web61017.mail.yahoo.com \
--to=i_am_sumit_kalra@yahoo.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=nanakos@wired-net.gr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).