本文整理汇总了C++中readsb函数的典型用法代码示例。如果您正苦于以下问题:C++ readsb函数的具体用法?C++ readsb怎么用?C++ readsb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readsb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ialloc
//PAGEBREAK!
// Allocate a new inode with the given type on device dev.
// A free inode has a type of zero.
struct inode*
ialloc(uint dev, short type)
{
int inum;
struct buf *bp;
struct dinode *dip;
struct superblock sb;
readsb(dev, &sb);
for(inum = 1; inum < sb.ninodes; inum++){
bp = bread(dev, IBLOCK(inum));
dip = (struct dinode*)bp->data + inum%IPB;
if(dip->type == 0){ // a free inode
memset(dip, 0, sizeof(*dip));
dip->type = type;
log_write(bp); // mark it allocated on the disk
brelse(bp);
return iget(dev, inum);
}
brelse(bp);
}
panic("ialloc: no inodes");
return 0;
}
开发者ID:Lulkafe,项目名称:xv6_rpi_port,代码行数:28,代码来源:fs.c
示例2: balloc
// Allocate a disk block.
static uint
balloc(uint dev)
{
int b, bi, m, bound;
struct buf *bp;
struct superblock sb;
bp = 0;
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
bp = bread(dev, BBLOCK(b, sb.ninodes));
if(b+BPB > sb.size){ //last bitmap block
bound = sb.size % BPB;
} else {
bound = BPB;
}
for(bi = 0; bi < bound; bi++){
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0){ // Is block free?
bp->data[bi/8] |= m; // Mark block in use on disk.
bwrite(bp);
brelse(bp);
return b + bi;
}
}
brelse(bp);
}
//panic("balloc: out of blocks");
return 0;
}
开发者ID:cquagliana,项目名称:something_short,代码行数:34,代码来源:fs.c
示例3: log_balloc
static uint
log_balloc(uint dev)
{
int b, bi, m, i;
struct superblock sb;
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
for(i = 0; i < b_index; i++)
if(bp[i]->sector == BBLOCK(b, sb.ninodes)) {
for(bi = 0; bi < BPB; bi++){
m = 1 << (bi % 8);
if((bp[i]->data[bi/8] & m) == 0){
bp[i]->data[bi/8] |= m;
return b + bi;
}
}
}
bp[b_index] = bread(dev, BBLOCK(b, sb.ninodes));
for(bi = 0; bi < BPB; bi++){
m = 1 << (bi % 8);
if((bp[b_index]->data[bi/8] & m) == 0){
bp[b_index]->data[bi/8] |= m;
b_index++;
return b + bi;
}
}
brelse(bp[b_index]);
}
panic("balloc: out of blocks");
}
开发者ID:fenster,项目名称:xv6-staus-treffert,代码行数:32,代码来源:logfs.c
示例4: balloc
// Allocate a zeroed disk block.
static uint
balloc(uint dev)
{
int b, bi, m;
struct buf *bp;
struct superblock sb;
bp = 0;
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
bp = bread(dev, BBLOCK(b, sb.ninodes));
for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0){ // Is block free?
bp->data[bi/8] |= m; // Mark block in use.
log_write(bp);
brelse(bp);
bzero(dev, b + bi);
return b + bi;
}
}
brelse(bp);
}
panic("balloc: out of blocks");
}
开发者ID:lxmonk,项目名称:OS122-3,代码行数:26,代码来源:fs.c
示例5: balloc
// Allocate a disk block.
static uint
balloc(uint dev)
{
int b, bi, m, bound;
struct buf *bp;
struct superblock sb;
bp = 0;
readsb(dev, &sb); // read superblock into sb
for(b = 0; b < sb.size; b += BPB){ // loop through all available blocks
// Return a B_BUSY buf with the contents of the indicated disk sector.
bp = bread(dev, BBLOCK(b, sb.ninodes)); // get inode bitmap
if(b+BPB > sb.size){ //last bitmap block
bound = sb.size % BPB;
} else {
bound = BPB;
}
for(bi = 0; bi < bound; bi++){ // loop through all inode bitmap
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0){ // Is block free?
bp->data[bi/8] |= m; // Mark block in use on disk.
bwrite(bp);
brelse(bp);
return b + bi;
}
}
brelse(bp);
}
//panic("balloc: out of blocks");
return 0;
}
开发者ID:squallee,项目名称:CS537,代码行数:35,代码来源:fs.c
示例6: nand_read_buf
static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
{
struct nand_chip *chip = mtd->priv;
readsl(chip->IO_ADDR_R, buf, (len >> 2));
if (len & 3)
readsb(chip->IO_ADDR_R, buf + (len & ~0x3), (len & 3));
}
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:7,代码来源:nand.c
示例7: changePartition
void
changePartition(int partition){ //TODO: CHECK!
currentPartition = partition;
superBlockOffset = mbr.partitions[partition].offset; //???
cprintf("off:%d\n",mbr.partitions[partition].offset);
readsb(ROOTDEV, &sb); //???
}
开发者ID:galbenor,项目名称:os162-4,代码行数:8,代码来源:fs.c
示例8: iinit
void
iinit(int dev)
{
initlock(&icache.lock, "icache");
readsb(dev, &sb);
cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n", sb.size,
sb.nblocks, sb.ninodes, sb.nlog, sb.logstart, sb.inodestart, sb.bmapstart);
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:8,代码来源:fs.c
示例9: cadence_qspi_apb_indirect_read_execute
int cadence_qspi_apb_indirect_read_execute(struct cadence_spi_platdata *plat,
unsigned int n_rx, u8 *rxbuf)
{
unsigned int remaining = n_rx;
unsigned int bytes_to_read = 0;
int ret;
writel(n_rx, plat->regbase + CQSPI_REG_INDIRECTRDBYTES);
/* Start the indirect read transfer */
writel(CQSPI_REG_INDIRECTRD_START,
plat->regbase + CQSPI_REG_INDIRECTRD);
while (remaining > 0) {
ret = cadence_qspi_wait_for_data(plat);
if (ret < 0) {
printf("Indirect write timed out (%i)\n", ret);
goto failrd;
}
bytes_to_read = ret;
while (bytes_to_read != 0) {
bytes_to_read *= CQSPI_FIFO_WIDTH;
bytes_to_read = bytes_to_read > remaining ?
remaining : bytes_to_read;
/* Handle non-4-byte aligned access to avoid data abort. */
if (((uintptr_t)rxbuf % 4) || (bytes_to_read % 4))
readsb(plat->ahbbase, rxbuf, bytes_to_read);
else
readsl(plat->ahbbase, rxbuf, bytes_to_read >> 2);
rxbuf += bytes_to_read;
remaining -= bytes_to_read;
bytes_to_read = cadence_qspi_get_rd_sram_level(plat);
}
}
/* Check indirect done status */
ret = wait_for_bit("QSPI", plat->regbase + CQSPI_REG_INDIRECTRD,
CQSPI_REG_INDIRECTRD_DONE, 1, 10, 0);
if (ret) {
printf("Indirect read completion error (%i)\n", ret);
goto failrd;
}
/* Clear indirect completion status */
writel(CQSPI_REG_INDIRECTRD_DONE,
plat->regbase + CQSPI_REG_INDIRECTRD);
return 0;
failrd:
/* Cancel the indirect read */
writel(CQSPI_REG_INDIRECTRD_CANCEL,
plat->regbase + CQSPI_REG_INDIRECTRD);
return ret;
}
开发者ID:wowotechX,项目名称:u-boot,代码行数:57,代码来源:cadence_qspi_apb.c
示例10: s3c2410_udc_read_packet
static inline int s3c2410_udc_read_packet(int fifo, u8 *buf,
struct s3c2410_request *req, unsigned avail)
{
unsigned len;
len = min(req->req.length - req->req.actual, avail);
req->req.actual += len;
readsb(fifo + base_addr, buf, len);
return len;
}
开发者ID:realmz,项目名称:blackfin-linux,代码行数:11,代码来源:s3c2410_udc.c
示例11: initlog
void
initlog(void)
{
if (sizeof(struct logheader) >= BSIZE)
panic("initlog: too big logheader");
struct superblock sb;
initlock(&log.lock, "log");
readsb(ROOTDEV, &sb);
log.start = sb.size - sb.nlog;
log.size = sb.nlog;
log.dev = ROOTDEV;
recover_from_log();
}
开发者ID:joaobatalha,项目名称:zv6,代码行数:14,代码来源:log.c
示例12: initlog
void
initlog(int dev)
{
if (sizeof(struct logheader) >= BSIZE)
panic("initlog: too big logheader");
struct superblock sb;
initlock(&log.lock, "log");
readsb(dev, &sb);
log.start = sb.logstart;
log.size = sb.nlog;
log.dev = dev;
recover_from_log();
}
开发者ID:jlledom,项目名称:MIT_6.828-xv6,代码行数:14,代码来源:log.c
示例13: bfree
// Free a disk block.
static void
bfree(int dev, uint b)
{
struct buf *bp;
int bi, m;
readsb(dev, &sb);
bp = bread(dev, BBLOCK(b, sb));
bi = b % BPB;
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0)
panic("freeing free block");
bp->data[bi/8] &= ~m;
log_write(bp);
brelse(bp);
}
开发者ID:gaohannk,项目名称:xv6-system,代码行数:17,代码来源:fs.c
示例14: bfree
// Free a disk block.
static void
bfree(int dev, uint b)
{
struct buf *bp;
struct superblock sb;
int bi, m;
bzero(dev, b);
readsb(dev, &sb);
bp = bread(dev, BBLOCK(b, sb.ninodes));
bi = b % BPB;
m = 1 << (bi % 8);
if((bp->data[bi/8] & m) == 0)
panic("freeing free block");
bp->data[bi/8] &= ~m; // Mark block free on disk.
bwrite(bp);
brelse(bp);
}
开发者ID:guneetsinghmehta,项目名称:CS537_OS,代码行数:20,代码来源:fs.c
示例15: iinit
int iinit(struct proc* p, int dev)
{
struct inode* rootNode;
struct superblock sb;
// TODO: change ot iterate over all partitions
cprintf("kernal by Asaf and Ilana \n");
initlock(&icache.lock, "icache");
rootNode = p->cwd;
// acquire(&icache.lock);
initMbr(dev);
printMBR(&mbrI);
cprintf("booting from %d \n", bootfrom);
if (bootfrom == -1) {
panic("no bootable partition");
}
rootNode->part = &(partitions[bootfrom]);
int i;
for (i = 0; i < NPARTITIONS; i++) {
readsb(dev, i);
sb = sbs[i];
cprintf("sb: offset %d size %d nblocks %d ninodes %d nlog %d logstart %d inodestart %d bmap start %d\n",
sb.offset,
sb.size,
sb.nblocks,
sb.ninodes,
sb.nlog,
sb.logstart,
sb.inodestart,
sb.bmapstart);
}
// set root inode
// release(&icache.lock);
// cprintf("root node init %d \n",rootNode->part->offset);
return bootfrom;
}
开发者ID:asafbennatan,项目名称:xv6-public,代码行数:41,代码来源:fs.c
示例16: s3c2410_udc_read_fifo_crq
static int s3c2410_udc_read_fifo_crq(struct usb_ctrlrequest *crq)
{
unsigned char *outbuf = (unsigned char *)crq;
int bytes_read = 0;
udc_write(0, S3C2410_UDC_INDEX_REG);
bytes_read = s3c2410_udc_fifo_count_out();
dprintk(DEBUG_NORMAL, "%s: fifo_count=%d\n", __func__, bytes_read);
if (bytes_read > sizeof(struct usb_ctrlrequest))
bytes_read = sizeof(struct usb_ctrlrequest);
readsb(S3C2410_UDC_EP0_FIFO_REG + base_addr, outbuf, bytes_read);
dprintk(DEBUG_VERBOSE, "%s: len=%d %02x:%02x {%x,%x,%x}\n", __func__,
bytes_read, crq->bRequest, crq->bRequestType,
crq->wValue, crq->wIndex, crq->wLength);
return bytes_read;
}
开发者ID:realmz,项目名称:blackfin-linux,代码行数:22,代码来源:s3c2410_udc.c
示例17: j_balloc
// Allocate a disk block.
static uint
j_balloc(uint dev)
{
int b, bi, m, i;
//struct buf *bp;
struct superblock sb;
// bp = 0;
readsb(dev, &sb);
for(b = 0; b < sb.size; b += BPB){
/* check in dirty blocks */
for(i = 0; i < b_index; i++)
if(bp[i]->sector == BBLOCK(b, sb.ninodes)) {
for(bi = 0; bi < BPB; bi++){
m = 1 << (bi % 8);
if((bp[i]->data[bi/8] & m) == 0){ // Is block free?
bp[i]->data[bi/8] |= m; // Mark block in use on disk.
return b + bi;
}
}
}
/* load new block out of mem */
bp[b_index] = bread(dev, BBLOCK(b, sb.ninodes));
for(bi = 0; bi < BPB; bi++){
m = 1 << (bi % 8);
if((bp[b_index]->data[bi/8] & m) == 0){ // Is block free?
bp[b_index]->data[bi/8] |= m; // Mark block in use on disk.
/* keep dirty around, move index to next*/
b_index++;
return b + bi;
}
}
// panic("eh");
brelse(bp[b_index]);
}
panic("balloc: out of blocks");
}
开发者ID:alangenfeld,项目名称:xv6,代码行数:38,代码来源:journal.c
示例18: setup
int
setup(const char *dev)
{
long cg, asked, i;
long bmapsize;
struct disklabel *lp;
off_t sizepb;
struct stat statb;
struct m_ext2fs proto;
int doskipclean;
u_int64_t maxfilesize;
havesb = 0;
fswritefd = -1;
doskipclean = skipclean;
if (stat(dev, &statb) < 0) {
printf("Can't stat %s: %s\n", dev, strerror(errno));
return 0;
}
if (!S_ISCHR(statb.st_mode)) {
pfatal("%s is not a character device", dev);
if (reply("CONTINUE") == 0)
return 0;
}
if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
printf("Can't open %s: %s\n", dev, strerror(errno));
return 0;
}
if (preen == 0)
printf("** %s", dev);
if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
printf(" (NO WRITE)");
}
if (preen == 0)
printf("\n");
fsmodified = 0;
lfdir = 0;
initbarea(&sblk);
initbarea(&asblk);
sblk.b_un.b_buf = malloc(SBSIZE);
asblk.b_un.b_buf = malloc(SBSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errexit("cannot allocate space for superblock");
if ((lp = getdisklabel(NULL, fsreadfd)) != NULL)
dev_bsize = secsize = lp->d_secsize;
else
dev_bsize = secsize = DEV_BSIZE;
/*
* Read in the superblock, looking for alternates if necessary
*/
if (readsb(1) == 0) {
if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
return 0;
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return 0;
for (cg = 1; cg < proto.e2fs_ncg; cg++) {
bflag = EXT2_FSBTODB(&proto,
cg * proto.e2fs.e2fs_bpg +
proto.e2fs.e2fs_first_dblock);
if (readsb(0) != 0)
break;
}
if (cg >= proto.e2fs_ncg) {
printf("%s %s\n%s %s\n%s %s\n",
"SEARCH FOR ALTERNATE SUPER-BLOCK",
"FAILED. YOU MUST USE THE",
"-b OPTION TO FSCK_FFS TO SPECIFY THE",
"LOCATION OF AN ALTERNATE",
"SUPER-BLOCK TO SUPPLY NEEDED",
"INFORMATION; SEE fsck_ext2fs(8).");
return 0;
}
doskipclean = 0;
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
}
if (debug)
printf("state = %d\n", sblock.e2fs.e2fs_state);
if (sblock.e2fs.e2fs_state == E2FS_ISCLEAN) {
if (doskipclean) {
pwarn("%sile system is clean; not checking\n",
preen ? "f" : "** F");
return -1;
}
if (!preen)
pwarn("** File system is already clean\n");
}
maxfsblock = sblock.e2fs.e2fs_bcount;
maxino = sblock.e2fs_ncg * sblock.e2fs.e2fs_ipg;
sizepb = sblock.e2fs_bsize;
maxfilesize = sblock.e2fs_bsize * EXT2FS_NDADDR - 1;
for (i = 0; i < EXT2FS_NIADDR; i++) {
sizepb *= EXT2_NINDIR(&sblock);
maxfilesize += sizepb;
}
/*
* Check and potentially fix certain fields in the super block.
*/
//.........这里部分代码省略.........
开发者ID:ryo,项目名称:netbsd-src,代码行数:101,代码来源:setup.c
示例19: setup
/*
* Read in a superblock finding an alternate if necessary.
* Return 1 if successful, 0 if unsuccessful, -1 if filesystem
* is already clean (preen mode only).
*/
int
setup(char *dev)
{
long size, asked, i, j;
long skipclean, bmapsize;
off_t sizepb;
struct stat statb;
havesb = 0;
fswritefd = -1;
skipclean = fflag ? 0 : preen;
if (stat(dev, &statb) < 0) {
printf("Can't stat %s: %s\n", dev, strerror(errno));
return (0);
}
if ((statb.st_mode & S_IFMT) != S_IFCHR &&
(statb.st_mode & S_IFMT) != S_IFBLK) {
pfatal("%s is not a disk device", dev);
if (reply("CONTINUE") == 0)
return (0);
}
if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
printf("Can't open %s: %s\n", dev, strerror(errno));
return (0);
}
if (preen == 0)
printf("** %s", dev);
if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
printf(" (NO WRITE)");
}
if (preen == 0)
printf("\n");
fsmodified = 0;
lfdir = 0;
initbarea(&sblk);
initbarea(&asblk);
sblk.b_un.b_buf = malloc(SBSIZE);
asblk.b_un.b_buf = malloc(SBSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
/*
* Figure out the device block size and the sector size. The
* block size is updated by readsb() later on.
*/
{
struct partinfo pinfo;
if (ioctl(fsreadfd, DIOCGPART, &pinfo) == 0) {
dev_bsize = secsize = pinfo.media_blksize;
} else {
dev_bsize = secsize = DEV_BSIZE;
}
}
/*
* Read in the superblock, looking for alternates if necessary
*/
if (readsb(1) == 0) {
skipclean = 0;
if (bflag || preen)
return(0);
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return (0);
bflag = 32;
if (readsb(0) == 0) {
printf(
"YOU MUST USE THE -b OPTION TO FSCK TO SPECIFY\n"
"THE LOCATION OF AN ALTERNATE SUPER-BLOCK TO\n"
"SUPPLY NEEDED INFORMATION; SEE fsck(8).");
bflag = 0;
return(0);
}
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
bflag = 0;
}
if (skipclean && sblock.fs_clean) {
pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
return (-1);
}
maxfsblock = sblock.fs_size;
maxino = sblock.fs_ncg * sblock.fs_ipg;
/*
* Check and potentially fix certain fields in the super block.
*/
if (sblock.fs_optim != FS_OPTTIME && sblock.fs_optim != FS_OPTSPACE) {
pfatal("UNDEFINED OPTIMIZATION IN SUPERBLOCK");
if (reply("SET TO DEFAULT") == 1) {
sblock.fs_optim = FS_OPTTIME;
sbdirty();
}
}
//.........这里部分代码省略.........
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:101,代码来源:setup.c
示例20: setup
//.........这里部分代码省略.........
* continue, as old kernels will recompute the summary at
* mount time. However, it will be an unexpected softupdates
* inconsistency if it turns out that the summary is still
* incorrect. Set a flag so subsequent operation can know
* this.
*/
bkgrdsumadj = 1;
if (sysctlnametomib("vfs.ffs.adjndir", adjndir, &size) < 0 ||
sysctlnametomib("vfs.ffs.adjnbfree", adjnbfree, &size) < 0 ||
sysctlnametomib("vfs.ffs.adjnifree", adjnifree, &size) < 0 ||
sysctlnametomib("vfs.ffs.adjnffree", adjnffree, &size) < 0 ||
sysctlnametomib("vfs.ffs.adjnumclusters", adjnumclusters, &size) < 0) {
bkgrdsumadj = 0;
pwarn("kernel lacks runtime superblock summary adjustment support");
}
cmd.version = FFS_CMD_VERSION;
cmd.handle = fsreadfd;
fswritefd = -1;
}
if (preen == 0)
printf("** %s", dev);
if (bkgrdflag == 0 &&
(nflag || (fswritefd = open(dev, O_WRONLY)) < 0)) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
printf(" (NO WRITE)");
}
if (preen == 0)
printf("\n");
/*
* Read in the superblock, looking for alternates if necessary
*/
if (readsb(1) == 0) {
skipclean = 0;
if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
return(0);
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return (0);
for (cg = 0; cg < proto.fs_ncg; cg++) {
bflag = fsbtodb(&proto, cgsblock(&proto, cg));
if (readsb(0) != 0)
break;
}
if (cg >= proto.fs_ncg) {
printf("%s %s\n%s %s\n%s %s\n",
"SEARCH FOR ALTERNATE SUPER-BLOCK",
"FAILED. YOU MUST USE THE",
"-b OPTION TO FSCK TO SPECIFY THE",
"LOCATION OF AN ALTERNATE",
"SUPER-BLOCK TO SUPPLY NEEDED",
"INFORMATION; SEE fsck_ffs(8).");
bflag = 0;
return(0);
}
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
bflag = 0;
}
if (skipclean && ckclean && sblock.fs_clean) {
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
return (-1);
}
maxfsblock = sblock.fs_size;
maxino = sblock.fs_ncg * sblock.fs_ipg;
/*
* Check and potentially fix certain fields in the super block.
开发者ID:ornarium,项目名称:freebsd,代码行数:67,代码来源:setup.c
注:本文中的readsb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论