aboutsummaryrefslogtreecommitdiffstats
path: root/disklab.c
diff options
context:
space:
mode:
Diffstat (limited to 'disklab.c')
-rw-r--r--disklab.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/disklab.c b/disklab.c
index a3abe36..c0673ef 100644
--- a/disklab.c
+++ b/disklab.c
@@ -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;
}