Eliminate dos_setfsize, dos_setftime, and dos_lseek, by just using the SFT.

dos_setfsize still needed to merge changes for SHARE so the call was replaced
by a new dos_merge_file_changes() call.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1405 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-05-26 20:44:44 +00:00
parent 76f1c10a4e
commit a0382d32e4
5 changed files with 27 additions and 118 deletions

View File

@ -318,11 +318,16 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode)
lpCurSft = s;
if (s->sft_flags & SFT_FSHARED)
/* Do special return for character devices */
if (s->sft_flags & SFT_FDEVICE)
{
s->sft_posit = 0l;
return SUCCESS;
}
/* seek from end of file */
if (mode == 2)
{
/* seek from end of file */
if (mode == 2)
{
/*
* RB list has it as Note:
* this function is called by the DOS 3.1+ kernel, but only when seeking
@ -333,42 +338,17 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode)
* Lredir via mfs.c from DosEMU works when writing appended files.
* Mfs.c looks for these mode bits set, so here is my best guess.;^)
*/
if (s->sft_mode & (O_DENYREAD | O_DENYNONE))
s->sft_posit = remote_lseek(s, new_pos);
else
s->sft_posit = s->sft_size + new_pos;
return SUCCESS;
}
if (mode == 0)
{
s->sft_posit = new_pos;
return SUCCESS;
}
if (mode == 1)
{
s->sft_posit += new_pos;
return SUCCESS;
}
return DE_INVLDFUNC;
}
/* Do special return for character devices */
if (s->sft_flags & SFT_FDEVICE)
{
s->sft_posit = 0l;
return SUCCESS;
}
else
{
LONG result = dos_lseek(sft_idx, new_pos, mode);
if (result < 0l)
return (int)result;
if ((s->sft_flags & SFT_FSHARED) &&
(s->sft_mode & (O_DENYREAD | O_DENYNONE)))
s->sft_posit = remote_lseek(s, new_pos);
else
{
s->sft_posit = result;
return SUCCESS;
}
s->sft_posit = s->sft_size + new_pos;
}
else if (mode == 0)
s->sft_posit = new_pos;
else /* mode == 1 */
s->sft_posit += new_pos;
return SUCCESS;
}
ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode)
@ -1156,11 +1136,7 @@ COUNT DosSetFtimeSft(int sft_idx, date dp, time tp)
s->sft_date = dp;
s->sft_time = tp;
if (s->sft_flags & SFT_FSHARED)
return SUCCESS;
/* call file system handler */
return dos_setftime(sft_idx, dp, tp);
return SUCCESS;
}
COUNT DosGetFattr(BYTE FAR * name)

View File

@ -241,7 +241,7 @@ BOOL dir_write_update(REG f_node_ptr fnp, BOOL update)
return FALSE;
/* Update the entry if it was modified by a write or create... */
if (fnp->f_flags & F_DMOD)
if (fnp->f_flags & (F_DMOD|F_DDATE))
{
bp = getblock(fnp->f_dirsector, fnp->f_dpb->dpb_unit);

View File

@ -438,6 +438,11 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect)
}
}
void dos_merge_file_changes(int fd)
{
merge_file_changes(sft_to_fnode(fd), FALSE);
}
/* /// Added - Ron Cemer */
STATIC int is_same_file(f_node_ptr fnp, sft FAR *sftp)
{
@ -813,43 +818,6 @@ time dos_gettime(void)
return time_encode(&dt);
}
/* */
/* dos_setftime for the file time */
/* */
COUNT dos_setftime(COUNT fd, date dp, time tp)
{
/* Translate the fd into an fnode pointer, since all internal */
/* operations are achieved through fnodes. */
f_node_ptr fnp = sft_to_fnode(fd);
/* Set the date and time from the fnode and return */
fnp->f_dir.dir_date = dp;
fnp->f_dir.dir_time = tp;
/* mark file as modified and set this date upon closing */
fnp->f_flags |= F_DMOD | F_DDATE;
fnode_to_sft(fnp);
return SUCCESS;
}
/* */
/* dos_setfsize for the file time */
/* */
BOOL dos_setfsize(COUNT fd, LONG size)
{
/* Translate the fd into an fnode pointer, since all internal */
/* operations are achieved through fnodes. */
f_node_ptr fnp = sft_to_fnode(fd);
/* Change the file size */
fnp->f_dir.dir_size = size;
merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */
fnode_to_sft(fnp);
return TRUE;
}
/* */
/* Find free cluster in disk FAT table */
/* */
@ -1656,39 +1624,6 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode)
return ret_cnt;
}
/* Position the file pointer to the desired offset */
/* Returns a long current offset or a negative error code */
LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin)
{
/* Translate the fd into a useful pointer */
REG f_node_ptr fnp = sft_to_fnode(fd);
/* now do the actual lseek adjustment to the file poitner */
switch (origin)
{
/* offset from beginning of file */
case 0:
fnp->f_offset = (ULONG) foffset;
break;
/* offset from current location */
case 1:
fnp->f_offset += foffset;
break;
/* offset from eof */
case 2:
fnp->f_offset = fnp->f_dir.dir_size + foffset;
break;
/* default to an invalid function */
default:
return (LONG) DE_INVLDFUNC;
}
fnode_to_sft(fnp);
return fnp->f_offset;
}
/* returns the number of unused clusters */
CLUSTER dos_free(struct dpb FAR * dpbp)
{

View File

@ -628,7 +628,7 @@ UBYTE FcbClose(xfcb FAR * lpXfcb)
/* change time and set file size */
s->sft_size = lpFcb->fcb_fsize;
if (!(s->sft_flags & SFT_FSHARED))
dos_setfsize(lpFcb->fcb_sftno, lpFcb->fcb_fsize);
dos_merge_file_changes(lpFcb->fcb_sftno);
DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time);
if ((CritErrCode = -DosCloseSft(lpFcb->fcb_sftno, FALSE)) == SUCCESS)
{

View File

@ -161,15 +161,12 @@ COUNT dos_rmdir(BYTE * path);
COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib);
date dos_getdate(void);
time dos_gettime(void);
COUNT dos_setftime(COUNT fd, date dp, time tp);
BOOL dos_setfsize(COUNT fd, LONG size);
COUNT dos_mkdir(BYTE * dir);
BOOL last_link(f_node_ptr fnp);
COUNT map_cluster(REG f_node_ptr fnp, COUNT mode);
long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode);
COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count);
COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count);
LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin);
CLUSTER dos_free(struct dpb FAR * dpbp);
BOOL dir_exists(char * path);
VOID dpb16to32(struct dpb FAR *dpbp);
@ -184,6 +181,7 @@ COUNT media_check(REG struct dpb FAR * dpbp);
f_node_ptr xlt_fd(COUNT fd);
COUNT xlt_fnp(f_node_ptr fnp);
struct dhdr FAR * select_unit(COUNT drive);
void dos_merge_file_changes(int fd);
/* fattab.c */
void read_fsinfo(struct dpb FAR * dpbp);