📄 read.c
字号:
/* $id:dmRead.c V1.0 2001/09/5 */
/******************************************************************************
* This source code has been made available to you by CORETEK on
* AS-IS.Anyone receiving this source is licensed under
* CORETEK copyrights to use it in any way he or she deems fit,including
* copying it,modifying it,compiling it,and redistributing it either with
* or without modifictions.
*
*
* Any person who transfers this source code or any derivative work must
* include the CORETEK copyright notice, this paragraph,and the preceding
* two paragraphs in the transferred software.
*
*
* COPYRIGHT CORETEK CORPORATION 2001
* LICENSED MATERIAL - PROGRAM PROPERTY OF CORETEK
*****************************************************************************/
/******************************************************************************
*
* FILE: Read.c
*
* MODULE: RTL
*
* PURPOSE: read() - POSIX 1003.1b 6.4.1 - Read From a File
*
* AUTHOR(S):Zhang Yumin
*
* GROUP:TOOL_GROUP
*
* DATE CREATED:2001/09/05
*
* REFERENCE DOCUMENT ID:
*
* MODIFICATIONS:
* Date user Name Description
* 2001/09/05 Zhang Yumin Create this file
*
*********************************************************************************/
#include <sys/types.h>
#include <sys/reent.h>
ssize_t sys_read(int fd, void* buffer, size_t count)
{
//实现read系统调用方法
}
/********************************************************************
* FUNCTION: read
*
* PURPOSE: Read() attempts to read nbytes of data from the object
* referenced by the descriptor fd into the buffer
* PARAMETERS:
*
* Input: fd -file descriptor of target file.
* count -the number of data in bytes.
* Output: buffer-data buffer.
* InOut: None
*
* Return value: If successful, the number of bytes actually read is returned.
* Upon reading end-of-file, zero is returned.Otherwise, a -1 is
* returned and the global variable errno is set to indicate the.
* error.
* Reentrant: Yes
********************************************************************/
ssize_t _read_r(
struct _reent *ptr,
int fd,
void *buffer,
size_t count
)
{
int rc = sys_read(fd,buffer,count);
if(rc < 0)
{
ptr->_errno = -rc;
return -1;
}
return rc;
}
#ifndef _REENT_ONLY
ssize_t read(
int fd,
void *buffer,
size_t count
)
{
return _read_r(_REENT,fd,buffer,count);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -