Fix ntfs such that it understand media with a non-512-bytes sector size:
1. Fixups are always done on 512 byte chunks (in stead of sectors). This is kind of stupid. 2. Conevrt between NTFS blocknumbers (the blocksize equals the media sector size) and the bread() and getblk() blocknr (which are 512-byte sized) NB: this change should not affect ntfs for 512-byte sector sizes.
This commit is contained in:
parent
58a0206d63
commit
c53a28102a
@ -183,6 +183,7 @@ struct attr_indexentry {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define NTFS_FILEMAGIC (u_int32_t)(0x454C4946)
|
#define NTFS_FILEMAGIC (u_int32_t)(0x454C4946)
|
||||||
|
#define NTFS_BLOCK_SIZE 512
|
||||||
#define NTFS_FRFLAG_DIR 0x0002
|
#define NTFS_FRFLAG_DIR 0x0002
|
||||||
struct filerec {
|
struct filerec {
|
||||||
struct fixuphdr fr_fixup;
|
struct fixuphdr fr_fixup;
|
||||||
@ -257,6 +258,7 @@ struct ntfsmount {
|
|||||||
char ** ntm_u28; /* Unicode to 8 bit */
|
char ** ntm_u28; /* Unicode to 8 bit */
|
||||||
void * ntm_ic_l2u; /* Local to Unicode (iconv) */
|
void * ntm_ic_l2u; /* Local to Unicode (iconv) */
|
||||||
void * ntm_ic_u2l; /* Unicode to Local (iconv) */
|
void * ntm_ic_u2l; /* Unicode to Local (iconv) */
|
||||||
|
u_int8_t ntm_multiplier; /* NTFS blockno to DEV_BSIZE sectorno */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ntm_mftcn ntm_bootfile.bf_mftcn
|
#define ntm_mftcn ntm_bootfile.bf_mftcn
|
||||||
|
@ -278,6 +278,7 @@ ntfs_loadntnode(
|
|||||||
|
|
||||||
bn = ntfs_cntobn(ntmp->ntm_mftcn) +
|
bn = ntfs_cntobn(ntmp->ntm_mftcn) +
|
||||||
ntmp->ntm_bpmftrec * ip->i_number;
|
ntmp->ntm_bpmftrec * ip->i_number;
|
||||||
|
bn *= ntmp->ntm_multiplier;
|
||||||
|
|
||||||
error = bread(ntmp->ntm_devvp,
|
error = bread(ntmp->ntm_devvp,
|
||||||
bn, ntfs_bntob(ntmp->ntm_bpmftrec),
|
bn, ntfs_bntob(ntmp->ntm_bpmftrec),
|
||||||
@ -581,7 +582,7 @@ ntfs_attrtontvattr(
|
|||||||
memcpy(vap->va_datap, (caddr_t) rap + rap->a_r.a_dataoff,
|
memcpy(vap->va_datap, (caddr_t) rap + rap->a_r.a_dataoff,
|
||||||
rap->a_r.a_datalen);
|
rap->a_r.a_datalen);
|
||||||
}
|
}
|
||||||
ddprintf((", len: %d", vap->va_datalen));
|
ddprintf((", len: %lld", vap->va_datalen));
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
free(vap, M_NTFSNTVATTR);
|
free(vap, M_NTFSNTVATTR);
|
||||||
@ -1491,11 +1492,13 @@ ntfs_writentvattr_plain(
|
|||||||
(u_int32_t) left));
|
(u_int32_t) left));
|
||||||
if ((off == 0) && (tocopy == ntfs_cntob(cl)))
|
if ((off == 0) && (tocopy == ntfs_cntob(cl)))
|
||||||
{
|
{
|
||||||
bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn),
|
bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn)
|
||||||
|
* ntmp->ntm_multiplier,
|
||||||
ntfs_cntob(cl), 0, 0, 0);
|
ntfs_cntob(cl), 0, 0, 0);
|
||||||
clrbuf(bp);
|
clrbuf(bp);
|
||||||
} else {
|
} else {
|
||||||
error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn),
|
error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn)
|
||||||
|
* ntmp->ntm_multiplier,
|
||||||
ntfs_cntob(cl), NOCRED, &bp);
|
ntfs_cntob(cl), NOCRED, &bp);
|
||||||
if (error) {
|
if (error) {
|
||||||
brelse(bp);
|
brelse(bp);
|
||||||
@ -1602,7 +1605,8 @@ ntfs_readntvattr_plain(
|
|||||||
(u_int32_t) tocopy,
|
(u_int32_t) tocopy,
|
||||||
(u_int32_t) left));
|
(u_int32_t) left));
|
||||||
error = bread(ntmp->ntm_devvp,
|
error = bread(ntmp->ntm_devvp,
|
||||||
ntfs_cntobn(cn),
|
ntfs_cntobn(cn)
|
||||||
|
* ntmp->ntm_multiplier,
|
||||||
ntfs_cntob(cl),
|
ntfs_cntob(cl),
|
||||||
NOCRED, &bp);
|
NOCRED, &bp);
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -1878,7 +1882,7 @@ ntfs_procfixups(
|
|||||||
fhp->fh_magic, magic);
|
fhp->fh_magic, magic);
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
if ((fhp->fh_fnum - 1) * ntmp->ntm_bps != len) {
|
if ((fhp->fh_fnum - 1) * NTFS_BLOCK_SIZE != len) {
|
||||||
printf("ntfs_procfixups: " \
|
printf("ntfs_procfixups: " \
|
||||||
"bad fixups number: %d for %ld bytes block\n",
|
"bad fixups number: %d for %ld bytes block\n",
|
||||||
fhp->fh_fnum, (long)len); /* XXX printf kludge */
|
fhp->fh_fnum, (long)len); /* XXX printf kludge */
|
||||||
@ -1889,7 +1893,7 @@ ntfs_procfixups(
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
fxp = (u_int16_t *) (buf + fhp->fh_foff);
|
fxp = (u_int16_t *) (buf + fhp->fh_foff);
|
||||||
cfxp = (u_int16_t *) (buf + ntmp->ntm_bps - 2);
|
cfxp = (u_int16_t *) (buf + NTFS_BLOCK_SIZE - 2);
|
||||||
fixup = *fxp++;
|
fixup = *fxp++;
|
||||||
for (i = 1; i < fhp->fh_fnum; i++, fxp++) {
|
for (i = 1; i < fhp->fh_fnum; i++, fxp++) {
|
||||||
if (*cfxp != fixup) {
|
if (*cfxp != fixup) {
|
||||||
@ -1897,7 +1901,7 @@ ntfs_procfixups(
|
|||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
*cfxp = *fxp;
|
*cfxp = *fxp;
|
||||||
cfxp = (u_int16_t *) ((caddr_t) cfxp + ntmp->ntm_bps);
|
cfxp = (u_int16_t *) ((caddr_t) cfxp + NTFS_BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -316,6 +316,8 @@ ntfs_mountfs(devvp, mp, td)
|
|||||||
else
|
else
|
||||||
ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
|
ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
|
||||||
}
|
}
|
||||||
|
ntmp->ntm_multiplier = ntmp->ntm_bps / DEV_BSIZE;
|
||||||
|
|
||||||
dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
|
dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
|
||||||
ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
|
ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
|
||||||
ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
|
ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
|
||||||
|
Loading…
Reference in New Issue
Block a user