本文整理汇总了C++中bwrite函数的典型用法代码示例。如果您正苦于以下问题:C++ bwrite函数的具体用法?C++ bwrite怎么用?C++ bwrite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bwrite函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ext2_htree_writebuf
static int
ext2_htree_writebuf(struct ext2fs_htree_lookup_info *info)
{
int i, error;
for (i = 0; i < info->h_levels_num; i++) {
struct buf *bp = info->h_levels[i].h_bp;
error = bwrite(bp);
if (error)
return (error);
}
return (0);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:14,代码来源:ext2_htree.c
示例2: flush
void
flush(int fd, struct bufarea *bp)
{
int i;
if (!bp->b_dirty)
return;
if (bp->b_errs != 0)
pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
(bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
bp->b_bno);
bp->b_dirty = 0;
bp->b_errs = 0;
bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
if (bp != &sblk)
return;
for (i = 0; i < sblock.e2fs_ngdb; i++) {
bwrite(fswritefd, (char *)
&sblock.e2fs_gd[i* sblock.e2fs_bsize / sizeof(struct ext2_gd)],
fsbtodb(&sblock, ((sblock.e2fs_bsize>1024)?0:1)+i+1),
sblock.e2fs_bsize);
}
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:23,代码来源:utilities.c
示例3: install_trans
// Copy committed blocks from log to their home location
static void
install_trans(void)
{
int tail;
for (tail = 0; tail < log.lh.n; tail++) {
struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block
struct buf *dbuf = bread(log.dev, log.lh.sector[tail]); // read dst
memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst
bwrite(dbuf); // write dst to disk
brelse(lbuf);
brelse(dbuf);
}
}
开发者ID:williamsandrew,项目名称:xv6,代码行数:15,代码来源:log.c
示例4: log_writei
int
log_writei(struct inode *ip, char *src, uint off, uint n)
{
uint tot, m, i, j;
struct buf *tbp;
if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
return -1;
return devsw[ip->major].write(ip, src, n);
}
if(off + n < off)
return -1;
if(off + n > MAXFILE*BSIZE)
n = MAXFILE*BSIZE - off;
b_index = 0; // new xfer, start keeping track of open bufs
/* allocate all space needed */
for(i=0, j=off; i<n; i+=m, j+=m){
log_bmap(ip, j/BSIZE);
m = min(n - i, BSIZE - j%BSIZE);
}
for(tot=0; tot<n; tot+=m, off+=m, src+=m){
bp[b_index] = bread(ip->dev, log_lookup(ip, off/BSIZE));
m = min(n - tot, BSIZE - off%BSIZE);
memmove(bp[b_index]->data + off%BSIZE, src, m);
b_index++;
}
if(n > 0 && off > ip->size){
ip->size = off;
log_iupdate(ip);
}
log_start();
for(i = 0; i < b_index; i++){
bwrite(bp[i]);
brelse(bp[i]);
}
log_end();
return n;
}
开发者ID:fenster,项目名称:xv6-staus-treffert,代码行数:49,代码来源:logfs.c
示例5: send_options_reply
//发送options处理后的响应
int send_options_reply(RTSP_buffer * pRtsp, long cseq)
{
char r[1024];
sprintf(r, "%s %d %s"RTSP_EL"CSeq: %ld"RTSP_EL, RTSP_VER, 200, get_stat(200), cseq);
strcat(r, "Public: OPTIONS,DESCRIBE,SETUP,PLAY,PAUSE,TEARDOWN"RTSP_EL);
strcat(r, RTSP_EL);
bwrite(r, (unsigned short) strlen(r), pRtsp);
#ifdef RTSP_DEBUG
// fprintf(stderr ,"SERVER SEND Option Replay: %s\n", r);
#endif
return ERR_NOERROR;
}
开发者ID:michalliu,项目名称:rtspserver,代码行数:16,代码来源:rtspservice.c
示例6: ext2fs_sbupdate
/*
* Write a superblock and associated information back to disk.
*/
int
ext2fs_sbupdate(struct ufsmount *mp, int waitfor)
{
struct m_ext2fs *fs = mp->um_e2fs;
struct buf *bp;
int error = 0;
bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0);
e2fs_sbsave(&fs->e2fs, (struct ext2fs *) bp->b_data);
if (waitfor == MNT_WAIT)
error = bwrite(bp);
else
bawrite(bp);
return (error);
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:18,代码来源:ext2fs_vfsops.c
示例7: init_Boot_Block
static void
init_Boot_Block (void)
/*
* Since there isn't any BootBlock yet, simply clear the contents
* of the first block on disc.
*/
{
struct buf *bp;
bp = getblk(filedrive,0,1,NOSAVE);
clr_buf (bp);
bwrite(bp->b_tbp);
}
开发者ID:jamjr,项目名称:Helios-NG,代码行数:15,代码来源:deal_fs.c
示例8: putino
int
putino(struct uufsd *disk)
{
struct fs *fs;
fs = &disk->d_fs;
if (disk->d_inoblock == NULL) {
ERROR(disk, "No inode block allocated");
return (-1);
}
if (bwrite(disk, fsbtodb(fs, ino_to_fsba(&disk->d_fs, disk->d_inomin)),
disk->d_inoblock, disk->d_fs.fs_bsize) <= 0)
return (-1);
return (0);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:15,代码来源:inode.c
示例9: msdosfs_updatede
static int
msdosfs_updatede(struct denode *dep)
{
struct buf *bp;
struct direntry *dirp;
int error;
dep->de_flag &= ~DE_MODIFIED;
error = readde(dep, &bp, &dirp);
if (error)
return error;
DE_EXTERNALIZE(dirp, dep);
error = bwrite(bp);
return error;
}
开发者ID:lwhsu,项目名称:freebsd-makefs,代码行数:15,代码来源:msdosfs_vnops.c
示例10: move_generic_block
/* block moving */
static unsigned long move_generic_block(unsigned long block, unsigned long bnd, int h)
{
struct buffer_head * bh, * bh2;
/* primitive fsck */
if (block > rs_block_count(rs)) {
fprintf(stderr, "resize_reiserfs: invalid block number (%lu) found.\n", block);
quit_resizer();
}
/* progress bar, 3D style :) */
if (opt_verbose)
print_how_far(&total_node_cnt, blocks_used, 1, 0);
else
total_node_cnt ++;
/* infinite loop check */
if( total_node_cnt > blocks_used && !block_count_mismatch) {
fputs("resize_reiserfs: warning: block count exeeded\n",stderr);
block_count_mismatch = 1;
}
if (block < bnd) /* block will not be moved */
return 0;
/* move wrong block */
bh = bread(fs->s_dev, block, fs->s_blocksize);
reiserfs_bitmap_find_zero_bit(bmp, &unused_block);
if (unused_block == 0 || unused_block >= bnd) {
fputs ("resize_reiserfs: can\'t find free block\n", stderr);
quit_resizer();
}
/* blocknr changing */
bh2 = getblk(fs->s_dev, unused_block, fs->s_blocksize);
memcpy(bh2->b_data, bh->b_data, bh2->b_size);
reiserfs_bitmap_clear_bit(bmp, block);
reiserfs_bitmap_set_bit(bmp, unused_block);
brelse(bh);
mark_buffer_uptodate(bh2,1);
mark_buffer_dirty(bh2);
bwrite(bh2);
brelse(bh2);
total_moved_cnt++;
return unused_block;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:49,代码来源:do_shrink.c
示例11: send_play_reply
int send_play_reply(RTSP_buffer * pRtsp, RTSP_session * pRtspSessn)
{
char s8Str[1024];
char s8Temp[30];
sprintf(s8Str, "%s %d %s"RTSP_EL"CSeq: %d"RTSP_EL"Server: %s/%s"RTSP_EL, RTSP_VER, 200,\
get_stat(200), pRtsp->rtsp_cseq, PACKAGE, VERSION);
add_time_stamp(s8Str, 0);
sprintf(s8Temp, "Session: %d"RTSP_EL, pRtspSessn->session_id);
strcat(s8Str, s8Temp);
strcat(s8Str, RTSP_EL);
bwrite(s8Str, (unsigned short) strlen(s8Str), pRtsp);
return ERR_NOERROR;
}
开发者ID:michalliu,项目名称:rtspserver,代码行数:16,代码来源:rtspservice.c
示例12: ext2fs_sbupdate
/*
* Write a superblock and associated information back to disk.
*/
int
ext2fs_sbupdate(struct ufsmount *mp, int waitfor)
{
printf("In file: %s, fun: %s,lineno: %d\n",__FILE__, __func__, __LINE__);
struct m_ext2fs *fs = mp->um_e2fs;
struct buf *bp;
int error = 0;
bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0);
e2fs_sbsave(&fs->e2fs, (struct ext2fs*)bp->b_data);
if (waitfor == MNT_WAIT)
error = bwrite(bp);
else
bawrite(bp);
return (error);
}
开发者ID:zoulasc,项目名称:ext2fs,代码行数:19,代码来源:ext2fs_vfsops.c
示例13: clr_imap_bit
static int clr_imap_bit( struct d_block_table_entry *bt, struct m_inode *inode )
{
int imap_nr = bt->start_imap_nr;
int off = inode->inode_num - bt->first_inode_num;
if( inode->inode_num < bt->free_inode_num )
bt->free_inode_num = inode->inode_num;
int block = off / SECTOR_SIZE;
struct buffer_head *bh = bread( bt->dev, imap_nr + block, 0 );
int i = off / 32;
int j = off % 32;
u32 *tmp = (u32 *)(bh->pdata);
tmp = tmp + i;
*tmp = *tmp & ~(1<<j);
bwrite( bh );
return 1;
}
开发者ID:qpig,项目名称:sfs,代码行数:16,代码来源:inode.c
示例14: set_imap_first_zero
static int set_imap_first_zero( struct d_block_table_entry *bt, struct m_inode *inode )
{
int imap_nr = bt->start_imap_nr ;
int free_block = (bt->free_inode_num - bt->first_inode_num )/SECTOR_SIZE ;
int i,j,inode_nr;
struct buffer_head *bh ;
for( ; free_block < bt->inode_count/SECTOR_SIZE +1; free_block++ )
{
bh = bread( bt->dev, imap_nr + free_block, 0 );
u32 *tmp = (u32 *)(bh->pdata);
for( i=0; i<SECTOR_SIZE/32; i++,tmp++ )
{
if( *tmp != 0xffffffff )
{
for( j=0; j<32; j++ )
if( (~(*tmp) & (1<<j)) != 0 )
break;
inode_nr = bt->free_inode_num + free_block *512 + i * 32 + j;
if( j > bt->free_inode_num + bt->inode_count )
{
printk("inode is used up!\n");
return 0;
}
*tmp = *tmp | 1 << j;
bwrite( bh );
bt->free_inode_num = inode_nr + 1;
inode->dev = bt->dev;
inode->size = bt->block_size;
inode->inode_num = inode_nr;
inode->start_data_sect = bt->start_data_nr + (inode_nr - bt->first_inode_num) * bt->block_size;
inode->start_itable_sect = bt->start_itable_nr + (inode_nr - bt->first_inode_num)/8;
inode->start_imap_sect = bt->start_imap_nr + (inode_nr - bt->first_inode_num)/SECTOR_SIZE;
inode->zone_first_inode_num = bt->first_inode_num;
inode->next_inode_id = 0;
inode->nlinks = 1;
inode->update = 1;
inode->dirt = 0;
return inode_nr;
}
}
brelse( bh );
}
return 0;
}
开发者ID:qpig,项目名称:sfs,代码行数:47,代码来源:inode.c
示例15: iupdate
// Copy inode, which has changed, from memory to disk.
void
iupdate(struct inode *ip)
{
struct buf *bp;
struct dinode *dip;
bp = bread(ip->dev, IBLOCK(ip->inum));
dip = (struct dinode*)bp->data + ip->inum%IPB;
dip->type = ip->type;
dip->major = ip->major;
dip->minor = ip->minor;
dip->nlink = ip->nlink;
dip->size = ip->size;
memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
bwrite(bp);
brelse(bp);
}
开发者ID:guneetsinghmehta,项目名称:CS537_OS,代码行数:18,代码来源:fs.c
示例16: bfree
int bfree(int bno) //释放磁盘块
{
if(super->nextFreeBlock==BLOCKNUM)
{
bwrite(&super->freeBlock,bno,0,sizeof(unsigned int),BLOCKNUM);
super->nextFreeBlock=1;
super->freeBlock[0]=bno;
}
else
{
super->freeBlock[super->nextFreeBlock]=bno;
super->nextFreeBlock++;
}
super->freeBlockNum++;
write_super();
return 1;
}
开发者ID:KING1301,项目名称:linux-experiment,代码行数:17,代码来源:vm.cpp
示例17: v7_update
/*
****************************************************************
* Atualiza um Super Bloco V7 *
****************************************************************
*/
void
v7_update (const SB *sp)
{
V7SB *v7sp = sp->sb_ptr;
BHEAD *bp;
/*
* Tenta trancar as listas Livres
*/
if (SLEEPTEST (&v7sp->s_ilock) < 0)
return;
if (SLEEPTEST (&v7sp->s_flock) < 0)
{ SLEEPFREE (&v7sp->s_ilock); return; }
/*
* Prepara para escrever o SB no Disco
*/
bp = bread (sp->sb_dev, V7_SBNO, 0);
*(time_t *)v7sp->s_time = time;
memmove (bp->b_addr, v7sp, sizeof (V7SB));
#ifdef LITTLE_ENDIAN
/*
* Se for o caso, converte, ...
*/
v7_sb_endian_conversion ((V7SB *)bp->b_addr);
#endif LITTLE_ENDIAN
/*
* Escreve o SB no Disco
*/
bwrite (bp);
#ifdef MSG
if (CSWT (6))
printf ("%g: SB, dev = %v\n", sp->sb_dev);
#endif MSG
SLEEPFREE (&v7sp->s_flock);
SLEEPFREE (&v7sp->s_ilock);
} /* end v7_update */
开发者ID:marioaugustorama,项目名称:tropix-kernel,代码行数:50,代码来源:v7mount.c
示例18: write_head
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void write_head(void)
{
struct buf *buf;
struct logheader *hb;
int i;
buf = bread(log.dev, log.start);
hb = (struct logheader *) (buf->data);
hb->n = log.lh.n;
for (i = 0; i < log.lh.n; i++) {
hb->sector[i] = log.lh.sector[i];
}
bwrite(buf);
brelse(buf);
}
开发者ID:JackieXie168,项目名称:xv6-rpi,代码行数:21,代码来源:log.c
示例19: ext2fs_update
/*
* Update the access, modified, and inode change times as specified by the
* IACCESS, IUPDATE, and ICHANGE flags respectively. The IMODIFIED flag is
* used to specify that the inode needs to be updated but that the times have
* already been set. The access and modified times are taken from the second
* and third parameters; the inode change time is always taken from the current
* time. If waitfor is set, then wait for the disk write of the inode to
* complete.
*/
int
ext2fs_update(struct inode *ip, int waitfor)
{
struct m_ext2fs *fs;
struct buf *bp;
int error;
caddr_t cp;
if (ITOV(ip)->v_mount->mnt_flag & MNT_RDONLY)
return (0);
EXT2FS_ITIMES(ip);
if ((ip->i_flag & IN_MODIFIED) == 0)
return (0);
ip->i_flag &= ~IN_MODIFIED;
fs = ip->i_e2fs;
error = bread(ip->i_devvp,
fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
(int)fs->e2fs_bsize, &bp);
if (error) {
brelse(bp);
return (error);
}
ip->i_flag &= ~(IN_MODIFIED);
cp = (caddr_t)bp->b_data +
(ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
/*
* See note about 16-bit UID/GID limitation in ext2fs_vget(). Now
* that we are about to write the inode, construct the split UID and
* GID fields out of the two 32-bit fields we kept in memory.
*/
ip->i_e2fs_uid_low = (u_int16_t)ip->i_e2fs_uid;
ip->i_e2fs_gid_low = (u_int16_t)ip->i_e2fs_gid;
ip->i_e2fs_uid_high = ip->i_e2fs_uid >> 16;
ip->i_e2fs_gid_high = ip->i_e2fs_gid >> 16;
e2fs_isave(fs, ip->i_e2din, (struct ext2fs_dinode *)cp);
if (waitfor)
return (bwrite(bp));
else {
bdwrite(bp);
return (0);
}
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:53,代码来源:ext2fs_inode.c
示例20: deupdat
int
deupdat(struct denode *dep, int waitfor)
{
struct direntry dir;
struct timespec ts;
struct buf *bp;
struct direntry *dirp;
int error;
if (DETOV(dep)->v_mount->mnt_flag & MNT_RDONLY) {
dep->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS |
DE_MODIFIED);
return (0);
}
getnanotime(&ts);
DETIMES(dep, &ts, &ts, &ts);
if ((dep->de_flag & DE_MODIFIED) == 0 && waitfor == 0)
return (0);
dep->de_flag &= ~DE_MODIFIED;
if (DETOV(dep)->v_vflag & VV_ROOT)
return (EINVAL);
if (dep->de_refcnt <= 0)
return (0);
error = readde(dep, &bp, &dirp);
if (error)
return (error);
DE_EXTERNALIZE(&dir, dep);
if (bcmp(dirp, &dir, sizeof(dir)) == 0) {
if (waitfor == 0 || (bp->b_flags & B_DELWRI) == 0) {
brelse(bp);
return (0);
}
} else
*dirp = dir;
if ((DETOV(dep)->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0)
bp->b_flags |= B_CLUSTEROK;
if (waitfor)
error = bwrite(bp);
else if (vm_page_count_severe() || buf_dirty_count_severe())
bawrite(bp);
else
bdwrite(bp);
return (error);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:44,代码来源:msdosfs_denode.c
注:本文中的bwrite函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论