view pirollback/checknames.c @ 361:5d1c186cc3cf

fluid-mnf/target-bin/cmd39.m0: hand-crafted by copying cmd.m0 and manually patching the S3 record that contains the 16-bit word at 0x1140, the literal pool DPLL init constant used by hardware_init_calypso()
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 14 Mar 2020 19:33:52 +0000
parents 78ac405716db
children
line wrap: on
line source

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "struct.h"
#include "pathname.h"

extern struct inode_info inode[];
extern int last_inode;

static void
check_inode(ino)
{
	struct inode_info *in;
	u8 *cp;
	int cnt;

	in = inode + ino;
	switch (in->type) {
	case 0xE1:
	case 0xF1:
	case 0xF2:
		break;
	case 0x00:
	case 0xF4:
		return;
	default:
		fprintf(stderr, "inode #%x: unexpected type %02X\n", ino,
			in->type);
		exit(1);
	}
	for (cp = in->dataptr, cnt = 0; ; cp++, cnt++) {
		if (cnt >= in->len) {
			fprintf(stderr,
			"inode #%x: name expected at %x: length overrun\n",
				ino, in->offset);
			exit(1);
		}
		if (!*cp)
			break;
		if (cnt >= MAX_FN_COMPONENT) {
			fprintf(stderr,
			"inode #%x: name exceeds program limit of %d chars\n",
				ino, MAX_FN_COMPONENT);
			exit(1);
		}
		if (*cp < '!' || *cp > '~') {
			fprintf(stderr,
			"inode #%x: name expected at %x: bad character\n",
				ino, in->offset);
			exit(1);
		}
	}
	if (!cnt) {
		fprintf(stderr, "inode #%x: name expected at %x: null string\n",
			ino, in->offset);
		exit(1);
	}
	in->byte_after_name = cp + 1;
}

check_object_names()
{
	int ino;

	for (ino = 1; ino <= last_inode; ino++)
		check_inode(ino);
}