Adapted from Chris Rodie's patch (bugzilla #1729):

"open" and "close" should call the open/close functions for devices using
a device request when appropriate.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@755 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-01-26 13:18:13 +00:00
parent 3d7d36cf91
commit a9c00dcf86
2 changed files with 30 additions and 3 deletions

View File

@ -123,6 +123,7 @@ typedef struct sfttbl {
/* the following bits are device (char) unique */ /* the following bits are device (char) unique */
#define SFT_FIOCTL 0x4000 /* IOCTL support - device */ #define SFT_FIOCTL 0x4000 /* IOCTL support - device */
#define SFT_FOCRM 0x0800 /* Open/Close/RM bit in device attribute*/
#define SFT_FEOF 0x0040 /* device eof */ #define SFT_FEOF 0x0040 /* device eof */
#define SFT_FBINARY 0x0020 /* device binary mode */ #define SFT_FBINARY 0x0020 /* device binary mode */
#define SFT_FSPECIAL 0x0010 /* int 29 support */ #define SFT_FSPECIAL 0x0010 /* int 29 support */

View File

@ -466,7 +466,7 @@ const char FAR *get_root(const char FAR * fname)
} }
/* initialize SFT fields (for open/creat) for character devices */ /* initialize SFT fields (for open/creat) for character devices */
STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) STATIC int DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp)
{ {
int i; int i;
@ -487,6 +487,17 @@ STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp)
sftp->sft_date = dos_getdate(); sftp->sft_date = dos_getdate();
sftp->sft_time = dos_gettime(); sftp->sft_time = dos_gettime();
sftp->sft_attrib = D_DEVICE; sftp->sft_attrib = D_DEVICE;
if (sftp->sft_dev->dh_attr & SFT_FOCRM)
{
/* if Open/Close/RM bit in driver's attribute is set
* then issue an Open request to the driver
*/
struct dhdr FAR *dev = sftp->sft_dev;
if (BinaryCharIO(&dev, 0, MK_FP(0x0000, 0x0000), C_OPEN) != SUCCESS)
return DE_ACCESS;
}
return SUCCESS;
} }
/* /*
@ -575,7 +586,12 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib)
/* check for a device */ /* check for a device */
if ((result & IS_DEVICE) && (dhp = IsDevice(fname)) != NULL) if ((result & IS_DEVICE) && (dhp = IsDevice(fname)) != NULL)
{ {
DeviceOpenSft(dhp, sftp); int rc = DeviceOpenSft(dhp, sftp);
/* check the status code returned by the
* driver when we tried to open it
*/
if (rc < SUCCESS)
return rc;
return sft_idx; return sft_idx;
} }
@ -738,8 +754,18 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly)
sftp->sft_count -= 1; sftp->sft_count -= 1;
if (sftp->sft_flags & SFT_FDEVICE) if (sftp->sft_flags & SFT_FDEVICE)
{
if (sftp->sft_dev->dh_attr & SFT_FOCRM)
{
/* if Open/Close/RM bit in driver's attribute is set
* then issue a Close request to the driver
*/
struct dhdr FAR *dev = sftp->sft_dev;
if (BinaryCharIO(&dev, 0, MK_FP(0x0000, 0x0000), C_CLOSE) != SUCCESS)
return DE_ACCESS;
}
return SUCCESS; return SUCCESS;
}
if (commitonly) if (commitonly)
return dos_commit(sftp->sft_status); return dos_commit(sftp->sft_status);