chklabel.c

来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 33 行

C
33
字号
/* * @(#)chklabel.c 1.1 92/07/30 Copyright (c) 1985 by Sun Microsystems, Inc. */#include <stand/saio.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);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?