kern

diff src/bdev.c @ 98:921a264297a4

merged the filesystem stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Apr 2014 17:03:30 +0300
parents f83f50c17c3b
children
line diff
     1.1 --- a/src/bdev.c	Thu Apr 17 12:30:02 2014 +0300
     1.2 +++ b/src/bdev.c	Thu Apr 17 17:03:30 2014 +0300
     1.3 @@ -40,11 +40,13 @@
     1.4  
     1.5  		bdev->offset = SECT_TO_BLK(plist->start_sect);
     1.6  		bdev->size = SECT_TO_BLK(plist->size_sect);
     1.7 +		bdev->ptype = get_part_type(plist);
     1.8  
     1.9  		free_part_list(plist);
    1.10  	} else {
    1.11  		bdev->offset = 0;
    1.12  		bdev->size = SECT_TO_BLK(ata_num_sectors(devno));
    1.13 +		bdev->ptype = 0;
    1.14  	}
    1.15  
    1.16  	return bdev;
    1.17 @@ -57,13 +59,13 @@
    1.18  
    1.19  #define NSECT	(BLKSZ / 512)
    1.20  
    1.21 -int blk_read(struct block_device *bdev, uint32_t blk, void *buf)
    1.22 +int blk_read(struct block_device *bdev, uint32_t blk, int count, void *buf)
    1.23  {
    1.24  	int i;
    1.25  	char *ptr = buf;
    1.26 -	uint32_t sect = blk * NSECT;
    1.27 +	uint32_t sect = blk * NSECT + bdev->offset;
    1.28  
    1.29 -	for(i=0; i<NSECT; i++) {
    1.30 +	for(i=0; i<NSECT * count; i++) {
    1.31  		if(ata_read_pio(bdev->ata_dev, sect++, ptr) == -1) {
    1.32  			return -1;
    1.33  		}
    1.34 @@ -72,13 +74,13 @@
    1.35  	return 0;
    1.36  }
    1.37  
    1.38 -int blk_write(struct block_device *bdev, uint32_t blk, void *buf)
    1.39 +int blk_write(struct block_device *bdev, uint32_t blk, int count, void *buf)
    1.40  {
    1.41  	int i;
    1.42  	char *ptr = buf;
    1.43 -	uint32_t sect = blk * NSECT;
    1.44 +	uint32_t sect = blk * NSECT + bdev->offset;
    1.45  
    1.46 -	for(i=0; i<NSECT; i++) {
    1.47 +	for(i=0; i<NSECT * count; i++) {
    1.48  		if(ata_write_pio(bdev->ata_dev, sect++, ptr) == -1) {
    1.49  			return -1;
    1.50  		}
    1.51 @@ -116,5 +118,5 @@
    1.52  	}
    1.53  
    1.54  	minor = MKMINOR(atadev, part);
    1.55 -	return DEVNO(0, minor);
    1.56 +	return DEVNO(1, minor);
    1.57  }