[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Reading fibmap



Hi booters,
i just hacked a few lines to get the fibmap of an iso image - I created
an iso of my /usr/sbin and mounted it on /mnt/loop

flo@paradigm:/mnt/loop$ sudo ~/ff rdate 
File: rdate Size: 5264 Blocks: 3 Blocksize: 2048
  0       1240
  1       1241
  2       1242
flo@paradigm:/mnt/loop$ cd
flo@paradigm:$ dd if=test.iso of=t count=3 bs=2048 skip=1240
3+0 records in
3+0 records out
flo@paradigm:~$ cmp t /mnt/loop/rdate 
cmp: EOF on /mnt/loop/rdate

Which shows that it is possible to find the correct blocks 
on an iso9660 filesystem. Now one has to make an iso of the
"boot-floppies" directory and generate the fibmap of the kernel +
ramdisk bootimage (tftpboot ?) and build a "boot-sector" from it
for the decstation case and a "volume header" for the sgi case.

It should be possible to generate a volume-header+iso image
for the sgis and get the tftpboot.img from it with dvhtool which
should be some kind of verification. 

I have attached the ff.c code for people to play with.

Flo
-- 
Florian Lohoff                  flo@rfc822.org             +49-5201-669912
Nine nineth on september the 9th              Welcome to the new billenium
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <linux/hdreg.h>
#include <assert.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv) {
	int		fd,
			i,
			block,
			blocksize,
			bcount;
	struct stat	st;

	assert(argv[1] != NULL);

	assert(fd=open(argv[1], O_RDONLY));

	assert(ioctl(fd, FIGETBSZ, &blocksize) == 0);

	assert(!fstat(fd, &st));

	bcount = (st.st_size + blocksize - 1) / blocksize;

	printf("File: %s Size: %d Blocks: %d Blocksize: %d\n", 
		argv[1], st.st_size, bcount, blocksize);

	for(i=0;i < bcount;i++) {
		block=i;
		if (ioctl(fd, FIBMAP, &block)) {
			printf("FIBMAP ioctl failed - errno: %s\n",
					strerror(errno));
		}
		printf("%3d %10d\n", i, block);
	}

	close(fd);
}

Attachment: pgpfH6BpCaBPH.pgp
Description: PGP signature


Reply to: