gint sblb_block_data_file_read_raw (SBlbBlockDataFile *block_data_file, gint len, gpointer block_data, GError **error) { g_return_val_if_fail (SBLB_IS_BLOCK_DATA_FILE (block_data_file), -1); g_return_val_if_fail (block_data != NULL, -1); if (!ensure_file_is_open (block_data_file, error)) return -1; return read_raw_block (block_data_file, len, block_data, error); }
int isofs_read(const char *path,char *read_buf,size_t size,off_t offset) { log_msg("i am now in read_block\n"); struct iso_inode *inode = isofs_lookup(path); if(!inode) { fprintf(stderr,"no such file or directory found \n"); return -ENOENT; } if(ISO_FLAGS_DIR(inode->record->flags)) { fprintf(stderr,"not a regular file may be a directory\n"); return -EINVAL; } int data_size = gvar->data_size; struct iso_directory_record *dr = inode->record; int start_block = isonum_733(dr->extent); int end_block = isonum_733(dr->size)/data_size; int in_block = end_block - start_block ; int offset_block_start = offset / data_size; int offset_block_end = (offset + size) / data_size; int offset_shift_point = (offset%data_size); int block = offset_block_start + start_block; log_msg("malloced .....\n"); char *buf = (char *) malloc(data_size); if(!buf) { perror("isofs_read:cannot malloc"); exit(0); } int total = 0; int count = 0; int len; do{ log_msg("read_raw_block.....\n"); len = read_raw_block(block,buf); log_msg("buffer is now ....%s\n",buf); memcpy(read_buf+count*data_size,buf+offset_shift_point,data_size); log_msg("the read_buf is %s",read_buf); offset_shift_point = 0; count ++; block++; total += len; }while(count <= in_block); return total; }