[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

@@ -388,6 +388,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_efi_autoboot ( ERRFILE_OTHER | 0x00530000 )
#define ERRFILE_efi_autoexec ( ERRFILE_OTHER | 0x00540000 )
#define ERRFILE_efi_cachedhcp ( ERRFILE_OTHER | 0x00550000 )
#define ERRFILE_linux_sysfs ( ERRFILE_OTHER | 0x00560000 )
/** @} */

View File

@@ -46,6 +46,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <linux/ioctl.h>
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/stat.h>
#define MAP_FAILED ( ( void * ) -1 )
#endif
@@ -65,6 +66,8 @@ extern ssize_t __asmcall linux_read ( int fd, void *buf, size_t count );
extern ssize_t __asmcall linux_write ( int fd, const void *buf, size_t count );
extern int __asmcall linux_fcntl ( int fd, int cmd, ... );
extern int __asmcall linux_ioctl ( int fd, unsigned long request, ... );
extern int __asmcall linux_statx ( int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf );
extern int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds,
int timeout );
extern int __asmcall linux_nanosleep ( const struct timespec *req,

View File

@@ -0,0 +1,16 @@
#ifndef _IPXE_LINUX_SYSFS_H
#define _IPXE_LINUX_SYSFS_H
/** @file
*
* Linux sysfs files
*
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/uaccess.h>
extern int linux_sysfs_read ( const char *filename, userptr_t *data );
#endif /* _IPXE_LINUX_SYSFS_H */