mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-14 01:14:27 +02:00
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:
parent
d7d201a53b
commit
e63e5dd125
@ -36,7 +36,6 @@ static BYTE *fnode_hRcsId =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct f_node {
|
struct f_node {
|
||||||
UWORD f_count; /* number of uses of this file */
|
|
||||||
COUNT f_mode; /* read, write, read-write, etc */
|
COUNT f_mode; /* read, write, read-write, etc */
|
||||||
|
|
||||||
UWORD f_flags; /* file flags */
|
UWORD f_flags; /* file flags */
|
||||||
|
@ -61,12 +61,6 @@ f_node_ptr dir_open(register const char *dirname, f_node_ptr fnp)
|
|||||||
int i;
|
int i;
|
||||||
char fcbname[FNAME_SIZE + FEXT_SIZE];
|
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 */
|
/* Force the fnode into read-write mode */
|
||||||
fnp->f_mode = RDWR;
|
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. */
|
/* handling has been performed. */
|
||||||
|
|
||||||
if (media_check(fnp->f_dpb) < 0)
|
if (media_check(fnp->f_dpb) < 0)
|
||||||
{
|
|
||||||
release_f_node(fnp);
|
|
||||||
return (f_node_ptr) 0;
|
return (f_node_ptr) 0;
|
||||||
}
|
|
||||||
|
|
||||||
/* Walk the directory tree to find the starting cluster */
|
/* 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))
|
if (!i || !(fnp->f_dir.dir_attrib & D_DIR))
|
||||||
{
|
{
|
||||||
release_f_node(fnp);
|
|
||||||
return (f_node_ptr) 0;
|
return (f_node_ptr) 0;
|
||||||
}
|
}
|
||||||
else
|
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 */
|
/* Now that we have a block, transfer the directory */
|
||||||
/* entry into the block. */
|
/* entry into the block. */
|
||||||
if (bp == NULL)
|
if (bp == NULL)
|
||||||
{
|
|
||||||
release_f_node(fnp);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DISPLAY_GETBLOCK
|
#ifdef DISPLAY_GETBLOCK
|
||||||
printf("DIR (dir_write)\n");
|
printf("DIR (dir_write)\n");
|
||||||
@ -310,9 +297,6 @@ VOID dir_close(REG f_node_ptr fnp)
|
|||||||
/* Clear buffers after release */
|
/* Clear buffers after release */
|
||||||
/* hazard: no error checking! */
|
/* hazard: no error checking! */
|
||||||
flush_buffers(fnp->f_dpb->dpb_unit);
|
flush_buffers(fnp->f_dpb->dpb_unit);
|
||||||
|
|
||||||
/* and release this instance of the fnode */
|
|
||||||
release_f_node(fnp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef IPL
|
#ifndef IPL
|
||||||
@ -424,11 +408,7 @@ COUNT dos_findnext(void)
|
|||||||
REG dmatch *dmp = &sda_tmp_dm;
|
REG dmatch *dmp = &sda_tmp_dm;
|
||||||
|
|
||||||
/* Allocate an fnode if possible - error return (0) if not. */
|
/* Allocate an fnode if possible - error return (0) if not. */
|
||||||
if ((fnp = get_f_node(&fnode[0])) == (f_node_ptr) 0)
|
fnp = &fnode[0];
|
||||||
{
|
|
||||||
return DE_NFILES;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(fnp, 0, sizeof(*fnp));
|
memset(fnp, 0, sizeof(*fnp));
|
||||||
|
|
||||||
/* Force the fnode into read-write mode */
|
/* Force the fnode into read-write mode */
|
||||||
@ -438,10 +418,7 @@ COUNT dos_findnext(void)
|
|||||||
/* searches... */
|
/* searches... */
|
||||||
fnp->f_dpb = get_dpb(dmp->dm_drive);
|
fnp->f_dpb = get_dpb(dmp->dm_drive);
|
||||||
if (media_check(fnp->f_dpb) < 0)
|
if (media_check(fnp->f_dpb) < 0)
|
||||||
{
|
|
||||||
release_f_node(fnp);
|
|
||||||
return DE_NFILES;
|
return DE_NFILES;
|
||||||
}
|
|
||||||
|
|
||||||
dir_init_fnode(fnp, dmp->dm_dircluster);
|
dir_init_fnode(fnp, dmp->dm_dircluster);
|
||||||
|
|
||||||
@ -475,7 +452,6 @@ COUNT dos_findnext(void)
|
|||||||
dmp->dm_dircluster = fnp->f_dirstart;
|
dmp->dm_dircluster = fnp->f_dirstart;
|
||||||
memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent));
|
memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent));
|
||||||
/* return the result */
|
/* return the result */
|
||||||
release_f_node(fnp);
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,8 +463,6 @@ COUNT dos_findnext(void)
|
|||||||
printf("dos_findnext: %11s\n", fnp->f_dir.dir_name);
|
printf("dos_findnext: %11s\n", fnp->f_dir.dir_name);
|
||||||
#endif
|
#endif
|
||||||
/* return the result */
|
/* return the result */
|
||||||
release_f_node(fnp);
|
|
||||||
|
|
||||||
return DE_NFILES;
|
return DE_NFILES;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ BYTE *RcsId = "$Id$";
|
|||||||
/* */
|
/* */
|
||||||
/* function prototypes */
|
/* 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);
|
f_node_ptr xlt_fd(COUNT);
|
||||||
COUNT xlt_fnp(f_node_ptr);
|
COUNT xlt_fnp(f_node_ptr);
|
||||||
STATIC void fnode_to_sft(f_node_ptr fnp, int fd);
|
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);
|
init_direntry(&fnp->f_dir, attrib, FREE, fcbname);
|
||||||
fnp->f_flags = F_DMOD | F_DDIR;
|
fnp->f_flags = F_DMOD | F_DDIR;
|
||||||
if (!dir_write(fnp))
|
if (!dir_write(fnp))
|
||||||
{
|
|
||||||
release_f_node(fnp);
|
|
||||||
return DE_ACCESS;
|
return DE_ACCESS;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now change to file */
|
/* 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);
|
fnp = dir_open(path, fnp);
|
||||||
path[dirlength] = tmp;
|
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;
|
return fnp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,10 +426,7 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect)
|
|||||||
f_nodes_cnt = get_f_nodes_cnt();
|
f_nodes_cnt = get_f_nodes_cnt();
|
||||||
for (i = 0; i < f_nodes_cnt; i++)
|
for (i = 0; i < f_nodes_cnt; i++)
|
||||||
{
|
{
|
||||||
sft_to_fnode(fnp2, i);
|
if (i != fd && sft_to_fnode(fnp2, i) == SUCCESS && is_same_file(fnp, fnp2))
|
||||||
if ((fnp != (f_node_ptr) 0)
|
|
||||||
&& (i != fd)
|
|
||||||
&& (fnp->f_count > 0) && (is_same_file(fnp, fnp2)))
|
|
||||||
{
|
{
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
@ -1880,17 +1864,6 @@ int dos_cd(char * PathName)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifndef IPL
|
||||||
COUNT dos_getfattr_fd(COUNT fd)
|
COUNT dos_getfattr_fd(COUNT fd)
|
||||||
{
|
{
|
||||||
@ -2143,12 +2116,13 @@ COUNT xlt_fnp(f_node_ptr fnp)
|
|||||||
return fnode_fd[fnp - fnode];
|
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);
|
sft FAR *sftp = idx_to_sft(fd);
|
||||||
UWORD flags;
|
UWORD flags;
|
||||||
|
|
||||||
fnp->f_count = sftp->sft_count;
|
if (FP_OFF(sftp) == (size_t) - 1)
|
||||||
|
return -1;
|
||||||
flags = sftp->sft_flags;
|
flags = sftp->sft_flags;
|
||||||
fnp->f_flags = (flags & SFT_FDATE) | ((flags & SFT_FDIRTY) ^ SFT_FDIRTY);
|
fnp->f_flags = (flags & SFT_FDATE) | ((flags & SFT_FDIRTY) ^ SFT_FDIRTY);
|
||||||
fnp->f_dir.dir_attrib = sftp->sft_attrib;
|
fnp->f_dir.dir_attrib = sftp->sft_attrib;
|
||||||
@ -2169,6 +2143,7 @@ STATIC void sft_to_fnode(f_node_ptr fnp, int fd)
|
|||||||
#else
|
#else
|
||||||
fnp->f_cluster_offset = sftp->sft_relclust;
|
fnp->f_cluster_offset = sftp->sft_relclust;
|
||||||
#endif
|
#endif
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the SFT fd into the first near fnode */
|
/* 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 */
|
/* If the fd was invalid because it was out of range or the */
|
||||||
/* requested file was not open, tell the caller and exit */
|
/* requested file was not open, tell the caller and exit */
|
||||||
/* note: an invalid fd is indicated by a 0 return */
|
/* 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);
|
fnode_fd[0] = fd;
|
||||||
if (fnode[0].f_count > 0)
|
return &fnode[0];
|
||||||
{
|
|
||||||
fnode_fd[0] = fd;
|
|
||||||
return &fnode[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,6 @@ VOID trim_path(BYTE FAR * s);
|
|||||||
|
|
||||||
int dos_cd(char * PathName);
|
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_fd(COUNT fd);
|
||||||
COUNT dos_getfattr(BYTE * name);
|
COUNT dos_getfattr(BYTE * name);
|
||||||
COUNT dos_setfattr(BYTE * name, UWORD attrp);
|
COUNT dos_setfattr(BYTE * name, UWORD attrp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user