Skip to content

use of "errno" variable to indicate errors #4

@steverpalmer

Description

@steverpalmer

Firstly, thanks for this library. It looks like a good fit to my needs ... with perhaps one exception ...

You have obviously stuck to the libc/posix API, which is always a good starting point, but may be not in this case. I suggest that the libc interface includes some problems which have become apparent over time, but which libc can't break because of the massive impact it would have on existing code. In particular the use of the errno variable has become an increasing problem with multiple thread code. (See https://yarchive.net/comp/linux/errno.html). I might suggest that other libraries like littlefs (https://github.com/littlefs-project/littlefs) as an example of a library that has striven to break from the errno model. Might I gently suggest that there is some value is breaking the code into two parts: a low-level which does not use the errno variable, and a high-level wrapper which provides the more conventional libc interface?

Just a suggestion.

Cheers.

Background

I'm writing bare-metal code for a Pimoroni Pico Plus 2W (RPi Pico 2w but with 16MB Flash plus 8MB PSRAM). My code is running a Lua REPR loop in a little co-operative scheduler with a virtual file system. The VFS includes a ROMFS for various useful Lua libraries (e.g. Lust unit testing), and I am hoping to add an microSD card option and a ram file system. My aim is to be able to prototype application code in Lua on target with real sensors/actuators, before recording in C/Rust. Lua can also provide a useful framework for unit testing on target, or maybe for initial system configuration.

My "file system stack" looks something like:

Application (which mayor may not use Lua below. but may also make direct access to my VFS directory)
Lua
libc implemented by picolibc (https://github.com/picolibc/picolibc)
libgloss (handles mapping for to errno model from non-errno model below)
My Virtual File System (no errno)
| ROMFS | RamFS? | UART drivers | ...

Obviously, my use-case may not be your target audience, but I dare to suggest there are people who want a low-level ramfs library without errno.

Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions