Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv2185/libntfs
Modified Files:
disk_io.c
Log Message:
Updates
Index: disk_io.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/disk_io.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** disk_io.c 2001/03/05 03:04:40 1.3
--- disk_io.c 2001/03/26 03:39:59 1.4
***************
*** 263,267 ****
}
! int get_mft_records(const ntfs_volume *vol, __u8 *buf, const __s64 mftrec,
const int count)
{
--- 263,313 ----
}
! /*
! * Return 0 on success, <0 on error (return value is the error code).
! * Caller has to free(*mrec) when finished.
! */
! int read_file_record(const ntfs_volume *vol, const MFT_REFERENCE mref,
! MFT_RECORD **mrec, ATTR_RECORD **attr)
! {
! int er = 0;
!
! if (!vol || !mrec || !attr) {
! #ifdef DEBUG
! fprintf(stderr, "read_file_record() received NULL pointer!\n");
! #endif
! return -EINVAL;
! }
! if (!(*mrec = malloc(vol->mft_record_size)))
! return -ENOMEM;
! if ((er = get_mft_record(vol, *mrec, mref)) != 1)
! goto failed;
! if (!is_file_record(*mrec->magic))
! goto file_corrupt;
! if (mref.sequence_number != le16_to_cpu(*mrec->sequence_number))
! goto file_corrupt;
! if (!(*mrec->flags & MFT_RECORD_IN_USE))
! goto file_corrupt;
! *attr = (ATTR_RECORD*)((char*)*mrec + le16_to_cpu(*mrec->attrs_offset));
! if (*attr < *mrec || *attr > (char*)*mrec + vol->mft_record_size)
! goto file_corrupt;
! return 0;
! file_corrupt:
! #ifdef DEBUG
! fprintf(stderr, "read_file_record(): file is corrupt.\n");
! #endif
! er = -EIO;
! failed:
! free(*mrec);
! *mrec = *attr = NULL;
! return er < 0 ? er : -EINVAL;
! }
!
! __inline__ int get_mft_record(const ntfs_volume *vol, __u8 *buf,
! const __s64 mft_ref)
! {
! return get_mft_records(vol, buf, mft_ref, 1);
! }
!
! int get_mft_records(const ntfs_volume *vol, __u8 *buf, const __s64 mft_ref,
const int count)
{
***************
*** 269,279 ****
__s64 lcn, ofs;
! if (!vol || !buf || mftrec < 0)
return -EINVAL;
if (!vol->fd)
return -EBADF;
! if (vol->number_of_mft_records < mftrec + count)
return -ESPIPE;
! if (!get_bit(vol->mft_bitmap, mftrec))
return -ENOENT;
/* Size of mft record != size of cluster thus need to work with
--- 315,325 ----
__s64 lcn, ofs;
! if (!vol || !buf || mftref < 0)
return -EINVAL;
if (!vol->fd)
return -EBADF;
! if (vol->number_of_mft_records < mft_ref + count)
return -ESPIPE;
! if (!get_bit(vol->mft_bitmap, mft_ref))
return -ENOENT;
/* Size of mft record != size of cluster thus need to work with
***************
*** 281,292 ****
if (vol->mft_records_per_cluster) {
lcn = vcn_to_lcn(vol->mft_runlist,
! mftrec / vol->mft_records_per_cluster);
/* FIXME: Change "/" above and "%" below to ">>" and "&"
respectively! */
! ofs = mftrec % vol->mft_records_per_cluster;
ofs <<= vol->mft_record_size_bits;
} else {
lcn = vcn_to_lcn(vol->mft_runlist,
! mftrec * vol->clusters_per_mft_record);
/* FIXME: Change "*" above to "<<"! */
ofs = 0;
--- 327,338 ----
if (vol->mft_records_per_cluster) {
lcn = vcn_to_lcn(vol->mft_runlist,
! mft_ref / vol->mft_records_per_cluster);
/* FIXME: Change "/" above and "%" below to ">>" and "&"
respectively! */
! ofs = mft_ref % vol->mft_records_per_cluster;
ofs <<= vol->mft_record_size_bits;
} else {
lcn = vcn_to_lcn(vol->mft_runlist,
! mft_ref * vol->clusters_per_mft_record);
/* FIXME: Change "*" above to "<<"! */
ofs = 0;
|