本文整理汇总了C++中sb_bread函数的典型用法代码示例。如果您正苦于以下问题:C++ sb_bread函数的具体用法?C++ sb_bread怎么用?C++ sb_bread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sb_bread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: add_chain
static inline Indirect *get_branch(struct inode *inode,
int depth,
int *offsets,
Indirect chain[DEPTH],
int *err)
{
struct super_block *sb = inode->i_sb;
Indirect *p = chain;
struct buffer_head *bh;
*err = 0;
/* i_data is not going away, no lock needed */
add_chain (chain, NULL, i_data(inode) + *offsets);
if (!p->key)
goto no_block;
while (--depth) {
bh = sb_bread(sb, block_to_cpu(p->key));
if (!bh)
goto failure;
read_lock(&pointers_lock);
if (!verify_chain(chain, p))
goto changed;
add_chain(++p, bh, (block_t *)bh->b_data + *++offsets);
read_unlock(&pointers_lock);
if (!p->key)
goto no_block;
}
return NULL;
changed:
read_unlock(&pointers_lock);
brelse(bh);
*err = -EAGAIN;
goto no_block;
failure:
*err = -EIO;
no_block:
return p;
}
开发者ID:markthueson,项目名称:cs6460,代码行数:39,代码来源:itree_common.c
示例2: update_dind_extent_range
static int update_dind_extent_range(handle_t *handle, struct inode *inode,
ext4_fsblk_t pblock, ext4_lblk_t *blk_nump,
struct list_blocks_struct *lb)
{
struct buffer_head *bh;
__le32 *i_data;
int i, retval = 0;
ext4_lblk_t blk_count = *blk_nump;
unsigned long max_entries = inode->i_sb->s_blocksize >> 2;
if (!pblock) {
/* Only update the file block number */
*blk_nump += max_entries * max_entries;
return 0;
}
bh = sb_bread(inode->i_sb, pblock);
if (!bh)
return -EIO;
i_data = (__le32 *)bh->b_data;
for (i = 0; i < max_entries; i++) {
if (i_data[i]) {
retval = update_ind_extent_range(handle, inode,
le32_to_cpu(i_data[i]),
&blk_count, lb);
if (retval)
break;
} else {
/* Only update the file block number */
blk_count += max_entries;
}
}
/* Update the file block number */
*blk_nump = blk_count;
put_bh(bh);
return retval;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:39,代码来源:migrate.c
示例3: read_raw_super_block
/*
* Read f2fs raw super block.
* Because we have two copies of super block, so read the first one at first,
* if the first one is invalid, move to read the second one.
*/
static int read_raw_super_block(struct super_block *sb,
struct f2fs_super_block **raw_super,
struct buffer_head **raw_super_buf)
{
int block = 0;
retry:
*raw_super_buf = sb_bread(sb, block);
if (!*raw_super_buf) {
f2fs_msg(sb, KERN_ERR, "Unable to read %dth superblock",
block + 1);
if (block == 0) {
block++;
goto retry;
} else {
return -EIO;
}
}
*raw_super = (struct f2fs_super_block *)
((char *)(*raw_super_buf)->b_data + F2FS_SUPER_OFFSET);
/* sanity checking of raw super */
if (sanity_check_raw_super(sb, *raw_super)) {
brelse(*raw_super_buf);
f2fs_msg(sb, KERN_ERR,
"Can't find valid F2FS filesystem in %dth superblock",
block + 1);
if (block == 0) {
block++;
goto retry;
} else {
return -EINVAL;
}
}
return 0;
}
开发者ID:achaykin,项目名称:android_kernel_huawei_viva,代码行数:43,代码来源:super.c
示例4: ux_readdir
int
ux_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
unsigned long pos;
struct inode *inode = filp->f_dentry->d_inode;
struct ux_inode *uip = (struct ux_inode *)
&inode->i_private;
struct ux_dirent *udir;
struct buffer_head *bh;
__u32 blk;
start_again:
pos = filp->f_pos;
if (pos >= inode->i_size) {
return 0;
}
blk = (pos + 1) / UX_BSIZE;
blk = uip->i_addr[blk];
bh = sb_bread(inode->i_sb, blk);
udir = (struct ux_dirent *)(bh->b_data + pos % UX_BSIZE);
/*
* Skip over 'null' directory entries.
*/
if (udir->d_ino == 0) {
filp->f_pos += sizeof(struct ux_dirent);
brelse(bh);
goto start_again;
} else {
filldir(dirent, udir->d_name,
sizeof(udir->d_name), pos,
udir->d_ino, DT_UNKNOWN);
}
filp->f_pos += sizeof(struct ux_dirent);
brelse(bh);
return 0;
}
开发者ID:dunecn,项目名称:uxfs,代码行数:38,代码来源:ux_dir.c
示例5: entry
/* Returns the inode number of the directory entry at offset pos. If bh is
non-NULL, it is brelse'd before. Pos is incremented. The buffer header is
returned in bh.
AV. Most often we do it item-by-item. Makes sense to optimize.
AV. OK, there we go: if both bh and de are non-NULL we assume that we just
AV. want the next entry (took one explicit de=NULL in vfat/namei.c).
AV. It's done in fat_get_entry() (inlined), here the slow case lives.
AV. Additionally, when we return -1 (i.e. reached the end of directory)
AV. we make bh NULL.
*/
static int fat__get_entry(struct inode *dir, loff_t *pos,
struct buffer_head **bh, struct msdos_dir_entry **de)
{
struct super_block *sb = dir->i_sb;
sector_t phys, iblock;
unsigned long mapped_blocks;
int err, offset;
next:
if (*bh)
brelse(*bh);
*bh = NULL;
iblock = *pos >> sb->s_blocksize_bits;
err = fat_bmap(dir, iblock, &phys, &mapped_blocks, 0);
if (err || !phys)
return -1; /* beyond EOF or error */
fat_dir_readahead(dir, iblock, phys);
*bh = sb_bread(sb, phys);
if (*bh == NULL) {
/* [email protected] remove error message at pulling sd card without unmount */
#ifdef LGE_REMOVE_ERROR
printk(KERN_ERR "FAT: Directory bread(block %llu) failed\n",
(llu)phys);
#endif
/* skip this block */
*pos = (iblock + 1) << sb->s_blocksize_bits;
goto next;
}
offset = *pos & (sb->s_blocksize - 1);
*pos += sizeof(struct msdos_dir_entry);
*de = (struct msdos_dir_entry *)((*bh)->b_data + offset);
return 0;
}
开发者ID:Shabbypenguin,项目名称:Cayman-Island-Kernel,代码行数:48,代码来源:dir.c
示例6: udf_symlink_filler
static int udf_symlink_filler(struct file *file, struct page *page)
{
struct inode *inode = page->mapping->host;
struct buffer_head *bh = NULL;
char *symlink;
int err = -EIO;
char *p = kmap(page);
struct udf_inode_info *iinfo;
lock_kernel();
iinfo = UDF_I(inode);
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
symlink = iinfo->i_ext.i_data + iinfo->i_lenEAttr;
} else {
bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
if (!bh)
goto out;
symlink = bh->b_data;
}
udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p);
brelse(bh);
unlock_kernel();
SetPageUptodate(page);
kunmap(page);
unlock_page(page);
return 0;
out:
unlock_kernel();
SetPageError(page);
kunmap(page);
unlock_page(page);
return err;
}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:38,代码来源:symlink.c
示例7: hellofs_read
ssize_t hellofs_read(struct file *filp, char __user *buf, size_t len,
loff_t *ppos) {
struct super_block *sb;
struct inode *inode;
struct hellofs_inode *hellofs_inode;
struct buffer_head *bh;
char *buffer;
int nbytes;
inode = filp->f_path.dentry->d_inode;
sb = inode->i_sb;
hellofs_inode = HELLOFS_INODE(inode);
if (*ppos >= hellofs_inode->file_size) {
return 0;
}
bh = sb_bread(sb, hellofs_inode->data_block_no);
if (!bh) {
printk(KERN_ERR "Failed to read data block %llu\n",
hellofs_inode->data_block_no);
return 0;
}
buffer = (char *)bh->b_data + *ppos;
nbytes = min((size_t)(hellofs_inode->file_size - *ppos), len);
if (copy_to_user(buf, buffer, nbytes)) {
brelse(bh);
printk(KERN_ERR
"Error copying file content to userspace buffer\n");
return -EFAULT;
}
brelse(bh);
*ppos += nbytes;
return nbytes;
}
开发者ID:accelazh,项目名称:hellofs,代码行数:38,代码来源:file.c
示例8: read_from_real_sfs
static int read_from_real_sfs(sfs_info_t *info, byte4_t block, byte4_t offset, void *buf, byte4_t len)
{
byte4_t block_size = info->sb.block_size;
byte4_t bd_block_size = info->vfs_sb->s_bdev->bd_block_size;
byte4_t abs;
struct buffer_head *bh;
// Translating the real SFS block numbering to underlying block device block numbering, for sb_bread()
abs = block * block_size + offset;
block = abs / bd_block_size;
offset = abs % bd_block_size;
if (offset + len > bd_block_size) // Should never happen
{
return -EINVAL;
}
if (!(bh = sb_bread(info->vfs_sb, block)))
{
return -EIO;
}
memcpy(buf, bh->b_data + offset, len);
brelse(bh);
return 0;
}
开发者ID:gokul-github,项目名称:linuxpedia,代码行数:23,代码来源:real_sfs_ops.c
示例9: befs_bread
struct buffer_head *
befs_bread(struct super_block *sb, befs_blocknr_t block)
{
struct buffer_head *bh = NULL;
befs_debug(sb, "---> Enter %s %lu", __func__, (unsigned long)block);
bh = sb_bread(sb, block);
if (bh == NULL) {
befs_error(sb, "Failed to read block %lu",
(unsigned long)block);
goto error;
}
befs_debug(sb, "<--- %s", __func__);
return bh;
error:
befs_debug(sb, "<--- %s ERROR", __func__);
return NULL;
}
开发者ID:020gzh,项目名称:linux,代码行数:23,代码来源:io.c
示例10: ubh_bread_uspi
struct ufs_buffer_head * ubh_bread_uspi (struct ufs_sb_private_info * uspi,
struct super_block *sb, u64 fragment, u64 size)
{
unsigned i, j;
u64 count = 0;
if (size & ~uspi->s_fmask)
return NULL;
count = size >> uspi->s_fshift;
if (count <= 0 || count > UFS_MAXFRAG)
return NULL;
USPI_UBH(uspi)->fragment = fragment;
USPI_UBH(uspi)->count = count;
for (i = 0; i < count; i++)
if (!(USPI_UBH(uspi)->bh[i] = sb_bread(sb, fragment + i)))
goto failed;
for (; i < UFS_MAXFRAG; i++)
USPI_UBH(uspi)->bh[i] = NULL;
return USPI_UBH(uspi);
failed:
for (j = 0; j < i; j++)
brelse (USPI_UBH(uspi)->bh[j]);
return NULL;
}
开发者ID:AK101111,项目名称:linux,代码行数:23,代码来源:util.c
示例11: minix_V1_raw_inode
struct minix_inode *
minix_V1_raw_inode(struct super_block *sb, ino_t ino, struct buffer_head **bh)
{
int block;
struct minix_sb_info *sbi = minix_sb(sb);
struct minix_inode *p;
if (!ino || ino > sbi->s_ninodes) {
printk("Bad inode number on dev %s: %ld is out of range\n",
sb->s_id, (long)ino);
return NULL;
}
ino--;
block = 2 + sbi->s_imap_blocks + sbi->s_zmap_blocks +
ino / MINIX_INODES_PER_BLOCK;
*bh = sb_bread(sb, block);
if (!*bh) {
printk("Unable to read inode block\n");
return NULL;
}
p = (void *)(*bh)->b_data;
return p + ino % MINIX_INODES_PER_BLOCK;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:23,代码来源:bitmap.c
示例12: lab5fs_inode_init_block_index
/*
* Initialize a data index block for specified inode at specified block number
*
*/
int lab5fs_inode_init_block_index(struct inode *ino, int bi_block_num)
{
int err = 0;
struct super_block *sb = ino->i_sb;
struct buffer_head *bibh = NULL;
struct lab5fs_inode_data_index *lab5fs_data_index = NULL;
/* read the inode's block index. */
if (!(bibh = sb_bread(sb, bi_block_num))) {
printk("unable to read inode block index, block %d.\n",
bi_block_num);
err = -ENOMEM;
goto ret;
}
lab5fs_data_index = (struct lab5fs_inode_data_index *)(bibh->b_data);
memset(lab5fs_data_index->blocks, 0, sizeof(*lab5fs_data_index));
mark_buffer_dirty(bibh);
ret:
if (bibh)
brelse(bibh);
return err;
}
开发者ID:souravzzz,项目名称:lab5fs,代码行数:27,代码来源:lab5fs_inode.c
示例13: lab5fs_inode_clear_blocks
/*Clear out data and data index blocks of given inode*/
void lab5fs_inode_clear_blocks(struct inode *ino){
struct super_block *sb = ino->i_sb;
struct lab5fs_inode_info *inode_info = LAB5FS_INODE_INFO(ino);
int bi_block_num = inode_info->i_bi_block_num;
struct buffer_head *bibh = NULL;
struct lab5fs_inode_data_index *block_index_table = NULL;
int i, block_num;
printk("inode_clear_blocks:: freeing data blocks \n");
/* read the inode's block index. */
if (!(bibh = sb_bread(sb, bi_block_num))) {
printk("unable to read block index, block %d.\n",bi_block_num);
}
block_index_table = (struct lab5fs_inode_data_index *) bibh->b_data;
for (i=0;i < LAB5FS_MAX_BLOCK_INDEX; i++) {
block_num = le32_to_cpu(block_index_table->blocks[i]);
if (block_num != 0) { //block is in used
printk("freeing block %u\n",block_num);
lab5fs_release_block_num(sb, block_num);
}
}
ino->i_blocks=0;
}
开发者ID:souravzzz,项目名称:lab5fs,代码行数:24,代码来源:lab5fs_inode.c
示例14: free_branches
static void free_branches(struct inode *inode, block_t *p, block_t *q, int depth)
{
struct buffer_head * bh;
unsigned long nr;
if (depth--) {
for ( ; p < q ; p++) {
nr = block_to_cpu(*p);
if (!nr)
continue;
*p = 0;
bh = sb_bread(inode->i_sb, nr);
if (!bh)
continue;
free_branches(inode, (block_t*)bh->b_data,
block_end(bh), depth);
bforget(bh);
xiafs_free_block(inode, nr);
mark_inode_dirty(inode);
}
} else
free_data(inode, p, q);
}
开发者ID:ctdk,项目名称:modern-xiafs,代码行数:23,代码来源:itree.c
示例15: dedupfs_inode_add
void dedupfs_inode_add(struct super_block *vsb,
struct dedupfs_inode *inode)
{
struct dedupfs_super_block *sb = DEDUPFS_SB(vsb);
struct buffer_head *bh;
struct dedupfs_inode *inode_iterator;
if(mutex_lock_interruptible(&dedupfs_inodes_mgmt_lock)) {
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
__FILE__, __LINE__);
return;
}
bh = (struct buffer_head *)sb_bread(vsb,
DEDUPFS_INODESTORE_BLOCK_NUMBER);
inode_iterator = (struct dedupfs_inode *)bh->b_data;
if(mutex_lock_interruptible(&dedupfs_sb_lock)) {
printk(KERN_ERR "Failed to acquire mutex lock %s +%d\n",
__FILE__, __LINE__);
return;
}
/* Append the new inode in the end in the inode store */
inode_iterator += sb->inodes_count;
memcpy(inode_iterator, inode, sizeof(struct dedupfs_inode));
sb->inodes_count++;
mark_buffer_dirty(bh);
dedupfs_sb_sync(vsb);
mutex_unlock(&dedupfs_sb_lock);
mutex_unlock(&dedupfs_inodes_mgmt_lock);
}
开发者ID:Flynston,项目名称:ProgMonk,代码行数:37,代码来源:super.c
示例16: while
static struct buffer_head *qnx4_find_entry(int len, struct inode *dir,
const char *name, struct qnx4_inode_entry **res_dir, int *ino)
{
unsigned long block, offset, blkofs;
struct buffer_head *bh;
*res_dir = NULL;
bh = NULL;
block = offset = blkofs = 0;
while (blkofs * QNX4_BLOCK_SIZE + offset < dir->i_size) {
if (!bh) {
block = qnx4_block_map(dir, blkofs);
if (block)
bh = sb_bread(dir->i_sb, block);
if (!bh) {
blkofs++;
continue;
}
}
*res_dir = (struct qnx4_inode_entry *) (bh->b_data + offset);
if (qnx4_match(len, name, bh, &offset)) {
*ino = block * QNX4_INODES_PER_BLOCK +
(offset / QNX4_DIR_ENTRY_SIZE) - 1;
return bh;
}
if (offset < bh->b_size) {
continue;
}
brelse(bh);
bh = NULL;
offset = 0;
blkofs++;
}
brelse(bh);
*res_dir = NULL;
return NULL;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:37,代码来源:namei.c
示例17: fat__get_entry
static int fat__get_entry(struct inode *dir, loff_t *pos,
struct buffer_head **bh, struct msdos_dir_entry **de)
{
struct super_block *sb = dir->i_sb;
sector_t phys, iblock;
unsigned long mapped_blocks;
int err, offset, retry_count;
retry_count = MAX_BREAD_TRYCOUNT;
next:
if (*bh)
brelse(*bh);
*bh = NULL;
iblock = *pos >> sb->s_blocksize_bits;
err = fat_bmap(dir, iblock, &phys, &mapped_blocks, 0);
if (err || !phys)
return -1; /* beyond EOF or error */
fat_dir_readahead(dir, iblock, phys);
*bh = sb_bread(sb, phys);
if (*bh == NULL) {
fat_msg(sb, KERN_DEBUG, "Directory bread(block %llu) failed",
(llu)phys);
/* skip this block */
*pos = (iblock + 1) << sb->s_blocksize_bits;
if(retry_count-- < 0)
return -1;
goto next;
}
offset = *pos & (sb->s_blocksize - 1);
*pos += sizeof(struct msdos_dir_entry);
*de = (struct msdos_dir_entry *)((*bh)->b_data + offset);
return 0;
}
开发者ID:Scorpio92,项目名称:mstar6a918,代码行数:37,代码来源:dir.c
示例18: entry
/* Returns the inode number of the directory entry at offset pos. If bh is
non-NULL, it is brelse'd before. Pos is incremented. The buffer header is
returned in bh.
AV. Most often we do it item-by-item. Makes sense to optimize.
AV. OK, there we go: if both bh and de are non-NULL we assume that we just
AV. want the next entry (took one explicit de=NULL in vfat/namei.c).
AV. It's done in fat_get_entry() (inlined), here the slow case lives.
AV. Additionally, when we return -1 (i.e. reached the end of directory)
AV. we make bh NULL.
*/
static int fat__get_entry(struct inode *dir, loff_t *pos,
struct buffer_head **bh, struct msdos_dir_entry **de)
{
struct super_block *sb = dir->i_sb;
sector_t phys, iblock;
unsigned long mapped_blocks;
int err, offset;
next:
if (*bh)
brelse(*bh);
*bh = NULL;
iblock = *pos >> sb->s_blocksize_bits;
err = fat_bmap(dir, iblock, &phys, &mapped_blocks, 0);
if (err || !phys)
return -1; /* beyond EOF or error */
fat_dir_readahead(dir, iblock, phys);
*bh = sb_bread(sb, phys);
if (*bh == NULL) {
#ifndef CONFIG_MACH_LGE
fat_msg_ratelimit(sb, KERN_ERR,
"Directory bread(block %llu) failed", (llu)phys);
#endif
/* skip this block */
*pos = (iblock + 1) << sb->s_blocksize_bits;
goto next;
}
offset = *pos & (sb->s_blocksize - 1);
*pos += sizeof(struct msdos_dir_entry);
*de = (struct msdos_dir_entry *)((*bh)->b_data + offset);
return 0;
}
开发者ID:Emineminero,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:47,代码来源:dir.c
示例19: uxfs_find_entry
int uxfs_find_entry(struct inode *dip, char *name)
{
struct uxfs_inode_info *uxi = uxfs_i(dip);
struct super_block *sb = dip->i_sb;
struct buffer_head *bh = NULL;
struct uxfs_dirent *dirent;
int i, blk = 0;
for (blk = 0; blk < uxi->uip.i_blocks; blk++) {
bh = sb_bread(sb, uxi->uip.i_addr[blk]);
dirent = (struct uxfs_dirent *)bh->b_data;
for (i = 0; i < UXFS_DIRS_PER_BLOCK; i++) {
if (strcmp(dirent->d_name, name) == 0) {
brelse(bh);
return dirent->d_ino;
}
dirent++;
}
}
if (bh)
brelse(bh);
return 0;
}
开发者ID:majpaul,项目名称:uxfs,代码行数:24,代码来源:uxfs_inode.c
示例20: befs_bread_iaddr
struct buffer_head *
befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
{
struct buffer_head *bh = NULL;
befs_blocknr_t block = 0;
struct befs_sb_info *befs_sb = BEFS_SB(sb);
befs_debug(sb, "---> Enter %s "
"[%u, %hu, %hu]", __func__, iaddr.allocation_group,
iaddr.start, iaddr.len);
if (iaddr.allocation_group > befs_sb->num_ags) {
befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
iaddr.allocation_group, befs_sb->num_ags);
goto error;
}
block = iaddr2blockno(sb, &iaddr);
befs_debug(sb, "%s: offset = %lu", __func__, (unsigned long)block);
bh = sb_bread(sb, block);
if (bh == NULL) {
befs_error(sb, "Failed to read block %lu",
(unsigned long)block);
goto error;
}
befs_debug(sb, "<--- %s", __func__);
return bh;
error:
befs_debug(sb, "<--- %s ERROR", __func__);
return NULL;
}
开发者ID:020gzh,项目名称:linux,代码行数:36,代码来源:io.c
注:本文中的sb_bread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论