示例#1
0
文件: twins.c 项目: wtaysom/tau
buf_s *alloc_block (dev_s *dev)
{
	super_s	*super;
	buf_s	*buf;
	u64	blknum;
FN;
	buf = bget(dev, SUPER_BLOCK);
	super = buf->b_data;

	if (super->sp_magic != SUPER_MAGIC) {
		eprintf("no super block");
	}
	blknum = super->sp_next++;
	bdirty(buf);
	bput(buf);

	return bnew(dev, blknum);
}
示例#2
0
文件: buffer.c 项目: WizardGed/mg
/*
 * Search for a buffer, by name.
 * If not found, and the "cflag" is TRUE,
 * create a new buffer. Return pointer to the found
 * (or new) buffer.
 */
struct buffer *
bfind(const char *bname, int cflag)
{
	struct buffer	*bp;

	bp = bheadp;
	while (bp != NULL) {
		if (strcmp(bname, bp->b_bname) == 0)
			return (bp);
		bp = bp->b_bufp;
	}
	if (cflag != TRUE)
		return (NULL);

	bp = bnew(bname);

	return (bp);
}
示例#3
0
文件: twins.c 项目: wtaysom/tau
static void init_super_block (tree_s *tree)
{
	super_s	*super;
	buf_s	*buf;

	buf = bget(tree->t_dev, SUPER_BLOCK);
	if (!buf) {
		buf = bnew(tree->t_dev, SUPER_BLOCK);
	}
	super = buf->b_data;
	if (super->sp_magic != SUPER_MAGIC) {
		super->sp_blknum = SUPER_BLOCK;
		super->sp_magic  = SUPER_MAGIC;
		super->sp_root   = 0;
		super->sp_next   = SUPER_BLOCK + 1;

		bdirty(buf);
	}
	bput(buf);
}