当前位置: 首页>>代码示例>>C++>>正文


C++ NINDIR函数代码示例

本文整理汇总了C++中NINDIR函数的典型用法代码示例。如果您正苦于以下问题:C++ NINDIR函数的具体用法?C++ NINDIR怎么用?C++ NINDIR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NINDIR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: virtualblocks

static int virtualblocks(struct fs *super, union dinode *dp)
{
	off_t nblk, sz;

	sz = DIP(super, dp, di_size);
#ifdef	COMPAT
	if (lblkno(super,sz) >= NDADDR) {
		nblk = blkroundup(super,sz);
		if (sz == nblk)
			nblk += super->fs_bsize;
	}

	return sz / 1024;

#else	/* COMPAT */

	if (lblkno(super,sz) >= NDADDR) {
		nblk = blkroundup(super,sz);
		sz = lblkno(super,nblk);
		sz = (sz - NDADDR + NINDIR(super) - 1) / NINDIR(super);
		while (sz > 0) {
			nblk += sz * super->fs_bsize;
			/* sz - 1 rounded up */
			sz = (sz - 1 + NINDIR(super) - 1) / NINDIR(super);
		}
	} else
		nblk = fragroundup(super,sz);

	return nblk / 512;
#endif	/* COMPAT */
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:31,代码来源:quot.c

示例2: dmpindir

/*
 * Read indirect blocks, and pass the data blocks to be dumped.
 */
static void
dmpindir(ino_t ino, daddr_t  blk, int ind_level, off_t *size)
{
	int i, cnt;
	char idblk[MAXBSIZE];

	if (blk != 0)
		bread(fsbtodb(sblock, blk), idblk, (int) sblock->fs_bsize);
	else
		memset(idblk, 0, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		if (*size < NINDIR(sblock) * sblock->fs_bsize)
			cnt = howmany(*size, sblock->fs_fsize);
		else
			cnt = NINDIR(sblock) * sblock->fs_frag;
		*size -= NINDIR(sblock) * sblock->fs_bsize;
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			ufs1_blksout((int32_t *)idblk, cnt, ino);
		else
			ufs2_blksout((int64_t *)idblk, cnt, ino);
		return;
	}
	ind_level--;
	for (i = 0; i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			dmpindir(ino, ((int32_t *)idblk)[i], ind_level,
			    size);
		else
			dmpindir(ino, ((int64_t *)idblk)[i], ind_level,
			    size);
		if (*size <= 0)
			return;
	}
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:37,代码来源:traverse.c

示例3: dmpindir

/*
 * Read indirect blocks, and pass the data blocks to be dumped.
 */
static void
dmpindir(ufs1_ino_t ino, daddr_t blk, int ind_level, fsizeT *size)
{
	int i, cnt;
	daddr_t idblk[MAXNINDIR];

	if (blk != 0)
		bread(fsbtodb(sblock, blk), (char *)idblk, (int) sblock->fs_bsize);
	else
		memset(idblk, 0, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		if (*size < NINDIR(sblock) * sblock->fs_bsize)
			cnt = howmany(*size, sblock->fs_fsize);
		else
			cnt = NINDIR(sblock) * sblock->fs_frag;
		*size -= NINDIR(sblock) * sblock->fs_bsize;
		blksout(&idblk[0], cnt, ino);
		return;
	}
	ind_level--;
	for (i = 0; i < NINDIR(sblock); i++) {
		dmpindir(ino, idblk[i], ind_level, size);
		if (*size <= 0)
			return;
	}
}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:29,代码来源:traverse.c

示例4: dirindir

/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(ino_t ino, daddr64_t blkno, int ind_level, off_t *filesize)
{
	int ret = 0;
	int i;
	char idblk[MAXBSIZE];

	bread(fsbtodb(sblock, blkno), idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			if (sblock->fs_magic == FS_UFS1_MAGIC)
				blkno = ((int32_t *)idblk)[i];
			else
				blkno = ((int64_t *)idblk)[i];
			if (blkno != 0)
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize);
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			blkno = ((int32_t *)idblk)[i];
		else
			blkno = ((int64_t *)idblk)[i];
		if (blkno != 0)
			ret |= dirindir(ino, blkno, ind_level, filesize);
	}
	return (ret);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:40,代码来源:traverse.c

示例5: dirindir

/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(ufs1_ino_t ino, daddr_t blkno, int ind_level, long *filesize,
         long *tape_size, int nodump)
{
	int ret = 0;
	int i;
	daddr_t	idblk[MAXNINDIR];

	bread(fsbtodb(sblock, blkno), (char *)idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			blkno = idblk[i];
			if (blkno != 0) {
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize, tape_size, nodump);
			}
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		blkno = idblk[i];
		if (blkno != 0) {
			ret |= dirindir(ino, blkno, ind_level, filesize,
			    tape_size, nodump);
		}
	}
	return (ret);
}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:38,代码来源:traverse.c

示例6: make_dinode

/*
 * Create the root directory for this file system and the lost+found
 * directory.
 */
static void
make_dinode(ino_t ino, struct ufs1_dinode *dip, int nfrags, struct lfs *fs)
{
	int fsb_per_blk, i;
	int nblocks, bb, base, factor, lvl;

	nblocks = howmany(nfrags, fs->lfs_frag);
	if(nblocks >= NDADDR)
		nfrags = roundup(nfrags, fs->lfs_frag);

	dip->di_nlink = 1;
	dip->di_blocks = fragstofsb(fs, nfrags);

	dip->di_size = (nfrags << fs->lfs_ffshift);
	dip->di_atime = dip->di_mtime = dip->di_ctime = fs->lfs_tstamp;
	dip->di_atimensec = dip->di_mtimensec = dip->di_ctimensec = 0;
	dip->di_inumber = ino;
	dip->di_gen = 1;

	fsb_per_blk = fragstofsb(fs, blkstofrags(fs, 1));

	if (NDADDR < nblocks) {
		/* Count up how many indirect blocks we need, recursively */
		/* XXX We are only called with nblocks > 1 for Ifile */
		bb = nblocks - NDADDR;
		while (bb > 0) {
			bb = howmany(bb, NINDIR(fs));
			ifibc += bb;
			--bb;
		}
		dip->di_blocks += fragstofsb(fs, blkstofrags(fs, ifibc));
	}

	/* Assign the block addresses for the ifile */
	for (i = 0; i < MIN(nblocks,NDADDR); i++) {
		dip->di_db[i] = 0x0;
	}
	if(nblocks > NDADDR) {
		dip->di_ib[0] = 0x0;
		bb = howmany(nblocks - NDADDR, NINDIR(fs)) - 1;
		factor = NINDIR(fs);
		base = -NDADDR - factor;
		lvl = 1;
		while (bb > 0) {
			dip->di_ib[lvl] = 0x0;
			bb = howmany(bb, NINDIR(fs));
			--bb;
			factor *= NINDIR(fs);
			base -= factor;
			++lvl;
		}
	}
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:57,代码来源:make_lfs.c

示例7: dirindir

/*
 * Read indirect blocks, and pass the data blocks to be searched
 * as directories. Quit as soon as any entry is found that will
 * require the directory to be dumped.
 */
static int
dirindir(
	ino_t ino,
	ufs2_daddr_t blkno,
	int ind_level,
	long *filesize,
	long *tapesize,
	int nodump,
	ino_t maxino)
{
	union {
		ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)];
		ufs2_daddr_t ufs2[MAXBSIZE / sizeof(ufs2_daddr_t)];
	} idblk;
	int ret = 0;
	int i;

	bread(fsbtodb(sblock, blkno), (char *)&idblk, (int)sblock->fs_bsize);
	if (ind_level <= 0) {
		for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
			if (sblock->fs_magic == FS_UFS1_MAGIC)
				blkno = idblk.ufs1[i];
			else
				blkno = idblk.ufs2[i];
			if (blkno != 0)
				ret |= searchdir(ino, blkno, sblock->fs_bsize,
					*filesize, tapesize, nodump, maxino);
			if (ret & HASDUMPEDFILE)
				*filesize = 0;
			else
				*filesize -= sblock->fs_bsize;
		}
		return (ret);
	}
	ind_level--;
	for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			blkno = idblk.ufs1[i];
		else
			blkno = idblk.ufs2[i];
		if (blkno != 0)
			ret |= dirindir(ino, blkno, ind_level, filesize,
			    tapesize, nodump, maxino);
	}
	return (ret);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:51,代码来源:traverse.c

示例8: block_map

static grub_int64_t
block_map (int file_block)
{
  int bnum, offset, bsize;
  
  if (file_block < NDADDR)
    return (INODE_UFS2->di_db[file_block]);
  
  /* If the blockmap loaded does not include FILE_BLOCK,
     load a new blockmap.  */

  if ((bnum = fsbtodb (SUPERBLOCK, INODE_UFS2->di_ib[0])) != mapblock
      || (mapblock_offset <= bnum && bnum <= mapblock_offset + mapblock_bsize))
    {
      if (MAPBUF_LEN < SUPERBLOCK->fs_bsize)
	{
	  offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
	  bsize = MAPBUF_LEN;
	  
	  if (offset + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
	    offset = (SUPERBLOCK->fs_bsize - MAPBUF_LEN) / sizeof (int);
	}
      else
	{
	  bsize = SUPERBLOCK->fs_bsize;
	  offset = 0;
	}
      
      if (! devread (bnum, offset * sizeof (int), bsize, (char *) MAPBUF, 0xedde0d90))
	{
	  mapblock = -1;
	  mapblock_bsize = -1;
	  mapblock_offset = -1;
	  errnum = ERR_FSYS_CORRUPT;
	  return -1;
	}
      
      mapblock = bnum;
      mapblock_bsize = bsize;
      mapblock_offset = offset;
    }
  
  return (((grub_int64_t *) MAPBUF)[((file_block - NDADDR) % NINDIR (SUPERBLOCK))
				    - mapblock_offset]);
}
开发者ID:HappyBasher,项目名称:LINBOv3,代码行数:45,代码来源:fsys_ufs2.c

示例9: block_map

static int
block_map(int file_block)
{
	int bnum;
	if (file_block < NDADDR)
		return(inode.i_db[file_block]);
	if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) {
		devread(mapbuf, bnum, fs->fs_bsize);
		mapblock = bnum;
	}
	return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]);
}
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:12,代码来源:sys.c

示例10: printindir

/*
 * Recursively print a list of indirect blocks.
 */
static void
printindir(ufs2_daddr_t blk, int level, char *bufp)
{
    struct bufarea buf, *bp;
    char tempbuf[32];		/* enough to print an ufs2_daddr_t */
    int i, j, cpl, charssofar;
    ufs2_daddr_t blkno;

    if (blk == 0)
	return;
    printf("%jd (%d) =>\n", (intmax_t)blk, level);
    if (level == 0) {
	/* for the final indirect level, don't use the cache */
	bp = &buf;
	bp->b_un.b_buf = bufp;
	bp->b_prev = bp->b_next = bp;
	initbarea(bp);

	getblk(bp, blk, sblock.fs_bsize);
    } else
	bp = getdatablk(blk, sblock.fs_bsize);

    cpl = charsperline();
    for (i = charssofar = 0; i < NINDIR(&sblock); i++) {
	if (sblock.fs_magic == FS_UFS1_MAGIC)
		blkno = bp->b_un.b_indir1[i];
	else
		blkno = bp->b_un.b_indir2[i];
	if (blkno == 0)
	    continue;
	j = sprintf(tempbuf, "%jd", (intmax_t)blkno);
	if (level == 0) {
	    charssofar += j;
	    if (charssofar >= cpl - 2) {
		putchar('\n');
		charssofar = j;
	    }
	}
	fputs(tempbuf, stdout);
	if (level == 0) {
	    printf(", ");
	    charssofar += 2;
	} else {
	    printf(" =>\n");
	    printindir(blkno, level - 1, bufp);
	    printf("\n");
	    charssofar = 0;
	}
    }
    if (level == 0)
	putchar('\n');
    return;
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:56,代码来源:fsdbutil.c

示例11: dmpindir

/*
 * Read indirect blocks, and pass the data blocks to be dumped.
 */
static void
dmpindir(union dinode *dp, ino_t ino, ufs2_daddr_t blk, int ind_level,
	off_t *size)
{
	union {
		ufs1_daddr_t ufs1[MAXBSIZE / sizeof(ufs1_daddr_t)];
		ufs2_daddr_t ufs2[MAXBSIZE / sizeof(ufs2_daddr_t)];
	} idblk;
	int i, cnt, last;

	if (blk != 0)
		bread(fsbtodb(sblock, blk), (char *)&idblk,
		    (int)sblock->fs_bsize);
	else
		memset(&idblk, 0, sblock->fs_bsize);
	if (ind_level <= 0) {
		if (*size > NINDIR(sblock) * sblock->fs_bsize) {
			cnt = NINDIR(sblock) * sblock->fs_frag;
			last = 0;
		} else {
			cnt = howmany(*size, sblock->fs_fsize);
			last = 1;
		}
		*size -= NINDIR(sblock) * sblock->fs_bsize;
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			ufs1_blksout(idblk.ufs1, cnt, ino);
		else
			ufs2_blksout(dp, idblk.ufs2, cnt, ino, last);
		return;
	}
	ind_level--;
	for (i = 0; i < NINDIR(sblock); i++) {
		if (sblock->fs_magic == FS_UFS1_MAGIC)
			dmpindir(dp, ino, idblk.ufs1[i], ind_level, size);
		else
			dmpindir(dp, ino, idblk.ufs2[i], ind_level, size);
		if (*size <= 0)
			return;
	}
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:43,代码来源:traverse.c

示例12: block_map

int
block_map(int file_block)
{
	if (file_block < NDADDR)
		return(inode.i_db[file_block]);
	if ((bnum=fsbtodb(fs, inode.i_ib[0])+boff) != mapblock) {
		cnt = fs->fs_bsize;
		if (disk_read(bnum, cnt, (vm_offset_t)mapbuf))
			return(-1);
		mapblock = bnum;
	}
	return (((int *)mapbuf)[(file_block - NDADDR) % NINDIR(fs)]);
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:13,代码来源:sys.c

示例13: printindir

/*
 * Recursively print a list of indirect blocks.
 */
static int
printindir(ufs_daddr_t blk, int level, char *bufp)
{
    struct bufarea buf, *bp;
    char tempbuf[32];		/* enough to print an ufs_daddr_t */
    int i, j, cpl, charssofar;
    ufs_daddr_t blkno;

    if (level == 0) {
	/* for the final indirect level, don't use the cache */
	bp = &buf;
	bp->b_un.b_buf = bufp;
	bp->b_prev = bp->b_next = bp;
	initbarea(bp);

	getblk(bp, blk, sblock.fs_bsize);
    } else
	bp = getdatablk(blk, sblock.fs_bsize);

    cpl = charsperline();
    for (i = charssofar = 0; i < NINDIR(&sblock); i++) {
	blkno = bp->b_un.b_indir[i];
	if (blkno == 0) {
	    if (level == 0)
		putchar('\n');
	    return 0;
	}
	j = sprintf(tempbuf, "%d", blkno);
	if (level == 0) {
	    charssofar += j;
	    if (charssofar >= cpl - 2) {
		putchar('\n');
		charssofar = j;
	    }
	}
	fputs(tempbuf, stdout);
	if (level == 0) {
	    printf(", ");
	    charssofar += 2;
	} else {
	    printf(" =>\n");
	    if (printindir(blkno, level - 1, bufp) == 0)
		return 0;
	}
    }
    if (level == 0)
	putchar('\n');
    return 1;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:52,代码来源:fsdbutil.c

示例14: bmap

diskaddr_t
bmap(diskaddr_t i)
{
	daddr32_t ibuf[MAXNINDIR];

	if (i < NDADDR)
		return ((diskaddr_t)gip->di_db[i]);
	i -= NDADDR;
	if (i > NINDIR(&sblock)) {
		(void) fprintf(stderr, "ff    : %lu - huge directory\n", ino);
		return ((diskaddr_t)0);
	}
	bread(fsbtodb(&sblock, gip->di_ib[0]), (char *)ibuf, sizeof (ibuf));
	return ((diskaddr_t)ibuf[i]);
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:15,代码来源:ff.c

示例15: collapse_dirhole

/*
 * Truncate a directory to its first hole.  If there are non-holes
 * in the direct blocks after the problem block, move them down so
 * that there's somewhat less lossage.  Doing this for indirect blocks
 * is left as an exercise for the reader.
 */
static void
collapse_dirhole(fsck_ino_t inumber, struct inodesc *idesc)
{
	offset_t new_size;
	int blocks;

	if (idesc->id_firsthole < 0) {
		return;
	}

	/*
	 * Since truncino() adjusts the size, we don't need to do that here,
	 * but we have to tell it what final size we want.
	 *
	 * We need to count from block zero up through the last block
	 * before the hole.  If the hole is in the indirect blocks, chop at
	 * the start of the nearest level of indirection.  Orphans will
	 * get reconnected, so we're not actually losing anything by doing
	 * it this way, and we're simplifying truncation significantly.
	 */
	new_size = idesc->id_firsthole * (offset_t)sblock.fs_bsize;
	blocks = howmany(new_size, sblock.fs_bsize);
	if (blocks > NDADDR) {
		if (blocks < (NDADDR + NINDIR(&sblock)))
			blocks = NDADDR;
		else if (blocks < (NDADDR + NINDIR(&sblock) +
		    (NINDIR(&sblock) * NINDIR(&sblock))))
			blocks = NDADDR + NINDIR(&sblock);
		else
			blocks = NDADDR + NINDIR(&sblock) +
			    (NINDIR(&sblock) * NINDIR(&sblock));
		new_size = blocks * sblock.fs_bsize;
		if (debug)
			(void) printf("to %lld (blocks %d)\n",
			    (longlong_t)new_size, blocks);
	}
	truncino(inumber, new_size, TI_NOPARENT);

	/*
	 * Technically, there are still the original number of fragments
	 * associated with the object.  However, that number is not used
	 * to control anything, so we can do the in-memory truncation of
	 * it without bad things happening.
	 */
	idesc->id_entryno = btodb(new_size);
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:52,代码来源:pass1.c


注:本文中的NINDIR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。