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:
parent
3d7d36cf91
commit
a9c00dcf86
@ -123,6 +123,7 @@ typedef struct sfttbl {
|
||||
|
||||
/* the following bits are device (char) unique */
|
||||
#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_FBINARY 0x0020 /* device binary mode */
|
||||
#define SFT_FSPECIAL 0x0010 /* int 29 support */
|
||||
|
@ -466,7 +466,7 @@ const char FAR *get_root(const char FAR * fname)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
@ -487,6 +487,17 @@ STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp)
|
||||
sftp->sft_date = dos_getdate();
|
||||
sftp->sft_time = dos_gettime();
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
||||
@ -738,8 +754,18 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly)
|
||||
sftp->sft_count -= 1;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
if (commitonly)
|
||||
return dos_commit(sftp->sft_status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user