Пример #1
0
int
ReadHdr1(IHandle_t * ih, char *to, int size, u_int magic, u_int version)
{
    int bad = 0;
    int code;

    code = IH_IREAD(ih, 0, to, size);
    if (code != size)
	return -1;

    return 0;
}
Пример #2
0
int
ReadHdr1(IHandle_t * ih, char *to, int size, u_int magic, u_int version)
{
    struct versionStamp *vsn;
    int bad = 0;
    int code;

    vsn = (struct versionStamp *)to;

    code = IH_IREAD(ih, 0, to, size);
    if (code != size)
	return -1;

    if (vsn->magic != magic) {
	bad++;
	printf("Inode %s: Bad magic %x (%x): IGNORED\n",
	       PrintInode(NULL, ih->ih_ino), vsn->magic, magic);
    }

    /* Check is conditional, in case caller wants to inspect version himself */
    if (version && vsn->version != version) {
	bad++;
	printf("Inode %s: Bad version %x (%x): IGNORED\n",
	       PrintInode(NULL, ih->ih_ino), vsn->version, version);
    }
    if (bad && fixheader) {
	vsn->magic = magic;
	vsn->version = version;
	printf("Special index inode %s has a bad header. Reconstructing...\n",
	       PrintInode(NULL, ih->ih_ino));
	code = IH_IWRITE(ih, 0, to, size);
	if (code != size) {
	    printf("Write failed; header left in damaged state\n");
	}
    } else {
	if (!dsizeOnly && !saveinodes) {
	    printf("Inode %s: Good magic %x and version %x\n",
		   PrintInode(NULL, ih->ih_ino), magic, version);
	}
    }
    return 0;
}