mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-21 12:54:30 +02:00
Eliminate the fnode F_DDIR flag which has no SFT equivalent:
f_sft_idx==0xff can do the same. rwblock() is never called for directories so the checks could be removed. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1419 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
60e8c56f91
commit
fedf951beb
@ -54,7 +54,6 @@ struct f_node {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define F_DMOD 0x40 /* directory has been modified */
|
#define F_DMOD 0x40 /* directory has been modified */
|
||||||
#define F_DDIR 2 /* fnode is assigned to dir */
|
|
||||||
#define F_DDATE 0x4000 /* date set using setdate */
|
#define F_DDATE 0x4000 /* date set using setdate */
|
||||||
|
|
||||||
typedef struct f_node *f_node_ptr;
|
typedef struct f_node *f_node_ptr;
|
||||||
|
@ -42,7 +42,7 @@ static BYTE *fatdirRcsId =
|
|||||||
VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart)
|
VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart)
|
||||||
{
|
{
|
||||||
/* reset the directory flags */
|
/* reset the directory flags */
|
||||||
fnp->f_flags = F_DDIR;
|
fnp->f_sft_idx = 0xff;
|
||||||
fnp->f_diroff = 0;
|
fnp->f_diroff = 0;
|
||||||
fnp->f_offset = 0l;
|
fnp->f_offset = 0l;
|
||||||
fnp->f_cluster_offset = 0;
|
fnp->f_cluster_offset = 0;
|
||||||
@ -237,9 +237,6 @@ BOOL dir_write_update(REG f_node_ptr fnp, BOOL update)
|
|||||||
struct buffer FAR *bp;
|
struct buffer FAR *bp;
|
||||||
UBYTE FAR *vp;
|
UBYTE FAR *vp;
|
||||||
|
|
||||||
if (!(fnp->f_flags & F_DDIR))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Update the entry if it was modified by a write or create... */
|
/* Update the entry if it was modified by a write or create... */
|
||||||
if (fnp->f_flags & (F_DMOD|F_DDATE))
|
if (fnp->f_flags & (F_DMOD|F_DDATE))
|
||||||
{
|
{
|
||||||
|
@ -196,12 +196,13 @@ int dos_open(char *path, unsigned flags, unsigned attrib, int fd)
|
|||||||
if (status != S_OPENED)
|
if (status != S_OPENED)
|
||||||
{
|
{
|
||||||
init_direntry(&fnp->f_dir, attrib, FREE, fcbname);
|
init_direntry(&fnp->f_dir, attrib, FREE, fcbname);
|
||||||
fnp->f_flags = F_DMOD | F_DDIR;
|
fnp->f_flags = F_DMOD;
|
||||||
if (!dir_write(fnp))
|
if (!dir_write(fnp))
|
||||||
return DE_ACCESS;
|
return DE_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now change to file */
|
/* Now change to file */
|
||||||
|
fnp->f_sft_idx = fd;
|
||||||
fnp->f_offset = 0l;
|
fnp->f_offset = 0l;
|
||||||
|
|
||||||
if (status != S_OPENED)
|
if (status != S_OPENED)
|
||||||
@ -247,7 +248,7 @@ COUNT dos_close(COUNT fd)
|
|||||||
|
|
||||||
merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */
|
merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */
|
||||||
}
|
}
|
||||||
fnp->f_flags |= F_DDIR;
|
fnp->f_sft_idx = 0xff;
|
||||||
|
|
||||||
dir_write_update(fnp, TRUE);
|
dir_write_update(fnp, TRUE);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
@ -592,7 +593,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib)
|
|||||||
|
|
||||||
/* The directory has been modified, so set the bit before */
|
/* The directory has been modified, so set the bit before */
|
||||||
/* closing it, allowing it to be updated. */
|
/* closing it, allowing it to be updated. */
|
||||||
fnp1->f_flags = F_DMOD | F_DDIR;
|
fnp1->f_flags = F_DMOD;
|
||||||
|
|
||||||
/* Ok, so we can delete this one. Save the file info. */
|
/* Ok, so we can delete this one. Save the file info. */
|
||||||
*(fnp1->f_dir.dir_name) = DELETED;
|
*(fnp1->f_dir.dir_name) = DELETED;
|
||||||
@ -605,7 +606,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib)
|
|||||||
|
|
||||||
/* The directory has been modified, so set the bit before */
|
/* The directory has been modified, so set the bit before */
|
||||||
/* closing it, allowing it to be updated. */
|
/* closing it, allowing it to be updated. */
|
||||||
fnp2->f_flags = F_DMOD | F_DDIR;
|
fnp2->f_flags = F_DMOD;
|
||||||
dir_write(fnp2);
|
dir_write(fnp2);
|
||||||
|
|
||||||
/* SUCCESSful completion, return it */
|
/* SUCCESSful completion, return it */
|
||||||
@ -862,7 +863,7 @@ COUNT dos_mkdir(BYTE * dir)
|
|||||||
|
|
||||||
init_direntry(&fnp->f_dir, D_DIR, free_fat, fcbname);
|
init_direntry(&fnp->f_dir, D_DIR, free_fat, fcbname);
|
||||||
|
|
||||||
fnp->f_flags = F_DMOD | F_DDIR;
|
fnp->f_flags = F_DMOD;
|
||||||
|
|
||||||
fnp->f_offset = 0l;
|
fnp->f_offset = 0l;
|
||||||
|
|
||||||
@ -1017,7 +1018,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp)
|
|||||||
/* Description.
|
/* Description.
|
||||||
* Finds the cluster which contains byte at the fnp->f_offset offset and
|
* Finds the cluster which contains byte at the fnp->f_offset offset and
|
||||||
* stores its number to the fnp->f_cluster. The search begins from the start of
|
* stores its number to the fnp->f_cluster. The search begins from the start of
|
||||||
* a file or a directory depending whether fnp->f_ddir is FALSE or TRUE
|
* a file or a directory depending on whether the SFT index is valid
|
||||||
* and continues through the FAT chain until the target cluster is found.
|
* and continues through the FAT chain until the target cluster is found.
|
||||||
* The mode can have only XFR_READ or XFR_WRITE values.
|
* The mode can have only XFR_READ or XFR_WRITE values.
|
||||||
* In the XFR_WRITE mode map_cluster extends the FAT chain by creating
|
* In the XFR_WRITE mode map_cluster extends the FAT chain by creating
|
||||||
@ -1069,7 +1070,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode)
|
|||||||
/* If seek is to earlier in file than current position, */
|
/* If seek is to earlier in file than current position, */
|
||||||
/* we have to follow chain from the beginning again... */
|
/* we have to follow chain from the beginning again... */
|
||||||
/* Set internal index and cluster size. */
|
/* Set internal index and cluster size. */
|
||||||
fnp->f_cluster = (fnp->f_flags & F_DDIR) ? fnp->f_dirstart :
|
fnp->f_cluster = fnp->f_sft_idx == 0xff ? fnp->f_dirstart :
|
||||||
getdstart(fnp->f_dpb, &fnp->f_dir);
|
getdstart(fnp->f_dpb, &fnp->f_dir);
|
||||||
fnp->f_cluster_offset = 0;
|
fnp->f_cluster_offset = 0;
|
||||||
}
|
}
|
||||||
@ -1332,8 +1333,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
|||||||
unsigned sector, boff;
|
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. */
|
if (mode == XFR_READ && 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))
|
|
||||||
{
|
{
|
||||||
fnode_to_sft(fnp);
|
fnode_to_sft(fnp);
|
||||||
return ret_cnt;
|
return ret_cnt;
|
||||||
@ -1383,8 +1383,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
|||||||
|
|
||||||
/* see comments above */
|
/* see comments above */
|
||||||
|
|
||||||
if (!(fnp->f_flags & F_DDIR) && /* don't experiment with directories yet */
|
if (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;
|
||||||
@ -1473,7 +1472,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
|
|||||||
/* 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 - boff);
|
xfr_cnt = min(to_xfer, secsize - boff);
|
||||||
if (!(fnp->f_flags & F_DDIR) && mode == XFR_READ)
|
if (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);
|
||||||
|
|
||||||
/* transfer a block */
|
/* transfer a block */
|
||||||
@ -1634,7 +1633,6 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp)
|
|||||||
fnp->f_flags |= F_DMOD | F_DDATE;
|
fnp->f_flags |= F_DMOD | F_DDATE;
|
||||||
|
|
||||||
/* close open files in compat mode, otherwise there was a critical error */
|
/* close open files in compat mode, otherwise there was a critical error */
|
||||||
fnp->f_sft_idx = -1;
|
|
||||||
rc = merge_file_changes(fnp, -1);
|
rc = merge_file_changes(fnp, -1);
|
||||||
if (rc == SUCCESS)
|
if (rc == SUCCESS)
|
||||||
dir_write(fnp);
|
dir_write(fnp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user