Age | Commit message (Collapse) | Author |
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
Signed-off-by: Packet Please <pktpls@systemli.org>
|
|
Signed-off-by: Packet Please <pktpls@systemli.org>
|
|
Add full documentation coverage for the struct module by utilizing large
parts of the Python struct module documentation for the format string
description.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce a new debug library which provides introspection facilities
for debugging ucode scripts.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Get rid of most __APPLE__ guards by introducing a central platform.c unit
providing drop-in replacements for missing APIs.
Also move system signal definitions into the new platform file to be able
to share them with the upcoming debug library.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When the VM instance loading the uloop module has signal dispatching
enabled, implicitly register the signal pipe as file descriptor in the
global uloop and dispatch received signals to the VM instance.
This ensures that the respective managed ucode signal handlers are
invoked immediately and not just after `uloop_run()` returns.
Also end the uloop in case any invoked signal handler threw an
exception, to match the expected behaviour with other kinds of
callbacks.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Reportedly, automatic conversion of the `isatty()` int result value to
a bool does not work correctly on PPC. Explicitly compare the result
value with `1` to infer the boolean result value.
Fixes: #165
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
docs: various improvements
|
|
- Switch JSDoc theme to "clean-jsdoc-theme"
- Add some custom CSS and JS tweaks to the theme
- Use a condensed README.md for the toplevel directory
- Include a longer README.md in the documentation portal
- Tweak JSDoc annotations for better output results
- Register `ucode.mein.io` CNAME
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
fs: complete function documentation coverage
|
|
Use `fseeko()` and `ftello()` instead of `fseek()` and `ftell()`
respectively in order to be able to deal with large file offsets.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add missing function documentation and return value annotations.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add JSDoc documentation blocks to all exported filesystem functions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add JSDoc documentation blocks to all exported math functions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Useful for adding/removing interfaces
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
When converting ucode strings to blobmsg, use blobmsg_add_field in order to
explicltly pass the length of the data.
In the other direction, use ucv_string_new_length based on the attribute
length.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
It is unused and I couldn't find any purpose for it
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
A uci commit operation may invalidate the package pointer, leading to an
infinite loop while iterating the packages to commit.
Refactor the code to first build a string list of configurations, then
iterating it in order to avoid the iterator invalidation.
While we're at it, also allow restricting save and revert operations to
single configs, which was rejected as invalid before.
Fixes: #146
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes maintaining the listener array
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
Arguments stored in the registry need an extra reference
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
Arguments stored in the registry need an extra reference
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
This is the last attribute, adapt .nattr to include it so it gets
parsed.
Signed-off-by: Andre Heider <a.heider@gmail.com>
|
|
Similar to nl80211 uloop listener
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
nl80211: add support for registering an uloop based listener
|
|
The `pipe()` function takes no arguments and will return a two element
array containing open read- and write file descriptors for a newly
created pipe.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Can be used to capture nl80211 messages in an event driven program
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
- add missing overflow check
- make array size dynamic
- set all bits if command id is not specified
- add helper function for filling command bits
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
fs: add `isatty()` function
|
|
Expose the `isatty(3)` libc function in the fs module to allow checking
whether a file descriptor refers to a terminal.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
|
|
Signed-off-by: John Crispin <john@phrozen.org>
|
|
Expose the `realpath(3)` libc function in the fs module to allow for
canonicalizing file paths.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
math: add isnan() function
|
|
Add a new `isnan()` convenience function to the math library which can
be used to test if a given value is a NaN double.
The same test can be realized without the math library by using a function
similar to the following one:
function isNaN(x) {
return x != x;
}
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ensure that the main process uloop is terminated within task child
processes. Before this fix, using uloop in a task function would
trigger invalid memory accesses in the parent process by notifying
non-existing fd slots in the parent through the inherited shared
epoll descriptor.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Functions that use `uci_lookup_ptr()` internally, such as `ctx.get()`,
`ctx.set()` or `ctx.delete()`, implicitly load the given configuration
name while the higher level functions `ctx.foreach()` or `ctx.get_first()`
do not.
This behaviour violates the principle of least surprise and might lead to
non-deterministic program behavior as the outcome of these functions
depends on prior uci operations performed on the cursor.
Fix this issue by invoking `uci_load()` internally in case the given
uci package name cannot be found in the cursor's package cache.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When `fd.read()` is invoked with a single-character string argument,
invoke `getdelim()` internally to read the input until the give character
or EOF. This is useful for reading character delimited input data.
For example `fd.read('\n')` will read any data up to the first newline
(or EOF) while `fd.read('\0x00')` will read until the first null byte.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Use `getline()` instead of a custom `fgets()` wrapper logic to perform
line wise reads from open file handles. This is required to properly
deal with lines containing embedded null bytes.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Both input and output callbacks for uloop tasks are optional, but the
low level io callback implementation did not properly deal with an absent
ucode output callback, triggering an exception in managed code due to
invoking a null value as function.
Fix this issue by checking for the availability of a callable output
function and simply discarding the received task message otherwise.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Prevent GC'ing (and thus tearing down) an active ubus connection as long as
there's still unfinished deferred request contexts alive.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some ubus users require access to the original ubus error status returned
by various operations for fine grained error handling.
Extend the error() function with an optional boolean argument which causes
the function to return the numeric error code instead of a preformatted
message when invoked.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add constants for ubus status codes to the toplevel module scope in order
to avoid the need for magic values in the code.
Suggested-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The implicit return style for sending ubus method replies currently always
emits an UBUS_STATUS_NO_DATA code in case neither req.reply() was called,
nor a deferred or object were returned by the handler function.
This slightly complicates the implementation of handlers that do not wish
to send reply data but simply acknowledge the request with an
UBUS_STATUS_OK code.
In order to simplify this use case, allow handlers to override the default
status by treating integer return values as ubus error codes.
After this change, the following handler:
function (request) {
/* do some work */
request.reply(null, 0);
}
... can be rewritten as:
function (request) {
/* do some work */
return 0;
}
Suggested-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Rework the `fs.open()` implementation to accept an optional third file
permission argument which is applied to newly created files.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When building with gcc-10 and -O2, the following warning in ubus.c is
triggered during the compilation:
In function ‘uc_ubus_object_register’,
inlined from ‘uc_ubus_publish’ at .../ubus.c:1521:10:
.../ubus.c:1464:14: error: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
1464 | obj->name = strncpy(onptr, ubus_object_name, namelen);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../ubus.c: In function ‘uc_ubus_publish’:
.../ubus.c:1447:12: note: length computed here
1447 | namelen = strlen(ubus_object_name);
| ^~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Solve this issue by using memcpy() instead. We already take care of
allocating a zeroed, strlen() + 1 sized destination buffer so loosing
the `\0` byte of the source string is perfectly fine.
Fixes: #100
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some pecularities in the encoding of the IFLA_AF_SPEC attribute make it
unsuitable for table driven parsing/generation.
To solve this issue, introduce specific datatype handling for IFLA_AF_SPEC
and parse/generate the RTA depending on the address family of the containing
netlink message.
Also add some missing constants while we're at it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
ubus: end uloop on exceptions in managed code
|
|
Instead of silently continuing, end the uloop when encountering exceptions
in ucode callbacks to let those exceptions propagate to the host program.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|