Cameron Kaiser wrote:
I then put the
resulting disk image on another linux box and wrote a
tiny C program to search for valid sysv super blocks.
Mind posting the source?
no problem. it was just a quick hack.
--- cut here ---
#include <stdio.h>
#include <fcntl.h>
#define __packed2__ __attribute__ ((packed, aligned(2)))
typedef unsigned short u16;
typedef unsigned int u32;
typedef short s16;
typedef int s32;
typedef u16 sysv_ino_t;
typedef u32 sysv_zone_t;
/* Xenix super-block data on disk */
#define XENIX_NICINOD 100 /* number of inode cache entries */
#define XENIX_NICFREE 100 /* number of free block list chunk entries */
struct xenix_super_block {
u16 s_isize; /* index of first data zone */
u32 s_fsize __packed2__; /* total number of zones of this fs */
/* the start of the free block list: */
u16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
u32 s_free[XENIX_NICFREE]; /* first free block list chunk */
/* the cache of free inodes: */
u16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */
/* locks, not used by Linux: */
char s_flock; /* lock during free block list manipulation */
char s_ilock; /* lock during inode cache manipulation */
char s_fmod; /* super-block modified flag */
char s_ronly; /* flag whether fs is mounted read-only */
u32 s_time __packed2__; /* time of last super block update */
u32 s_tfree __packed2__; /* total number of free zones */
u16 s_tinode; /* total number of free inodes */
s16 s_dinfo[4]; /* device information ?? */
char s_fname[6]; /* file system volume name */
char s_fpack[6]; /* file system pack name */
char s_clean; /* set to 0x46 when filesystem is properly unmounted */
char s_fill[371];
s32 s_magic; /* version of file system */
s32 s_type; /* type of file system: 1 for 512 byte blocks
2 for 1024 byte blocks
3 for 2048 byte blocks */
};
char buffer[4096];
main()
{
int fd, ret;
struct xenix_super_block *sb;
int offset;
fd = open("d1", O_RDONLY);
sb = (struct xenix_super_block *)buffer;
printf("size %d\n", sizeof(struct xenix_super_block));
//printf("offset %d\n", ((char *)&sb->s_magic) - buffer);
offset = 0;
while (1) {
ret = read(fd, buffer, 1024);
if (ret != 1024)
break;
if (sb->s_magic == 0x002b5544 &&
(sb->s_type >= 1 && sb->s_type <= 3))
{
printf("offset %d 0x%x\n", offset, offset);
printf("block %d\n", (offset-1024) / 512);
printf("s_magic %08x\n", sb->s_magic);
printf("s_type %08x\n", sb->s_type);
printf("s_nfree %04x\n", sb->s_nfree);
}
offset += 1024;
}
}