[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>
This commit is contained in:
@@ -200,14 +200,15 @@ int __asmcall linux_ioctl ( int fd, unsigned long request, ... ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap statx()
|
||||
* Wrap part of fstat()
|
||||
*
|
||||
*/
|
||||
int __asmcall linux_statx ( int dirfd, const char *pathname, int flags,
|
||||
unsigned int mask, struct statx *statxbuf ) {
|
||||
int __asmcall linux_fstat_size ( int fd, size_t *size ) {
|
||||
struct stat stat;
|
||||
int ret;
|
||||
|
||||
ret = statx ( dirfd, pathname, flags, mask, statxbuf );
|
||||
ret = fstat ( fd, &stat );
|
||||
*size = stat.st_size;
|
||||
if ( ret == -1 )
|
||||
linux_errno = errno;
|
||||
return ret;
|
||||
@@ -531,7 +532,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_fstat_size );
|
||||
PROVIDE_IPXE_SYM ( linux_poll );
|
||||
PROVIDE_IPXE_SYM ( linux_nanosleep );
|
||||
PROVIDE_IPXE_SYM ( linux_usleep );
|
||||
|
||||
Reference in New Issue
Block a user