Let merge_file_changes operate directly on the other SFTs.
dos_setfattr with SHARE now closes open SFTs referring to that file in compat mode. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1403 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
386fc961e3
commit
4a81e6e9a2
@ -1211,12 +1211,12 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp)
|
|||||||
|
|
||||||
if (IsShareInstalled(TRUE))
|
if (IsShareInstalled(TRUE))
|
||||||
{
|
{
|
||||||
/* XXX SHARE should ideally close the file if it is opened in
|
/* SHARE closes the file if it is opened in
|
||||||
* compatibility mode, else generate a critical error.
|
* compatibility mode, else generate a critical error.
|
||||||
* Here just generate a critical error by opening in "rw compat"
|
* Here generate a critical error by opening in "rw compat" mode */
|
||||||
* mode */
|
|
||||||
if ((result = share_open_check(PriPathName, cu_psp, O_RDWR, 0)) < 0)
|
if ((result = share_open_check(PriPathName, cu_psp, O_RDWR, 0)) < 0)
|
||||||
return result;
|
return result;
|
||||||
|
/* else dos_setfattr will close the file */
|
||||||
share_close_file(result);
|
share_close_file(result);
|
||||||
}
|
}
|
||||||
return dos_setfattr(PriPathName, attrp);
|
return dos_setfattr(PriPathName, attrp);
|
||||||
|
@ -46,9 +46,8 @@ STATIC BOOL find_fname(f_node_ptr, char *, int);
|
|||||||
/* /// Added - Ron Cemer */
|
/* /// Added - Ron Cemer */
|
||||||
STATIC void merge_file_changes(f_node_ptr fnp, int collect);
|
STATIC void merge_file_changes(f_node_ptr fnp, int collect);
|
||||||
/* /// Added - Ron Cemer */
|
/* /// Added - Ron Cemer */
|
||||||
STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2);
|
STATIC int is_same_file(f_node_ptr fnp, sft FAR *sftp);
|
||||||
/* /// Added - Ron Cemer */
|
/* /// Added - Ron Cemer */
|
||||||
STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst);
|
|
||||||
STATIC BOOL find_free(f_node_ptr);
|
STATIC BOOL find_free(f_node_ptr);
|
||||||
STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname);
|
STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname);
|
||||||
STATIC VOID wipe_out(f_node_ptr);
|
STATIC VOID wipe_out(f_node_ptr);
|
||||||
@ -397,7 +396,7 @@ STATIC unsigned get_f_nodes_cnt(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* /// Added - Ron Cemer */
|
/* /// Added - Ron Cemer */
|
||||||
/* If more than one f_node has a file open, and a write
|
/* If more than one SFT has a file open, and a write
|
||||||
occurs, this function must be called to propagate the
|
occurs, this function must be called to propagate the
|
||||||
results of that write to the other f_nodes which have
|
results of that write to the other f_nodes which have
|
||||||
that file open. Note that this function only has an
|
that file open. Note that this function only has an
|
||||||
@ -407,7 +406,6 @@ STATIC unsigned get_f_nodes_cnt(void)
|
|||||||
unless these instances were generated by dup() or dup2(). */
|
unless these instances were generated by dup() or dup2(). */
|
||||||
STATIC void merge_file_changes(f_node_ptr fnp, int collect)
|
STATIC void merge_file_changes(f_node_ptr fnp, int collect)
|
||||||
{
|
{
|
||||||
f_node_ptr fnp2;
|
|
||||||
int i, fd;
|
int i, fd;
|
||||||
unsigned f_nodes_cnt;
|
unsigned f_nodes_cnt;
|
||||||
|
|
||||||
@ -415,19 +413,22 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fd = fnp->f_sft_idx;
|
fd = fnp->f_sft_idx;
|
||||||
fnp2 = &fnode[1];
|
|
||||||
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++)
|
||||||
{
|
{
|
||||||
if (i != fd && sft_to_fnode(fnp2, i) == SUCCESS && is_same_file(fnp, fnp2))
|
sft FAR *sftp = idx_to_sft(i);
|
||||||
|
if (i != fd && FP_OFF(sftp) != (size_t)-1 && is_same_file(fnp, sftp))
|
||||||
{
|
{
|
||||||
if (collect)
|
if (collect)
|
||||||
{
|
{
|
||||||
/* We're collecting file changes from any other
|
/* We're collecting file changes from any other
|
||||||
f_node which refers to this file. */
|
SFT which refers to this file. */
|
||||||
if (fnp2->f_mode != RDONLY)
|
if ((sftp->sft_mode & O_ACCMODE) != RDONLY)
|
||||||
{
|
{
|
||||||
copy_file_changes(fnp2, fnp);
|
setdstart(fnp->f_dpb, &fnp->f_dir, sftp->sft_stclust);
|
||||||
|
fnp->f_dir.dir_size = sftp->sft_size;
|
||||||
|
fnp->f_dir.dir_date = sftp->sft_date;
|
||||||
|
fnp->f_dir.dir_time = sftp->sft_time;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -436,36 +437,23 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect)
|
|||||||
/* We just made changes to this file, so we are
|
/* We just made changes to this file, so we are
|
||||||
distributing these changes to the other f_nodes
|
distributing these changes to the other f_nodes
|
||||||
which refer to this file. */
|
which refer to this file. */
|
||||||
copy_file_changes(fnp, fnp2);
|
sftp->sft_stclust = getdstart(fnp->f_dpb, &fnp->f_dir);
|
||||||
fnode_to_sft(fnp2, i);
|
sftp->sft_size = fnp->f_dir.dir_size;
|
||||||
|
sftp->sft_date = fnp->f_dir.dir_date;
|
||||||
|
sftp->sft_time = fnp->f_dir.dir_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /// Added - Ron Cemer */
|
/* /// Added - Ron Cemer */
|
||||||
STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2)
|
STATIC int is_same_file(f_node_ptr fnp, sft FAR *sftp)
|
||||||
{
|
{
|
||||||
return
|
return fnp->f_dpb == sftp->sft_dcb
|
||||||
(fnp1->f_dpb == fnp2->f_dpb)
|
&& (fnp->f_dir.dir_attrib & D_VOLID) == 0
|
||||||
&& (fcbmatch(fnp1->f_dir.dir_name, fnp2->f_dir.dir_name))
|
&& (sftp->sft_attrib & D_VOLID) == 0
|
||||||
&& ((fnp1->f_dir.dir_attrib & D_VOLID) == 0)
|
&& fnp->f_diridx == sftp->sft_diridx
|
||||||
&& ((fnp2->f_dir.dir_attrib & D_VOLID) == 0)
|
&& fnp->f_dirsector == sftp->sft_dirsector;
|
||||||
&& (fnp1->f_diridx == fnp2->f_diridx)
|
|
||||||
&& (fnp1->f_dirsector == fnp2->f_dirsector);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* /// Added - Ron Cemer */
|
|
||||||
STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst)
|
|
||||||
{
|
|
||||||
dst->f_dir.dir_start = src->f_dir.dir_start;
|
|
||||||
#ifdef WITHFAT32
|
|
||||||
dst->f_dir.dir_start_high = src->f_dir.dir_start_high;
|
|
||||||
#endif
|
|
||||||
dst->f_dir.dir_size = src->f_dir.dir_size;
|
|
||||||
dst->f_dir.dir_date = src->f_dir.dir_date;
|
|
||||||
dst->f_dir.dir_time = src->f_dir.dir_time;
|
|
||||||
dst->f_dir.dir_attrib = src->f_dir.dir_attrib;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC COUNT delete_dir_entry(f_node_ptr fnp)
|
STATIC COUNT delete_dir_entry(f_node_ptr fnp)
|
||||||
@ -1843,8 +1831,21 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp)
|
|||||||
fnp->f_dir.dir_attrib |= attrp; /* JPP */
|
fnp->f_dir.dir_attrib |= attrp; /* JPP */
|
||||||
fnp->f_flags |= F_DMOD | F_DDATE;
|
fnp->f_flags |= F_DMOD | F_DDATE;
|
||||||
|
|
||||||
/* should really close the file instead of merge */
|
/* close open files in compat mode, otherwise there was a critical error */
|
||||||
merge_file_changes(fnp, FALSE);
|
if (IsShareInstalled(FALSE)) {
|
||||||
|
int f_nodes_cnt = get_f_nodes_cnt();
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < f_nodes_cnt; i++)
|
||||||
|
{
|
||||||
|
sft FAR *sftp = idx_to_sft(i);
|
||||||
|
if (FP_OFF(sftp) != (size_t)-1 && is_same_file(fnp, sftp)) {
|
||||||
|
int rc = DosCloseSft(i, FALSE);
|
||||||
|
if (rc != SUCCESS)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dir_write(fnp);
|
dir_write(fnp);
|
||||||
dir_close(fnp);
|
dir_close(fnp);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user