Esempio n. 1
0
File: bio.c Progetto: eryjus/century
//-------------------------------------------------------------------------------------------------------------------
// bwrite() -- Write b's contents to disk.  Must be B_BUSY.
//-------------------------------------------------------------------------------------------------------------------
void bwrite(struct buf *b)
{
    if ((b->flags & B_BUSY) == 0) panic("bwrite");

    b->flags |= B_DIRTY;
    iderw(b);
}
Esempio n. 2
0
File: bio.c Progetto: lxmonk/OS122-4
// Return a B_BUSY buf with the contents of the indicated disk sector.
struct buf*
bread(uint dev, uint sector)
{
  struct buf *b;

  b = bget(dev, sector);
  if(!(b->flags & B_VALID))
    iderw(b);
  return b;
}
Esempio n. 3
0
// Return a B_BUSY buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
  struct buf *b;

  b = bget(dev, blockno);
  if(!(b->flags & B_VALID)) {
    iderw(b);
  }
  return b;
}
Esempio n. 4
0
File: bio.c Progetto: zbh24/tinyfs
// Return a B_BUSY buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
  struct buf *b;
  //回收回来的要么是一个已经存在的,但可能是dirty的数据。也有可能是个什么都没有的。
  //0和dirty是不一样的。dirty是写回去,0是直接从硬盘里面读数据的。
  b = bget(dev, blockno);
  if(!(b->flags & B_VALID)) {
    iderw(b);
  }
  return b;
}
Esempio n. 5
0
int main() 
{
	char tmp[512] = "abcd";
	struct buf *b;
	b = (struct buf *)malloc(sizeof(struct buf));
	memmove(b->data,tmp,512);

	b->dev = 1;
	b->blockno = 1;
	b->flags = 0;
	iderw(b);
	printf("The is %s\n",b->data);
	return 0;

	//Test the write [0,0] abcd
	b->dev = 0;
	b->blockno = 0;
	b->flags = B_DIRTY;
	iderw(b);

	//Test the write [0,1] abcd
	b->flags = B_DIRTY;
	b->blockno = 1;
	iderw(b);
	idedump(0,0);
	idedump(0,1);
	memset(b->data,'z',512);
	printf("The buf b is %s:\n",b->data);
	//这种情况下,lseek会失败的。
	//b->blockno = 2;
	iderw(b);
	printf("The [0,1] is %s:\n",b->data);

	b->flags = B_DIRTY;
	memset(b->data,'a',512);
	b->blockno = 0;
	iderw(b);
	idedump(0,0);
	idedump(0,1);

	printf("-------------------------\n");
	idedump(0,3);
	b->blockno = 3;
	iderw(b);
	printf("The buf b is %s:\n",b->data);
	// lseek if beyond the len of file,lseek is success,but will read the 0 data.

}
Esempio n. 6
0
File: bio.c Progetto: zbh24/tinyfs
// Write b's contents to disk.  Must be B_BUSY.
void
bwrite(struct buf *b)
{
  b->flags |= B_DIRTY;
  iderw(b);
}