Added POSIX-style blocking I/O calls, for use by PXE TFTP API.

This commit is contained in:
Michael Brown
2007-05-18 14:19:22 +00:00
parent 6b6fc1d5ea
commit 86a948ccbe
2 changed files with 363 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#ifndef _GPXE_POSIX_IO_H
#define _GPXE_POSIX_IO_H
/** @file
*
* POSIX-like I/O
*
*/
#include <stdint.h>
#include <gpxe/uaccess.h>
extern int open ( const char *uri_string );
extern ssize_t read_user ( int fd, userptr_t buffer,
off_t offset, size_t len );
extern ssize_t fsize ( int fd );
extern int close ( int fd );
/**
* Read data from file
*
* @v fd File descriptor
* @v buf Data buffer
* @v len Maximum length to read
* @ret len Actual length read, or negative error number
*/
static inline ssize_t read ( int fd, void *buf, size_t len ) {
return read_user ( fd, virt_to_user ( buf ), 0, len );
}
#endif /* _GPXE_POSIX_IO_H */