Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!ihnp4!houxm!hropus!jrw From: jrw@hropus.UUCP (Jim Webb) Newsgroups: net.unix Subject: Re: inodes Message-ID: <742@hropus.UUCP> Date: Sun, 19-Oct-86 12:19:42 EDT Article-I.D.: hropus.742 Posted: Sun Oct 19 12:19:42 1986 Date-Received: Tue, 21-Oct-86 06:31:37 EDT References: <47@andromeda.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 36 Keywords: Anything like getpwent() for i-nodes ? > Is there any way to "get" an i-node into a C > program, the way getpwent gets passwd entries ? Do I really have to > open the device file and look for the i-list ? The stat(2) call yields a lot of info in the inode, but if you are looking for block info, reading the inode is the only means of getting it. There is not a getinode() function, but it would be a very simple function to write. Under System V, the physical disk slice looks like this: block 0 block 1 block 2 .... +------------+------------+---------------------------+--------------- | BOOT BLK | SUPER BLK | INODES.... | DATA BLOCKS +------------+------------+---------------------------+--------------- So, to grab the inode, all one has to do is to lseek past the boot and super- blocks, and then, using the inode number, lseek into the ilist and read out the inode: #include #include #include int fd; ino_t inum; struct dinode ibuf; fd=open("/dev/rdsk/0s0",O_RDONLY); lseek(fd,1024+inum*sizeof(struct dinode),0); read(fd,ibuf,sizeof(struct dinode)); Then you can look at any of the inode info via ibuf. -- Jim Webb "Out of phase--get help" ...!ihnp4!hropus!jrw "Use the Force, Read the Source"