[PATCH] Support regular file type in _swistat for ARM
Previously, the implementation of _swistat() for ARM assumed all files
to be of type character device. This change adds support for stat-ing
regular files. Tested with arm-none-eabi
libgloss/arm/syscalls.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
On 04/06/2020 10:53, Joe Ramsay wrote:
> Previously, the implementation of _swistat() for ARM assumed all files
> to be of type character device. This change adds support for stat-ing
> regular files. Tested with arm-none-eabi
Firstly, there's a second version of this function, in
newlib/sysdeps/arm; the two really need to be kept in sync.
Unfortunately, there have been other cases where this hasn't happened,
so things are getting a bit messy now....
I don't think you should make the second SWI call if the first one
failed, so you should bail out immediately on failure. Also, checkerror
already calls error, so it is redundant to call it a second time.
I'm not sure the logic of that is right, even though in practice the
only possible results are 0, 1 and -1. error() should only be called if
isCharDevice is -1, since otherwise the errno will be set to something
meaningless, but see above, this needs to be done earlier.