aboutsummaryrefslogtreecommitdiffstats
path: root/disklab.c
blob: eebc5f41349861db1b57bf317faef4326b53b84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "disklab.h"

#include <stdio.h>


extern int fd;

void getlinsec(char *buf, int sector, int sector_cnt)
{
        int bytes_read;

        if ( lseek(fd, sector*512, SEEK_SET) < 0 ) {
                printf("seek file fs image error ....\n");
                return;
        }

        if ( (bytes_read = read(fd, buf, 512*sector_cnt)) < 512*sector_cnt) 
                printf("%s:%s: read %d bytes less than %d bytes..\n", 
                       __FILE__, __FUNCTION__, bytes_read, 512 * sector_cnt);
        
}


void getoneblk(char *buf, __u32 block, int block_size)
{
        int sec_per_block = block_size / 512; /* 512==sector size */
        
        getlinsec(buf, block*sec_per_block, sec_per_block);
}