File:  [Research Unix] / researchv9 / sys / boot / stand / chklabel.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

/*
 * @(#)chklabel.c 1.1 86/02/03 Copyright (c) 1985 by Sun Microsystems, Inc.
 */

#include <sys/types.h>
#include <sun/dklabel.h>

char msg_nolabel[] = "No label found - attempting boot anyway.\n";

/*
 * Checks a disk label, returns 0 for success, 1 for failure.
 * If the magic number is right but the checksum is wrong, prints
 * "Corrupt label" error message, otherwise is silent.
 */
chklabel(label)
	register struct dk_label *label;
{
	register int count, sum = 0;
	register short *sp;

	if (label->dkl_magic != DKL_MAGIC)
		return (1);
	count = sizeof (struct dk_label) / sizeof (short);
	sp = (short *)label;
	while (count--) 
		sum ^= *sp++;
	if (sum != 0) {
		printf("Corrupt label\n");
		return (1);
	}
	return (0);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.