• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ put_block函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: minix_dir_empty

static int minix_dir_empty(struct inode *dir)
{
	struct block *block;
	struct minix_dentry *de;
	int entries, i, k, n;
	/* Assert that @dir is directory inode. */
	entries = dir->i_size / MINIX_DENTRY_SIZE;
	for (i = 0; i < entries; i += n) {
		n = min(entries - i, MINIX_DENTRIES_PER_BLOCK);
		block = bmap_block(dir, i / MINIX_DENTRIES_PER_BLOCK, 0);
		if (!block)
			continue;
		de = (struct minix_dentry *)block->b_data;
		for (k = 0; k < n; k++, de++) {
			if (de->d_ino == 0)
				continue;
			if (de->d_name[0] != '.')
				goto not_empty;
			if (de->d_name[1] == '\0') {
				if (de->d_ino != dir->i_ino)
					panic("The inode number of . corrupts");
				continue;
			}
			if (de->d_name[1] != '.' || de->d_name[2] != '\0')
				goto not_empty;
		}
		put_block(block);
	}
	return 1;
not_empty:
	put_block(block);
	return 0;
}
开发者ID:chobits,项目名称:tinyos,代码行数:33,代码来源:inode.c


示例2: bmap_block

struct minix_dentry *minix_lookup_dentry(struct inode *dir, char *base, int len, struct block **b)
{
	struct minix_dentry *de;
	struct block *block;
	int entries, i, k, n;

	if (len > MINIX_NAME_LEN)
		return NULL;

	entries = dir->i_size / MINIX_DENTRY_SIZE;
	for (i = 0; i < entries; i += n) {
		block = bmap_block(dir, i / MINIX_DENTRIES_PER_BLOCK, 0);
		de = (struct minix_dentry *)block->b_data;
		n = min(entries - i, MINIX_DENTRIES_PER_BLOCK);
		for (k = 0; k < n; k++, de++) {
			if (de->d_ino == 0)
				continue;
			/* strncmp skips deleted entry automatically. */
			if (strlen(de->d_name) == len &&
				!strncmp(de->d_name, base, len))
				goto found;
		}
		put_block(block);
	}
	return NULL;
found:
	if (b)
		*b = block;
	else
		put_block(block);
	return de;
}
开发者ID:chobits,项目名称:tinyos,代码行数:32,代码来源:inode.c


示例3: dir_search

/**
 * Looks for entry 'file' in the given directory contents. The inode is 
 * assumed to be of directory type.
 *
 * If the file is found it's inode number is returned, otherwise NO_INODE is
 * returned.
 */
inode_nr dir_search(struct minix_inode *inode, const char *file)
{
	struct minix_block *blk;	/* block belonging to inode */
	zone_nr z;			
	int c_pos = 0;		/* current position in scan of directory */
	int i;			/* current position in directory block */
	inode_nr retval;

	debug("dir_search(%d, \"%s\"): searching...", inode->i_num,
		file);
	while((z = read_map(inode, c_pos)) != NO_ZONE) {
		blk = get_block(z, TRUE);
		/* TODO: fix bug. shouldn't use BLOCK_SIZE */
		for(i = 0; i < BLOCK_SIZE; i+= DENTRY_SIZE) {
			if(strcmp((char *)(blk->blk_data + i + 2), file) == 0) {
				retval = *((inode_nr *)(blk->blk_data + i));
				put_block(blk, DIR_BLOCK);
				debug("dir_search(): found \"%s\" at ix=%d", 
					file, i);
				return retval;
			}
		}
		put_block(blk, DIR_BLOCK);
		c_pos += BLOCK_SIZE;
	}

	/* couldn't find directory entry */
	debug("dir_search(%d, \"%s\"): couldn't find entry", inode->i_num, 
		file);
	return NO_INODE;
}
开发者ID:jordan-dinwiddy,项目名称:Somix,代码行数:38,代码来源:read.c


示例4: block_test

void block_test(void)
{
	struct block *block;
	unsigned char *p;
	int i;
	block = get_block(&hd_bdev, 0);
	if (!block)
		panic("Cannot get block");
	if (block != get_block(&hd_bdev, 0))
		panic("Cannot get hash block");
	put_block(block);
	p = (unsigned char *)block->b_data;
	if (p[510] != 0x55 || p[511] != 0xaa)
		panic("ERROR 0x55aa");
	p[0] = 'h';
	p[1] = 'k';
	block->b_dirty = 1;
	put_block(block);
	block = get_block(&hd_bdev, 0);
	p = (unsigned char *)block->b_data;
	if (p[0] != 'h' || p[1] != 'k')
		panic("block WRITE or READ error");
	for (i = 0; i < 512; i++)
		p[i] = 0xff;
	block->b_dirty = 1;
	put_block(block);
	printk("flush buffer\n");
	flush_block_buffer();
	block = get_block(&hd_bdev, 0);
	printk("test block ok\n");
}
开发者ID:chobits,项目名称:tinyos,代码行数:31,代码来源:block.c


示例5: sfs_write

int sfs_write(int fd, int start, int length, char *mem_pointer){
  int size;
  int i;
 /* if(sscanf(fd, "%i",  &intvar)!=1)
    return -1;
  if(sscanf(start, "%i" , &intvar)!=1)
    return -1;
  if(sscanf(length, "%i",  &intvar)!=1)
    return -1;
  */
  if(strlen(mem_pointer)!=length){
    printf("too many characters entered!");
    return -1;
  }
  if(inode[fd][1]==1)
    return -1;
  if(OpenFileTable[fd][0]==0)
    return -1;
  if(OpenFileTable[fd][0]>1)
    return -1;
  printf("%d", strlen(mem_pointer));
  char tmp_buffer[MAX_IO_LENGTH+1];
  printf("%d", inode[fd][2]);
  size=inode[fd][2];
  
  memcpy(tmp_buffer, RAM[OpenFileTable[fd][1]], sizeof(RAM[OpenFileTable[fd][1]]));
  if(!(inode[fd][3]==NULL)){
    
    if(start==-1){
      if(size!=0){
      strcat(tmp_buffer, mem_pointer);
      //memcpy(mem_pointer, tmp_buffer, sizeof(tmp_buffer));
      }
      inode[fd][2]=size+length;
      memcpy(RAM[OpenFileTable[fd][1]], tmp_buffer, sizeof(tmp_buffer));
      put_block(inode[fd][3],mem_pointer);
      return 1;
      //char tmp_buffer2[size + length+1];
      //get_block(inode[fd][3], tmp_buffer);
    }else if((start + length)> size){
      printf("size issue");
      return -1;
    }else{
      memcpy(tmp_buffer, RAM[OpenFileTable[fd][1]], sizeof(RAM[OpenFileTable[fd][1]]));

      for(i=start;i<start+length;i++){
	tmp_buffer[i]=mem_pointer[i-start];
      }
      //memcpy(tmp_buffer+start, mem_pointer, sizeof(mem_pointer));
      memcpy(RAM[OpenFileTable[fd][1]], tmp_buffer, sizeof(tmp_buffer));
      put_block(inode[fd][3],mem_pointer);
      return 1;
    }
    
  }
  return -1;
}
开发者ID:Adge2k,项目名称:Comp-Sci-OS-Project,代码行数:57,代码来源:sfs_test.c


示例6: decFreeInodes

int decFreeInodes(int fd) {
    char buf[BLOCK_SIZE];
    // dec free inodes count in Super and GroupDesc
    _get_block(fd, 1, buf);
    Super * super = (Super *) buf;
    super->s_free_inodes_count--;
    put_block(fd, 1, buf);
    _get_block(fd, 2, buf);
    GroupDesc * gp = (GroupDesc *) buf;
    gp->bg_free_inodes_count--;
    put_block(fd, 2, buf);
    return 0;
}
开发者ID:yuchenhou,项目名称:systems-programming,代码行数:13,代码来源:lab6.c


示例7: minix_lookup_dentry

struct inode *minix_inode_create(struct inode *dir, char *base, int len)
{
	struct minix_dentry *de;
	struct inode *inode;
	struct block *block;
	int entries, i, k, n;

	if (len > MINIX_NAME_LEN)
		return NULL;
	/* exist? */
	de = minix_lookup_dentry(dir, base, len, NULL);
	if (de)
		return NULL;
	/* find an empty dir entry */
	entries = dir->i_size / MINIX_DENTRY_SIZE;
	for (i = 0; i < entries; i += n) {
		block = bmap_block(dir, i / MINIX_DENTRIES_PER_BLOCK, 0);
		de = (struct minix_dentry *)block->b_data;
		n = min(entries - i, MINIX_DENTRIES_PER_BLOCK);
		for (k = 0; k < n; k++, de++) {
			if (de->d_ino == 0)
				goto found;
		}
		if (i + n < entries || !(entries % MINIX_DENTRIES_PER_BLOCK)) {
			put_block(block);
			block = NULL;
		}
	}
	/* create a new data block and get dir entry from it */
	if (!block) {
		block = bmap_block(dir, entries / MINIX_DENTRIES_PER_BLOCK, 1);
		if (!block)
			return NULL;
		if (block->b_refcnt != 1)
			panic("Not new block(ref:%d)", block->b_refcnt);
		de = (struct minix_dentry *)block->b_data;
	}
	inode_update_size(dir, dir->i_size + MINIX_DENTRY_SIZE);
found:
	inode = minix_new_inode(dir->i_sb);
	if (!inode)
		goto out;
	/* fill dir entry */
	strncpy(de->d_name, base, len);
	de->d_name[len] = '\0';
	de->d_ino = inode->i_ino;
	minix_inode_dirty_block(dir, block);
out:
	put_block(block);
	return inode;
}
开发者ID:chobits,项目名称:tinyos,代码行数:51,代码来源:inode.c


示例8: updateFreeInodes

int updateFreeInodes(int devId, int delta) {
	char buf[BLKSIZE];

	// dec free inodes count in SUPER and GD
	get_block(devId, 1, buf);
	sp = (SUPER *)buf;
	sp->s_free_inodes_count + delta;
	put_block(devId, 1, buf);

	get_block(devId, 2, buf);
	gp = (GD *)buf;
	gp->bg_free_inodes_count + delta;
	put_block(devId, 2, buf);
}
开发者ID:techfreek,项目名称:WSU_360_SysProgramming,代码行数:14,代码来源:utility.c


示例9: updateFreeBlocks

//Pass 1 to increase by 1, -1 to decrease by 1, etc
int updateFreeBlocks(int devId, int delta) {
	char buf[BLKSIZE];

	// update free block count in SUPER and GD
	get_block(devId, 1, buf);
	sp = (SUPER *)buf;
	sp->s_free_blocks_count + delta;
	put_block(devId, 1, buf);

	get_block(devId, 2, buf);
	gp = (GD *)buf;
	gp->bg_free_blocks_count + delta;
	put_block(devId, 2, buf);
}
开发者ID:techfreek,项目名称:WSU_360_SysProgramming,代码行数:15,代码来源:utility.c


示例10: decFreeInodes

void decFreeInodes(int dev)
{
	char buf[BLKSIZE];

	//dec free inodes count in SUPER and gd
	get_block(dev, 1, buf);
	sp = (SUPER *)buf;
	sp->s_free_inodes_count--;
	put_block(dev, 1, buf);

	get_block(dev, 2, buf);
	gp = (GD *)buf;
	gp->bg_free_inodes_count--;
	put_block(dev, 2, buf);
}
开发者ID:lldarrow,项目名称:CptS-360-File-Systems,代码行数:15,代码来源:alloc_dealloc.c


示例11: split_index_node

/* splits the index node at the given level of the given path */
PRIVATE int split_index_node(struct root *r, struct path *p, int level) {
	int slot = p->slots[level];
	struct cache *left = p->nodes[level];
	int nritems = left->u.node.header.nritems;
	int nrstaying = nritems/2;			/* smaller half stays on the left */
	int nrmoving = nritems - nrstaying;	/* larger half moves to the right */
	struct cache *right;
	blocknr_t rightnr;

	assert(left->will_write);	/* was ensured on tree descent */
	rightnr = alloc_block(r->fs_info, left, left->u.node.header.type);
	if (!rightnr) return -ENOSPC;
	right = init_node(rightnr, left->u.node.header.type, level);
	if (!right) return -errno;
	if(is_root_level(level, p)) {	/* no node above, so need to grow tree */
		blocknr_t new_rootnr;
		struct cache *c;

		assert(level < MAX_LEVEL - 1);	/* has room to add another level */
		new_rootnr = alloc_block(r->fs_info, right, right->u.node.header.type);
		if (!new_rootnr) return -ENOSPC;
		c = init_node(new_rootnr, right->u.node.header.type, level + 1);
		if (!c) return -errno;
		p->nodes[level + 1] = c;
		p->slots[level + 1] = 0;	/* path on the left node */
		insert_key_ptr(r, p, level + 1,
						key_for(left, 0), left->write_blocknr);
		r->blocknr = new_rootnr;
	}
	memmove(&right->u.node.u.key_ptrs[0],	/* move larger half to right node */
			&left->u.node.u.key_ptrs[nrstaying],
			nrmoving * sizeof(struct key_ptr));
	right->u.node.header.nritems = nrmoving;
	memset(&left->u.node.u.key_ptrs[nrstaying], 0,	/* clear moved in left */
			nrmoving * sizeof(struct key_ptr));
	left->u.node.header.nritems = nrstaying;
	p->slots[level + 1]++;		/* temporarily, for inserting in parent node */
	insert_key_ptr(r, p, level + 1, key_for(right, 0), rightnr);
	if (slot >= nrstaying) {		/* need to change path to the right */
		p->nodes[level] = right;
		p->slots[level] = slot - nrstaying;
		put_block(left);			/* free left since it's now off the path */
	} else {
		p->slots[level + 1]--;		/* path back to left node in parent node */
		put_block(right);			/* free right since it's not on the path */
	}
	return SUCCESS;
}
开发者ID:jdbeutel,项目名称:ics612-babyfs,代码行数:49,代码来源:tree.c


示例12: dir_try_enter

int
dir_try_enter(zone_t z, ino_t child, char const *name)
{
  struct direct *dir_entry = alloc_block();
  int r = 0;
  block_t b;
  int i, l;

  b = z << zone_shift;
  for (l = 0; l < zone_per_block; l++, b++) {
	get_block(b, dir_entry);

	for (i = 0; i < NR_DIR_ENTRIES(block_size); i++)
		if (!dir_entry[i].d_ino)
			break;

	if(i < NR_DIR_ENTRIES(block_size)) {
		r = 1;
		dir_entry[i].d_ino = child;
		assert(sizeof(dir_entry[i].d_name) == MFS_DIRSIZ);
		if (verbose && strlen(name) > MFS_DIRSIZ)
			fprintf(stderr, "File name %s is too long, truncated\n", name);
		strncpy(dir_entry[i].d_name, name, MFS_DIRSIZ);
		put_block(b, dir_entry);
		break;
	}
  }

  free(dir_entry);

  return r;
}
开发者ID:anuragpeshne,项目名称:minix,代码行数:32,代码来源:mkfs.c


示例13: insert_bit

/* Insert one bit into the bitmap */
void
insert_bit(block_t map, bit_t bit)
{
  int boff, w, s;
  unsigned int bits_per_block;
  block_t map_block;
  bitchunk_t *buf;

  buf = alloc_block();

  bits_per_block = FS_BITS_PER_BLOCK(block_size);
  map_block = map + bit / bits_per_block;
  if (map_block >= inode_offset)
	pexit("insertbit invades inodes area - this cannot happen");
  boff = bit % bits_per_block;

  assert(boff >=0);
  assert(boff < FS_BITS_PER_BLOCK(block_size));
  get_block(map_block, buf);
  w = boff / FS_BITCHUNK_BITS;
  s = boff % FS_BITCHUNK_BITS;
  buf[w] |= (1 << s);
  put_block(map_block, buf);

  free(buf);
}
开发者ID:anuragpeshne,项目名称:minix,代码行数:27,代码来源:mkfs.c


示例14: incr_size

/* Increment the file-size in inode n */
void
incr_size(ino_t n, size_t count)
{
  block_t b;
  int off;

  b = ((n - 1) / inodes_per_block) + inode_offset;
  off = (n - 1) % inodes_per_block;
  {
	struct inode *inodes;

	assert(inodes_per_block * sizeof(*inodes) == block_size);
	if(!(inodes = alloc_block()))
		err(1, "couldn't allocate a block of inodes");

	get_block(b, inodes);
	/* Check overflow; avoid compiler spurious warnings */
	if (inodes[off].i_size+(int)count < inodes[off].i_size ||
	    inodes[off].i_size > MAX_MAX_SIZE-(int)count)
		pexit("File has become too big to be handled by MFS");
	inodes[off].i_size += count;
	put_block(b, inodes);
	free(inodes);
  }
}
开发者ID:anuragpeshne,项目名称:minix,代码行数:26,代码来源:mkfs.c


示例15: incr_link

/* Increment the link count to inode n */
void
incr_link(ino_t n)
{
  int off;
  static int enter = 0;
  static struct inode *inodes = NULL;
  block_t b;

  if (enter++) pexit("internal error: recursive call to incr_link()");

  b = ((n - 1) / inodes_per_block) + inode_offset;
  off = (n - 1) % inodes_per_block;
  {
	assert(sizeof(*inodes) * inodes_per_block == block_size);
	if(!inodes && !(inodes = alloc_block()))
		err(1, "couldn't allocate a block of inodes");

	get_block(b, inodes);
	inodes[off].i_nlinks++;
	/* Check overflow (particularly on V1)... */
	if (inodes[off].i_nlinks <= 0)
		pexit("Too many links to a directory");
	put_block(b, inodes);
  }
  enter = 0;
}
开发者ID:anuragpeshne,项目名称:minix,代码行数:27,代码来源:mkfs.c


示例16: put

void
ClientUpdate::put_graph(const GraphImpl* graph)
{
    put(graph->uri(),
        graph->properties(Resource::Graph::INTERNAL),
        Resource::Graph::INTERNAL);

    put(graph->uri(),
        graph->properties(Resource::Graph::EXTERNAL),
        Resource::Graph::EXTERNAL);

    // Enqueue blocks
    for (const auto& b : graph->blocks()) {
        put_block(&b);
    }

    // Enqueue ports
    for (uint32_t i = 0; i < graph->num_ports_non_rt(); ++i) {
        put_port(graph->port_impl(i));
    }

    // Enqueue arcs
    for (const auto& a : graph->arcs()) {
        const SPtr<const Arc> arc     = a.second;
        const Connect         connect = { arc->tail_path(), arc->head_path() };
        connects.push_back(connect);
    }
}
开发者ID:ventosus,项目名称:ingen,代码行数:28,代码来源:ClientUpdate.cpp


示例17: minix_inc_link

struct inode *minix_inode_mkdir(struct inode *dir, char *base, int len)
{
	struct minix_dentry *de;
	struct inode *inode;
	struct block *block;
	if (!(inode = minix_inode_create(dir, base, len)))
		return NULL;
	/* update dir inode information */
	minix_inc_link(dir);
	/* update inode information */
	i2mdi(inode)->i_mode = 0755 | S_IFDIR;
	i2mdi(inode)->i_nlinks = 2;
	inode->i_mode = 0755 | S_IFDIR;
	inode->i_ops = &minix_dir_iops;
	inode_update_size(inode, 2 * MINIX_DENTRY_SIZE);
	/* create dir entry "." and ".." */
	block = minix_new_block(dir->i_sb, &i2mdi(inode)->i_zone[0]);
	if (!block)
		panic("Cannot alloc new block for minixfs");
	/* "." */
	de = (struct minix_dentry *)block->b_data;
	strcpy(de->d_name, ".");
	de->d_ino = inode->i_ino;
	/* ".." */
	de++;
	strcpy(de->d_name, "..");
	de->d_ino = dir->i_ino;
	minix_inode_dirty_block(inode, block);
	put_block(block);
	return inode;
}
开发者ID:chobits,项目名称:tinyos,代码行数:31,代码来源:inode.c


示例18: fs_bitmapdamager

int fs_bitmapdamager()
{
  /*
  m9_s1:dev
  m9_s2:inodenumber
  m9_s3:inode/zone flag
  m9_s4:0 or 1
  */
  struct super_block* sp = get_super(fs_m_in.m9_s1);
  int inodezoneflag = fs_m_in.m9_s3 == 0? 0:sp->s_zmap_blocks;
  int inodenumber = fs_m_in.m9_s2;
  if(fs_m_in.m9_s3 == 1)
  {
    inodenumber -= (sp->s_firstdatazone - 1);
  }
  int blockoff = inodenumber / (sp->s_block_size * 8);
  struct buf* bitmapblock = get_block(fs_m_in.m9_s1,2 + inodezoneflag + blockoff,NORMAL);
  bitchunk_t* mapchunks = (bitchunk_t*)bitmapblock->data;
  int chunkindex = inodenumber / (sizeof(bitchunk_t) * 8);
  int bitindex = inodenumber % (sizeof(bitchunk_t) * 8);
  if(fs_m_in.m9_s4 == 0)
  {
    mapchunks[chunkindex] &= (~((bitchunk_t)1 << (bitindex)));
  }
  else
  {
    mapchunks[chunkindex] |= ((bitchunk_t)1 << (bitindex));
  }
  printf("blockoff:%d chunkindex:%d bitindex:%d\n",blockoff,chunkindex,bitindex);
  put_block(bitmapblock,0);
  return 0;
}
开发者ID:bailichangqing,项目名称:minix3projects,代码行数:32,代码来源:misc.c


示例19: iput

//releases a minode[]
void iput(MINODE *mip)
{
	int ino = getino(mip, ".");
	int offset, ipos;
	char buf[1024];
	
	//decrement refCount by 1
	mip->refCount--;

	//check refcount to see if anyone using it
	//check dirty to see if it's been changed, dirty == 1 if changed
	//if refCount > 0 or dirty return
	if (mip->refCount || !mip->dirty)
		return;

	//mail man's to determine disk block and which inode in that block
	ipos = (ino - 1) / 8 + INODE_START_POS;
	offset = (ino -1) % 8;

	//read that block in
	get_block(dev, ipos, buf);

	//copy minode's inode into the inode area in that block
	ip = (INODE*)buf + offset;
	*ip = mip->INODE;

	//write block back to disk
	put_block(dev, ipos, buf);
}
开发者ID:lldarrow,项目名称:CptS-360-File-Systems,代码行数:30,代码来源:mount_root.c


示例20: put_super_blk

int put_super_blk(void) {
	char *convert;
	convert = calloc(4, sizeof(int));
	char *buf;
	buf = calloc(128, sizeof(char));
	int counter = 0;
	int decimal = 0;
	for(int i=0; i < 512; i++) {
		if (counter == 4) {
			counter = 0;
			decimal = binary_decimal(atoi(convert));

			super_blk_buf[i/4 - 1] = decimal;
			buf[i/4 - 1] = (char)(((int)'0')+decimal);
		}

		convert[counter] = (char)(((int)'0')+disk_bitmap[i]);
        ++counter;
	}

	// Write to memory
	int writesb = put_block(0, buf);

	return decimal;
}
开发者ID:CedricLeong,项目名称:filesystem,代码行数:25,代码来源:super_block.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ put_buffer函数代码示例发布时间:2022-05-30
下一篇:
C++ put_bits_count函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap