📄 lowl.c
字号:
tm_printf("numroot %d\n", (int) pbl0->numroot);
tm_printf("secpfat %d\n", (int) pbl0->secpfat);
tm_printf("numsecs %d\n", (int) pbl0->numsecs);
tm_printf("secptrk %d\n", (int) pbl0->secptrk);
tm_printf("numhead %d\n", (int) pbl0->numhead);
tm_printf("secpfat2 %ld\n", pbl0->secpfat2);
tm_printf("flags %x\n", (int) pbl0->flags);
tm_printf("fs_version %x\n", (int) pbl0->fs_version);
tm_printf("rootbegin %ld\n", pbl0->rootbegin);
tm_printf("infosec %ld\n", (long) pbl0->infosec);
tm_printf("backup %ld\n", (long) pbl0->backup);
tm_printf("numhide %d\n", (int) pbl0->numhide);
tm_printf("numhide2 %d\n", (int) pbl0->numhide2);
tm_printf("numsec2 %ld\n", (long) pbl0->numsecs2);
tm_printf("volid %lx\n", (long) pbl0->volid);
tm_printf("bytspsector %d\n", (int)pbl0->bytspsector);
tm_printf("volid %d\n", (int) pbl0->volid );
tm_printf("vollabel[0] %s\n", pbl0->vollabel);
// =====
#endif
pc_free_buf(buf, TRUE);
return(TRUE);
}
RTFS_FILE(clzero.c, pc_clzero)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
#if (RTFS_WRITE)
#if (RTFS_SUBDIRS)
/***************************************************************************
PC_CLZERO - Fill a disk cluster with zeroes
Description
Write zeroes into the cluster at clusterno on the drive pointed to by
pdrive. Used to zero out directory and data file clusters to eliminate
any residual data.
Returns
Returns FALSE on a write erro.
****************************************************************************/
/* Write zeros to all blocks in a cluster */
BOOLEAN pc_clzero(DDRIVE *pdrive, CLUSTERTYPE cluster) /*__fn__*/
{
BLKBUFF *pbuff;
CLUSTERTYPE i;
BLOCKT currbl;
currbl = pc_cl2sector(pdrive , cluster);
if (!currbl)
return (FALSE);
/*Init and write a block for each block in cl. Note: init clears the core */
for (i = 0; i < pdrive->secpalloc; i++, currbl++ )
{
pbuff = pc_init_blk( pdrive , currbl);
if (!pbuff)
{
return (FALSE);
}
if ( !pc_write_blk ( pbuff ) )
{
pc_free_buf(pbuff,TRUE);
return (FALSE);
}
else
pc_free_buf(pbuff,FALSE);
}
return (TRUE);
}
#endif
#endif
RTFS_FILE(drno2dr.c, pc_drno2dr)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/****************************************************************************
PC_DRNO2DR - Convert a drive number to a pointer to DDRIVE
Description
Given a drive number look up the DDRIVE structure associated with it.
Returns
Returns NULL if driveno is not an open drive.
****************************************************************************/
DDRIVE *pc_drno_to_drive_struct(int driveno) /*__fn__*/
{
DDRIVE *pdr;
pdr = 0;
/* Check drive number */
if (pc_validate_driveno(driveno))
{
pdr = drno_to_dr_map[driveno];
}
return(pdr);
}
DDRIVE *pc_drno2dr(int driveno) /*__fn__*/
{
DDRIVE *pdr;
DDRIVE *pretval;
pdr = pc_drno_to_drive_struct(driveno);
pretval = 0;
OS_CLAIM_FSCRITICAL()
/* Check drive number */
if (pdr)
{
if (pdr->mount_valid)
{
pretval = pdr;
}
}
OS_RELEASE_FSCRITICAL()
return(pretval);
}
RTFS_FILE(dskfree.c, pc_dskfree)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/***************************************************************************
PC_DSKFREE - Deallocate all core associated with a disk structure
Description
Given a valid drive number. If the drive open count goes to zero, free the
file allocation table and the block zero information associated with the
drive. If unconditional is true, ignore the open count and release the
drive.
If open count reaches zero or unconditional, all future accesses to
driveno will fail until re-opened.
Returns
Returns FALSE if driveno is not an open drive.
****************************************************************************/
/* free up all core associated with the drive
called by close. A drive restart would consist of
pc_dskfree(driveno, TRUE), pc_dskopen() */
BOOLEAN pc_dskfree(int driveno) /*__fn__*/
{
DDRIVE *pdr;
/* DROBJ *pcwd; */
/* Note this will fail unless mount_valid is true */
pdr = pc_drno2dr(driveno);
if (!pdr)
{
return(FALSE);
}
if (pdr->mount_valid)
{
/* Free the current working directory for this drive for all users */
pc_free_all_users(driveno);
/* Free all files, finodes & blocks associated with the drive */
pc_free_all_fil(pdr);
pc_free_all_i(pdr);
pc_free_all_blk(pdr);
}
pdr->mount_valid = FALSE;
return (TRUE);
}
RTFS_FILE(ifree.c, pc_ifree)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/***************************************************************************
PC_IFREE - Count the number of free bytes remaining on a disk (internal)
Description
Given a drive number count the number of free bytes on the drive. (called
by pc_free).
Returns
The number of free bytes or zero if the drive is full or
it it not open or out of range.
NOTE: To speed up this operation we maintain a variable in the
drive structure. known_free_clusters. If this variable is
non zero a multiple of this value will be returned. To force
the free count to be recalculated just set field to zero
before calling this function.
****************************************************************************/
dword pc_ifree(int driveno) /*__fn__*/
{
DDRIVE *pdr;
CLUSTERTYPE i;
CLUSTERTYPE nxt;
CLUSTERTYPE freecount = 0;
long ltemp;
pdr = pc_drno2dr(driveno);
if (!pdr)
{
return(0L);
}
if (pdr->known_free_clusters
#if (FAT32)
&& pdr->known_free_clusters != -1
#endif
)
freecount = pdr->known_free_clusters;
else
{
for (i = 2 ; i <= pdr->maxfindex; i++)
{
if (!pc_faxx(pdr, i, &nxt))
return(0L);
if (nxt == 0)
freecount++;
}
pdr->known_free_clusters = freecount;
}
ltemp = (dword) freecount;
ltemp *= pdr->bytespcluster;
return (ltemp);
}
RTFS_FILE(sec2cl.c, pc_sec2cluster)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/****************************************************************************
PC_SEC2CLUSTER - Convert a block number to its cluster representation.
Description
Convert blockno to its cluster representation if it is in cluster space.
Returns
Returns 0 if the block is not in cluster space, else returns the
cluster number associated with block.
****************************************************************************/
#if (RTFS_SUBDIRS)
/* Cluster<->sector conversion routines */
/* Convert sector to cluster. 0 == s error */
CLUSTERTYPE pc_sec2cluster(DDRIVE *pdrive, BLOCKT blockno) /*__fn__*/
{
BLOCKT ltemp;
BLOCKT answer;
if ((blockno >= pdrive->numsecs) || (pdrive->firstclblock > blockno))
return (0);
else
{
/* (2 + (blockno - pdrive->firstclblock)/pdrive->secpalloc) */
ltemp = blockno - pdrive->firstclblock;
answer = ltemp;
answer = (BLOCKT) answer >> pdrive->log2_secpalloc;
answer += 2;
return ((CLUSTERTYPE)answer);
}
}
#endif
RTFS_FILE(sec2indx.c, pc_sec2index)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/****************************************************************************
PC_SEC2INDEX - Calculate the offset into a cluster for a block.
Description
Given a block number offset from the beginning of the drive, calculate
which block number within a cluster it will be. If the block number
coincides with a cluster boundary, the return value will be zero. If it
coincides with a cluster boundary + 1 block, the value will be 1, etc.
Returns
0,1,2 upto blockspcluster -1.
***************************************************************************/
#if (RTFS_SUBDIRS)
/* Convert sector to index into a cluster . No error detection */
word pc_sec2index(DDRIVE *pdrive, BLOCKT blockno) /*__fn__*/
{
BLOCKT answer;
/* ((blockno - pdrive->firstclblock) % pdrive->secpalloc) ); */
answer = blockno - pdrive->firstclblock;
answer = answer % pdrive->secpalloc;
return ( (word) answer);
}
#endif
RTFS_FILE(cl2sect.c, pc_cl2sector)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
/***************************************************************************
PC_CL2SECTOR - Convert a cluster number to block number representation.
Description
Convert cluster number to a blocknumber.
Returns
Returns 0 if the cluster is out of range. else returns the
block number of the beginning of the cluster.
****************************************************************************/
/* Convert cluster. to sector */
BLOCKT pc_cl2sector(DDRIVE *pdrive, CLUSTERTYPE cluster) /*__fn__*/
{
BLOCKT blockno;
dword t;
if (cluster < 2)
return (BLOCKEQ0);
else
{
t = cluster - 2;
t = t << pdrive->log2_secpalloc;
blockno = pdrive->firstclblock + t;
}
if (blockno >= pdrive->numsecs)
return (BLOCKEQ0);
else
return (blockno);
}
RTFS_FILE(partinit.c, ext_part_init)
#ifndef __PCDISK__ /* This allows us to build the lib with subroutines split */
#include <pcdisk.h>
#endif
CLUSTERTYPE pc_finode_cluster(DDRIVE *pdr, FINODE *finode) /* __fn__ */
{
#if (FAT32)
if (pdr->fasize == 8)
return ( (dword)finode->fcluster | ((dword)finode->fclusterhi << 16) );
else
#else
ARGSUSED_PVOID((PFVOID) pdr);
#endif
return ( (CLUSTERTYPE)finode->fcluster );
}
void pc_pfinode_cluster(DDRIVE *pdr, FINODE *finode, CLUSTERTYPE value) /*__fn__ */
{
finode->fcluster = (word)value;
#if (FAT32)
if (pdr->fasize == 8)
finode->fclusterhi = (word)(value >> 16);
#else
ARGSUSED_PVOID((PFVOID) pdr);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -