syncindex.c

来自「这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易」· C语言 代码 · 共 59 行

C
59
字号
#include "stdinc.h"#include "dat.h"#include "fns.h"static	int	verbose;voidusage(void){	fprint(2, "usage: syncindex [-fv] [-B blockcachesize] config\n");	exits("usage");}intmain(int argc, char *argv[]){	u32int bcmem;	int fix;	fix = 0;	bcmem = 0;	ARGBEGIN{	case 'B':		bcmem = unittoull(ARGF());		break;	case 'f':		fix++;		break;	case 'v':		verbose++;		break;	default:		usage();		break;	}ARGEND	if(!fix)		readonly = 1;	if(argc != 1)		usage();	vtAttach();	if(!initVenti(argv[0], nil))		fatal("can't init venti: %R");	if(bcmem < maxBlockSize * (mainIndex->narenas + mainIndex->nsects * 4 + 16))		bcmem = maxBlockSize * (mainIndex->narenas + mainIndex->nsects * 4 + 16);	fprint(2, "initialize %d bytes of disk block cache\n", bcmem);	initDCache(bcmem);	if(verbose)		printIndex(2, mainIndex);	if(!syncIndex(mainIndex, fix))		fatal("failed to sync index=%s: %R\n", mainIndex->name);	exits(0);	return 0;	/* shut up stupid compiler */}

⌨️ 快捷键说明

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