summaryrefslogtreecommitdiffstats
path: root/src/interface/linux/linux_sysfs.c
diff options
context:
space:
mode:
authorMichael Brown2021-03-03 01:34:02 +0100
committerMichael Brown2021-03-03 02:01:58 +0100
commit69ecab2634d3f5a825e0baaa310ba048d5aed3b5 (patch)
treee3a8a0415394c75e0ef679b83b4d7032f7df61fa /src/interface/linux/linux_sysfs.c
parent[linux] Use generic sysfs mechanism to read SMBIOS table (diff)
downloadipxe-69ecab2634d3f5a825e0baaa310ba048d5aed3b5.tar.gz
ipxe-69ecab2634d3f5a825e0baaa310ba048d5aed3b5.tar.xz
ipxe-69ecab2634d3f5a825e0baaa310ba048d5aed3b5.zip
[linux] Use fstat() rather than statx()
The statx() system call has a clean header file and a consistent layout, but was unfortunately added only in kernel 4.11. Using stat() or fstat() directly is extremely messy since glibc does not necessarily use the kernel native data structures. However, as the only current use case is to obtain the length of an open file, we can merely provide a wrapper that does precisely this. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/linux/linux_sysfs.c')
-rw-r--r--src/interface/linux/linux_sysfs.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/interface/linux/linux_sysfs.c b/src/interface/linux/linux_sysfs.c
index 0b9f1f5d9..463bc2ab9 100644
--- a/src/interface/linux/linux_sysfs.c
+++ b/src/interface/linux/linux_sysfs.c
@@ -40,7 +40,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
* @ret len Length read, or negative error
*/
int linux_sysfs_read ( const char *filename, userptr_t *data ) {
- struct statx statx;
size_t offset;
size_t len;
ssize_t read;
@@ -57,13 +56,12 @@ int linux_sysfs_read ( const char *filename, userptr_t *data ) {
}
/* Get file length */
- if ( linux_statx ( fd, "", AT_EMPTY_PATH, STATX_SIZE, &statx ) == -1 ) {
+ if ( linux_fstat_size ( fd, &len ) == -1 ) {
rc = -ELINUX ( linux_errno );
DBGC ( filename, "LINUX could not stat %s: %s\n",
filename, linux_strerror ( linux_errno ) );
goto err_stat;
}
- len = statx.stx_size;
/* Allocate buffer */
*data = umalloc ( len );