From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Robert P. J. Day" Subject: Re: superblock & inode's Date: Tue, 26 Jul 2005 12:59:43 -0400 (EDT) Message-ID: References: <17125.51475.763052.283552@cerise.gclements.plus.com> <40710.62.1.10.61.1122396787.squirrel@webmail.wired-net.gr> Mime-Version: 1.0 Return-path: In-Reply-To: <40710.62.1.10.61.1122396787.squirrel@webmail.wired-net.gr> Sender: linux-c-programming-owner@vger.kernel.org List-Id: Content-Type: TEXT/PLAIN; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Nanakos Chrysostomos Cc: linux-c-programming@vger.kernel.org On Tue, 26 Jul 2005, Nanakos Chrysostomos 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 > #include > > 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; > } your best bet is to get a copy of the kernel source and check out the directory fs/ext3, particularly the source files super.c and inode.c. rday