📄 devio.c
字号:
/*
* EBS - RTFS (Real Time File Manager)
*
* Copyright EBS Inc. 1996
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*/
/* devio functions
*
*
*/
#include "pcdisk.h"
int card_failed_handler(int driveno) /* __fn__ */
{
int ret_val;
ret_val = critical_error_handler(driveno,CRERR_CARD_FAILURE, 0);
if (ret_val == CRITICAL_ERROR_ABORT)
{
/* Abort the current mount */
pc_dskfree((int)driveno);
}
return(ret_val);
}
BOOLEAN devio_read(int driveno, dword blockno, byte * buf, word n_to_read, BOOLEAN raw) /* __fn__ */
{
DDRIVE *pdr;
pdr = pc_drno_to_drive_struct(driveno);
while (1)
{
/* Check if disk is accessable and hasn't changed since mounted */
if (!(pdr->drive_flags & DRIVE_FLAGS_VALID))
return(FALSE);
if (!check_media_io(driveno, raw))
return(FALSE);
OS_CLAIM_DRIVE_IO(pdr->lock_unit)
if (pdr->drive_flags & DRIVE_FLAGS_PARTITIONED)
{
if (!raw)
blockno += pdr->partition_base;
}
if (pdr->dev_table_drive_io(driveno, blockno, buf, n_to_read, TRUE))
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
return(TRUE);
}
else
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
if (card_failed_handler(driveno) != CRITICAL_ERROR_RETRY)
break;
}
}
return(FALSE);
}
#if (RTFS_WRITE)
/* This is a special version of devio_write that is used by the format utility
It is the same as devio_write except that it does not automount the
drive or load the partition table. If non-raw IO is requested the
caller must first be sure that the partition table is loaded
*/
BOOLEAN devio_write_format(int driveno, dword blockno, byte * buf, word n_to_write, BOOLEAN raw) /* __fn__ */
{
DDRIVE *pdr;
pdr = pc_drno_to_drive_struct(driveno);
while (1)
{
/* Check if disk is accessable and hasn't changed since mounted */
if (!check_media_io(driveno, TRUE))
return(FALSE);
OS_CLAIM_DRIVE_IO(pdr->lock_unit)
if (pdr->drive_flags & DRIVE_FLAGS_PARTITIONED)
{
if (!raw)
blockno += pdr->partition_base;
}
if (pdr->dev_table_drive_io(driveno, blockno, buf, n_to_write, FALSE))
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
return(TRUE);
}
else
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
if (card_failed_handler(driveno) != CRITICAL_ERROR_RETRY)
break;
}
}
return(FALSE);
}
BOOLEAN devio_write(int driveno, dword blockno, byte * buf, word n_to_write, BOOLEAN raw) /* __fn__ */
{
DDRIVE *pdr;
pdr = pc_drno_to_drive_struct(driveno);
while (1)
{
/* Check if disk is accessable and hasn't changed since mounted */
if (!check_media_io(driveno, raw))
return(FALSE);
OS_CLAIM_DRIVE_IO(pdr->lock_unit)
if (pdr->drive_flags & DRIVE_FLAGS_PARTITIONED)
{
if (!raw)
blockno += pdr->partition_base;
}
if (pdr->dev_table_drive_io(driveno, blockno, buf, n_to_write, FALSE))
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
return(TRUE);
}
else
{
OS_RELEASE_DRIVE_IO(pdr->lock_unit)
if (card_failed_handler(driveno) != CRITICAL_ERROR_RETRY)
break;
}
}
return(FALSE);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -