Eliminate f_count field in fnodes and some no-op functions.

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1398 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-05-26 13:47:52 +00:00
parent d7d201a53b
commit e63e5dd125
4 changed files with 10 additions and 68 deletions

View File

@ -36,7 +36,6 @@ static BYTE *fnode_hRcsId =
#endif
struct f_node {
UWORD f_count; /* number of uses of this file */
COUNT f_mode; /* read, write, read-write, etc */
UWORD f_flags; /* file flags */

View File

@ -61,12 +61,6 @@ f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp)
int i;
char fcbname[FNAME_SIZE + FEXT_SIZE];
/* Allocate an fnode if possible - error return (0) if not. */
if ((fnp = get_f_node(fnp)) == (f_node_ptr) 0)
{
return (f_node_ptr) 0;
}
/* Force the fnode into read-write mode */
fnp->f_mode = RDWR;
@ -76,10 +70,7 @@ f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp)
/* handling has been performed. */
if (media_check(fnp->f_dpb) < 0)
{
release_f_node(fnp);
return (f_node_ptr) 0;
}
/* Walk the directory tree to find the starting cluster */
/* */
@ -135,7 +126,6 @@ f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp)
if (!i || !(fnp->f_dir.dir_attrib & D_DIR))
{
release_f_node(fnp);
return (f_node_ptr) 0;
}
else
@ -261,10 +251,7 @@ BOOL dir_write_update(REG f_node_ptr fnp, BOOL update)
/* Now that we have a block, transfer the directory */
/* entry into the block. */
if (bp == NULL)
{
release_f_node(fnp);
return FALSE;
}
#ifdef DISPLAY_GETBLOCK
printf("DIR (dir_write)\n");
@ -310,9 +297,6 @@ VOID dir_close(REG f_node_ptr fnp)
/* Clear buffers after release */
/* hazard: no error checking! */
flush_buffers(fnp->f_dpb->dpb_unit);
/* and release this instance of the fnode */
release_f_node(fnp);
}
#ifndef IPL
@ -424,11 +408,7 @@ COUNT dos_findnext(void)
REG dmatch *dmp = &sda_tmp_dm;
/* Allocate an fnode if possible - error return (0) if not. */
if ((fnp = get_f_node(&fnode[0])) == (f_node_ptr) 0)
{
return DE_NFILES;
}
fnp = &fnode[0];
memset(fnp, 0, sizeof(*fnp));
/* Force the fnode into read-write mode */
@ -438,10 +418,7 @@ COUNT dos_findnext(void)
/* searches... */
fnp->f_dpb = get_dpb(dmp->dm_drive);
if (media_check(fnp->f_dpb) < 0)
{
release_f_node(fnp);
return DE_NFILES;
}
dir_init_fnode(fnp, dmp->dm_dircluster);
@ -475,7 +452,6 @@ COUNT dos_findnext(void)
dmp->dm_dircluster = fnp->f_dirstart;
memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent));
/* return the result */
release_f_node(fnp);
return SUCCESS;
}
}
@ -487,8 +463,6 @@ COUNT dos_findnext(void)
printf("dos_findnext: %11s\n", fnp->f_dir.dir_name);
#endif
/* return the result */
release_f_node(fnp);
return DE_NFILES;
}
#endif

View File

@ -37,7 +37,7 @@ BYTE *RcsId = "$Id$";
/* */
/* function prototypes */
/* */
STATIC void sft_to_fnode(f_node_ptr fnp, int fd);
STATIC int sft_to_fnode(f_node_ptr fnp, int fd);
f_node_ptr xlt_fd(COUNT);
COUNT xlt_fnp(f_node_ptr);
STATIC void fnode_to_sft(f_node_ptr fnp, int fd);
@ -219,10 +219,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib, int fd)
init_direntry(&fnp->f_dir, attrib, FREE, fcbname);
fnp->f_flags = F_DMOD | F_DDIR;
if (!dir_write(fnp))
{
release_f_node(fnp);
return DE_ACCESS;
}
}
/* Now change to file */
@ -324,16 +321,6 @@ f_node_ptr split_path(char * path, char * fcbname, f_node_ptr fnp)
fnp = dir_open(path, fnp);
path[dirlength] = tmp;
}
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit... */
/* note: an invalid fd is indicated by a 0 return */
if (fnp == (f_node_ptr) 0 || fnp->f_count == 0)
{
dir_close(fnp);
return (f_node_ptr) 0;
}
return fnp;
}
@ -439,10 +426,7 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect)
f_nodes_cnt = get_f_nodes_cnt();
for (i = 0; i < f_nodes_cnt; i++)
{
sft_to_fnode(fnp2, i);
if ((fnp != (f_node_ptr) 0)
&& (i != fd)
&& (fnp->f_count > 0) && (is_same_file(fnp, fnp2)))
if (i != fd && sft_to_fnode(fnp2, i) == SUCCESS && is_same_file(fnp, fnp2))
{
if (collect)
{
@ -1880,17 +1864,6 @@ int dos_cd(char * PathName)
}
#endif
/* Compat functions for SFT transition */
f_node_ptr get_f_node(f_node_ptr fnp)
{
fnp->f_count = 1;
return fnp;
}
VOID release_f_node(f_node_ptr fnp)
{
}
#ifndef IPL
COUNT dos_getfattr_fd(COUNT fd)
{
@ -2143,12 +2116,13 @@ COUNT xlt_fnp(f_node_ptr fnp)
return fnode_fd[fnp - fnode];
}
STATIC void sft_to_fnode(f_node_ptr fnp, int fd)
STATIC int sft_to_fnode(f_node_ptr fnp, int fd)
{
sft FAR *sftp = idx_to_sft(fd);
UWORD flags;
fnp->f_count = sftp->sft_count;
if (FP_OFF(sftp) == (size_t) - 1)
return -1;
flags = sftp->sft_flags;
fnp->f_flags = (flags & SFT_FDATE) | ((flags & SFT_FDIRTY) ^ SFT_FDIRTY);
fnp->f_dir.dir_attrib = sftp->sft_attrib;
@ -2169,6 +2143,7 @@ STATIC void sft_to_fnode(f_node_ptr fnp, int fd)
#else
fnp->f_cluster_offset = sftp->sft_relclust;
#endif
return SUCCESS;
}
/* copy the SFT fd into the first near fnode */
@ -2177,14 +2152,10 @@ f_node_ptr xlt_fd(int fd)
/* If the fd was invalid because it was out of range or the */
/* requested file was not open, tell the caller and exit */
/* note: an invalid fd is indicated by a 0 return */
if (fd < get_f_nodes_cnt())
if (sft_to_fnode(&fnode[0], fd) == SUCCESS)
{
sft_to_fnode(&fnode[0], fd);
if (fnode[0].f_count > 0)
{
fnode_fd[0] = fd;
return &fnode[0];
}
fnode_fd[0] = fd;
return &fnode[0];
}
return NULL;
}

View File

@ -180,8 +180,6 @@ VOID trim_path(BYTE FAR * s);
int dos_cd(char * PathName);
f_node_ptr get_f_node(f_node_ptr fnp);
VOID release_f_node(f_node_ptr fnp);
COUNT dos_getfattr_fd(COUNT fd);
COUNT dos_getfattr(BYTE * name);
COUNT dos_setfattr(BYTE * name, UWORD attrp);