mirror of https://github.com/FDOS/kernel.git
Eliminated f_sector and f_boff fields from fnodes.
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@814 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
b0009452ee
commit
df538bb32a
|
@ -58,8 +58,6 @@ struct f_node {
|
||||||
CLUSTER f_back; /* the cluster we were at */
|
CLUSTER f_back; /* the cluster we were at */
|
||||||
CLUSTER f_cluster_offset; /* relative cluster number within file */
|
CLUSTER f_cluster_offset; /* relative cluster number within file */
|
||||||
CLUSTER f_cluster; /* the cluster we are at */
|
CLUSTER f_cluster; /* the cluster we are at */
|
||||||
UWORD f_sector; /* the sector in the cluster */
|
|
||||||
UWORD f_boff; /* the byte in the cluster */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct f_node *f_node_ptr;
|
typedef struct f_node *f_node_ptr;
|
||||||
|
|
|
@ -186,11 +186,12 @@ STATIC struct buffer FAR *getblock_from_off(f_node_ptr fnp, unsigned secsize)
|
||||||
{
|
{
|
||||||
/* Compute the block within the cluster and the */
|
/* Compute the block within the cluster and the */
|
||||||
/* offset within the block. */
|
/* offset within the block. */
|
||||||
fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
unsigned sector;
|
||||||
fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
|
|
||||||
|
sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
||||||
|
|
||||||
/* Get the block we need from cache */
|
/* Get the block we need from cache */
|
||||||
return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
|
return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector,
|
||||||
fnp->f_dpb->dpb_unit);
|
fnp->f_dpb->dpb_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1432,6 +1432,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
|
||||||
/* The variable secsize will be used later. */
|
/* The variable secsize will be used later. */
|
||||||
UWORD secsize = fnp->f_dpb->dpb_secsize;
|
UWORD secsize = fnp->f_dpb->dpb_secsize;
|
||||||
ULONG count;
|
ULONG count;
|
||||||
|
unsigned sector, boff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fnp->f_offset <= fnp->f_dir.dir_size)
|
if (fnp->f_offset <= fnp->f_dir.dir_size)
|
||||||
|
@ -1449,27 +1450,27 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
|
||||||
#ifdef WRITEZEROS
|
#ifdef WRITEZEROS
|
||||||
/* Compute the block within the cluster and the offset */
|
/* Compute the block within the cluster and the offset */
|
||||||
/* within the block. */
|
/* within the block. */
|
||||||
fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
||||||
fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
|
boff = (UWORD)(fnp->f_offset % secsize);
|
||||||
|
|
||||||
#ifdef DSK_DEBUG
|
#ifdef DSK_DEBUG
|
||||||
printf("write %d links; dir offset %ld, cluster %d\n",
|
printf("write %d links; dir offset %ld, cluster %d\n",
|
||||||
fnp->f_count, fnp->f_diroff, fnp->f_cluster);
|
fnp->f_count, fnp->f_diroff, fnp->f_cluster);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xfr_cnt = count < (ULONG) secsize - fnp->f_boff ?
|
xfr_cnt = count < (ULONG) secsize - boff ?
|
||||||
(UWORD) count : secsize - fnp->f_boff;
|
(UWORD) count : secsize - boff;
|
||||||
|
|
||||||
/* get a buffer to store the block in */
|
/* get a buffer to store the block in */
|
||||||
if ((fnp->f_boff == 0) && (xfr_cnt == secsize))
|
if ((boff == 0) && (xfr_cnt == secsize))
|
||||||
{
|
{
|
||||||
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) +
|
bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) +
|
||||||
fnp->f_sector, fnp->f_dpb->dpb_unit);
|
sector, fnp->f_dpb->dpb_unit);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector,
|
bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector,
|
||||||
fnp->f_dpb->dpb_unit);
|
fnp->f_dpb->dpb_unit);
|
||||||
}
|
}
|
||||||
if (bp == NULL)
|
if (bp == NULL)
|
||||||
|
@ -1478,7 +1479,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set a block to zero */
|
/* set a block to zero */
|
||||||
fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt);
|
fmemset((BYTE FAR *) & bp->b_buffer[boff], 0, xfr_cnt);
|
||||||
bp->b_flag |= BFR_DIRTY | BFR_VALID;
|
bp->b_flag |= BFR_DIRTY | BFR_VALID;
|
||||||
|
|
||||||
if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */
|
if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */
|
||||||
|
@ -1635,6 +1636,8 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
/* can utilize memory management in future DOS-C versions. */
|
/* can utilize memory management in future DOS-C versions. */
|
||||||
while (ret_cnt < count)
|
while (ret_cnt < count)
|
||||||
{
|
{
|
||||||
|
unsigned sector, boff;
|
||||||
|
|
||||||
/* Do an EOF test and return whatever was transferred */
|
/* Do an EOF test and return whatever was transferred */
|
||||||
/* but only for regular files. */
|
/* but only for regular files. */
|
||||||
if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size))
|
if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size))
|
||||||
|
@ -1651,7 +1654,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
/* file offset case. Here, we need to take the fnode's */
|
/* file offset case. Here, we need to take the fnode's */
|
||||||
/* offset pointer (f_offset) and translate it into a */
|
/* offset pointer (f_offset) and translate it into a */
|
||||||
/* relative cluster position, cluster block (sector) */
|
/* relative cluster position, cluster block (sector) */
|
||||||
/* offset (f_sector) and byte offset (f_boff). Once we */
|
/* offset (sector) and byte offset (boff). Once we */
|
||||||
/* have this information, we need to translate the */
|
/* have this information, we need to translate the */
|
||||||
/* relative cluster position into an absolute cluster */
|
/* relative cluster position into an absolute cluster */
|
||||||
/* position (f_cluster). This is unfortunate because it */
|
/* position (f_cluster). This is unfortunate because it */
|
||||||
|
@ -1678,15 +1681,15 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
|
|
||||||
/* Compute the block within the cluster and the offset */
|
/* Compute the block within the cluster and the offset */
|
||||||
/* within the block. */
|
/* within the block. */
|
||||||
fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask;
|
||||||
fnp->f_boff = (UWORD)(fnp->f_offset % secsize);
|
boff = (UWORD)(fnp->f_offset % secsize);
|
||||||
|
|
||||||
currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector;
|
currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + sector;
|
||||||
|
|
||||||
/* see comments above */
|
/* see comments above */
|
||||||
|
|
||||||
if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */
|
if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */
|
||||||
fnp->f_boff == 0) /* complete sectors only */
|
boff == 0) /* complete sectors only */
|
||||||
{
|
{
|
||||||
static ULONG startoffset;
|
static ULONG startoffset;
|
||||||
UCOUNT sectors_to_xfer, sectors_wanted;
|
UCOUNT sectors_to_xfer, sectors_wanted;
|
||||||
|
@ -1703,7 +1706,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
if (sectors_wanted == 0)
|
if (sectors_wanted == 0)
|
||||||
goto normal_xfer;
|
goto normal_xfer;
|
||||||
|
|
||||||
sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector;
|
sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - sector;
|
||||||
|
|
||||||
sectors_to_xfer = min(sectors_to_xfer, sectors_wanted);
|
sectors_to_xfer = min(sectors_to_xfer, sectors_wanted);
|
||||||
|
|
||||||
|
@ -1772,7 +1775,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
/* requested transfer size, whichever is smaller. */
|
/* requested transfer size, whichever is smaller. */
|
||||||
/* Then compare to what is left, since we can transfer */
|
/* Then compare to what is left, since we can transfer */
|
||||||
/* a maximum of what is left. */
|
/* a maximum of what is left. */
|
||||||
xfr_cnt = min(to_xfer, secsize - fnp->f_boff);
|
xfr_cnt = min(to_xfer, secsize - boff);
|
||||||
if (!fnp->f_flags.f_ddir && mode == XFR_READ)
|
if (!fnp->f_flags.f_ddir && mode == XFR_READ)
|
||||||
xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset);
|
xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset);
|
||||||
|
|
||||||
|
@ -1783,12 +1786,12 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
||||||
/* a maximum of what is left. */
|
/* a maximum of what is left. */
|
||||||
if (mode == XFR_WRITE)
|
if (mode == XFR_WRITE)
|
||||||
{
|
{
|
||||||
fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt);
|
fmemcpy(&bp->b_buffer[boff], buffer, xfr_cnt);
|
||||||
bp->b_flag |= BFR_DIRTY | BFR_VALID;
|
bp->b_flag |= BFR_DIRTY | BFR_VALID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt);
|
fmemcpy(buffer, &bp->b_buffer[boff], xfr_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complete buffer transferred ?
|
/* complete buffer transferred ?
|
||||||
|
|
Loading…
Reference in New Issue