- 论坛徽章:
- 0
|
在 solaris 10 sparc 64 的v890 上安装了gcc
写一个小程序读一个18g 的问题, 输入的参数是没有问题的,
但是在fseek 函数中 送进去的 offset= 8192 * 1015825
好像fseek 只能到达offset = 8192 * 491537 位置
编译的时候加了 -m64 和 -D_FILE_OFFSET_BITS=64
大虾门帮忙分析下是什么问题呢??
#include "mydul.h"
int read_buffer( FILE *fp, int rdba, char *buffer)
{
unsigned int file_no, blk_no;
file_no = FILEID(rdba);
blk_no = BLOCKID(rdba) +1 ;
blk_no = 1015825 ;
if (fp == NULL)
{
printf("file is not open yet %s %d\n\n", __FILE__ , __LINE__);
perror("file *fp");
exit(-1);
}
if( (fseek(fp,(long long )(BLKSIZE * blk_no),SEEK_SET)) == -1)
{
printf("fseek error !! %s,%d\n", __FILE__ , __LINE__ );
perror("fseek");
exit(-1);
}
fread(buffer,BLKSIZE,1,fp) ;
printf(" we have read \n");
// {
// printf("read buffer error! %s,%d\n", __FILE__,__LINE__);
// perror("fread");
// exit(-1);
//}
}
/*
get_extmap_dict( char * buffer, extmap_dict *extmap_dict) {
char *p;
p=buffer;
memcpy(extmap_dict,p+OFFSETEXTMAPDICT,SIZEOFEXTMAPDICT);
}
void prt_extmap_dict( extmap_dict * extmap_dict) {
printf("Seg extmap dict :\n\
ext_cnt :0x%x = %d \n\
next_extmap :0x%x\n\
object_id :0x%x = %d \n\
flag :0x%\n",\
extmap_dict->ext_cnt,\
extmap_dict->n_extmap_rdba,\
extmap_dict->obj_id,\
extmap_dict->flag);
}
*/
extent_item * get_ext_byextmap(FILE *fp ,int extmap_rdba){
int i=0,j=0 ;
int f_no , blk_no ;
text buffer[BLKSIZE+1];
extmap_dict extmap_dic;
extent_item *ext_arrary, *p;
extent_cnt *cnt_arrary, *p1;
extent_data *data_arrary, *p2;
block_head blk_head ;
if (fp == NULL) {
printf(" FILE *fp is not open yet , %s ,%d \n",__FILE__,__LINE__);
perror("FILE *fp");
return NULL;
}
// initialize
memset(&f_no,0,sizeof(int));
memset(&blk_no,0,sizeof(int));
memset(buffer,0,BLKSIZE+1);
memset(&extmap_dic,0,sizeof(extmap_dict));
ext_arrary = NULL;
cnt_arrary = NULL;
data_arrary = NULL;
f_no = FILEID(extmap_rdba);
blk_no= BLOCKID(extmap_rdba);
printf(" file# %d, blk# %d\n",f_no,blk_no);
if ( (read_buffer( fp , extmap_rdba , buffer) ) == -1) {
perror("read_buffer");
printf("read_bffer error!!, %s , %d \n",__FILE__,__LINE__);
return NULL ;
}
get_blk_head(buffer,&blk_head);
prt_blk_hd(&blk_head,0);
get_extmap_dict(buffer,&extmap_dic) ;
printf("we have get extmap_dic\n");
prt_extmap_dict(&extmap_dic);
if ( extmap_dic.ext_cnt > 0 ) {
printf(" ext_cnt : %d \n",extmap_dic.ext_cnt);
cnt_arrary = calloc( sizeof(extent_cnt),extmap_dic.ext_cnt);
data_arrary = calloc(sizeof(extent_data),extmap_dic.ext_cnt);
ext_arrary = calloc(sizeof(extent_item),extmap_dic.ext_cnt);
p=ext_arrary ;
p1=cnt_arrary;
p2=data_arrary;
memcpy(cnt_arrary,buffer+40,sizeof(extent_cnt)*extmap_dic.ext_cnt);
memcpy(data_arrary,buffer+4100,sizeof(extent_data)*extmap_dic.ext_cnt);
for ( i=0; i<extmap_dic.ext_cnt;i++) {
p->ext_rdba = p1->ext_rdba ;
p->blk_cnt = p1->blk_cnt ;
p->data_addr = p2->data_addr;
p2++;
p1++;
p++;
}
}
free(cnt_arrary) ;
free(data_arrary) ;
return ext_arrary ;
}
int main(){
char file[]="/data/oracle/baby/prog/big_file/LSL.dbf";
FILE *fp ;
fp=fopen(file,"rb");
extent_item *p , *q ;
int next_extmap ;
q= get_ext_byextmap(fp,0x024f8011) ;
p=q ;
int i=0;
for (i=0; i< 0x88;i++) {
printf(" ext_rdba : 0x%x ext_cnt : 0x%x = %d ext_data : 0x%x \n",\
p->ext_rdba , p->blk_cnt, p->blk_cnt, p->data_addr );
p++;
}
free(q) ;
} |
|