Ejemplo n.º 1
0
Archivo: file.c Proyecto: vener91/cs537
// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
	uchar cksum;
	struct buf *bp;
	int i;
	
  if(f->type == FD_INODE){
    ilock(f->ip);
    stati(f->ip, st);
	cksum = getcksum(f->ip->addrs[0]);
  	for(i = 1; i < NDIRECT; i++){
		cksum =  cksum ^ getcksum(f->ip->addrs[i]);
	}
	bp = bread(f->ip->dev, getptr(f->ip->addrs[NDIRECT]));
	uint *a;
	a = (uint*)bp->data;
	for(i = 0; i < 512/sizeof(uint); i++){
		cksum = cksum ^ getcksum(a[i]);	
	}

	st->checksum = cksum;
    iunlock(f->ip);
    return 0;
  }
  return -1;
}
Ejemplo n.º 2
0
Archivo: file.c Proyecto: tmfahey/cs537
// Get metadata about file f.
int
filestat(struct file *f, struct stat *st)
{
  if(f->type == FD_INODE){
    ilock(f->ip);
    stati(f->ip, st);
    iunlock(f->ip);
    return 0;
  }
  return -1;
}