[linux] Add a generic function for reading files from sysfs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2021-03-02 23:37:41 +00:00
parent 976839ae4c
commit 5c8a9905ce
5 changed files with 143 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <ipxe/linux_api.h>
#include <ipxe/slirp.h>
@@ -198,6 +199,20 @@ int __asmcall linux_ioctl ( int fd, unsigned long request, ... ) {
return ret;
}
/**
* Wrap statx()
*
*/
int __asmcall linux_statx ( int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf ) {
int ret;
ret = statx ( dirfd, pathname, flags, mask, statxbuf );
if ( ret == -1 )
linux_errno = errno;
return ret;
}
/**
* Wrap poll()
*
@@ -516,6 +531,7 @@ PROVIDE_IPXE_SYM ( linux_read );
PROVIDE_IPXE_SYM ( linux_write );
PROVIDE_IPXE_SYM ( linux_fcntl );
PROVIDE_IPXE_SYM ( linux_ioctl );
PROVIDE_IPXE_SYM ( linux_statx );
PROVIDE_IPXE_SYM ( linux_poll );
PROVIDE_IPXE_SYM ( linux_nanosleep );
PROVIDE_IPXE_SYM ( linux_usleep );