diff options
author | Liu Aleaxander <Aleaxander@gmail.com> | 2009-05-11 16:47:51 +0800 |
---|---|---|
committer | Liu Aleaxander <Aleaxander@gmail.com> | 2009-05-11 16:47:51 +0800 |
commit | 0d701f8a814792f5db473d417648c2e5a9f6a20c (patch) | |
tree | a6ef6f1800fe043aa9a812714b5b7fb01946ba13 /disklab.c | |
parent | dcc79fb69015fd7aed1db14544b155969f4d1783 (diff) | |
download | devel-0d701f8a814792f5db473d417648c2e5a9f6a20c.tar.gz devel-0d701f8a814792f5db473d417648c2e5a9f6a20c.tar.xz devel-0d701f8a814792f5db473d417648c2e5a9f6a20c.zip |
Make cache based on block size and fixed some bugs
well, it's a big change.
1st, make the caceh based on block but not sector
2nd, make the fast symlink check worked.
3rd, totally changed the linsector function.
4th, some little changes.
Diffstat (limited to 'disklab.c')
-rw-r--r-- | disklab.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1,27 +1,29 @@ +#include "disklab.h" + #include <stdio.h> #include <malloc.h> + extern int fd; +extern int blk_size; -void * getonesec(int sector) +void* getoneblk(__u32 block) { - void *data; int bytes_read; + char *buf; - if ( lseek(fd, sector * 512, SEEK_SET) < 0) {/* ... */ + if ( lseek(fd, block * blk_size, SEEK_SET) < 0) {/* ... */ printf("seek file ext2.img error....\n"); return NULL; } + buf = malloc(blk_size); - data = malloc(512); - - if ( (bytes_read = read(fd, data, 512)) < 512 ) - printf("read %d bytes less than 512B...\n", bytes_read); - + if ( (bytes_read = read(fd, buf, blk_size)) < blk_size ) + printf("read %d bytes less than %dB..\n", bytes_read, blk_size); - return data; + return buf; } |