We have quite a bit of tricky udev and device tree parsing code that is
only tested manually. Best case we would have tests for this in QEMU,
but until we do, let's test it with loop devices:
The downside is that we can only test block devices and that we need
a tiny bit of code that's not used
Even if /run exists, it may not be world-writable. This is the case on
NixOS. Add an alternative option to lock the device node instead.
This should eventually be made the default when it has enjoyed more
testing.
Signed-off-by: Ahmad Fatoum
---
configure.ac | 9 +
This adds experimental support for building dt-utils with meson. The
hope is that the alternative meson.build will be easier to maintain.
Signed-off-by: Ahmad Fatoum
---
.gitignore| 1 +
README| 20 ++
check-news.sh | 82
meson.build
It's straight forward to use meson as test runner, so let's compile a
very simple test application that links against libdt-utils and verifies
crc32 behaves as one would expect.
Signed-off-by: Ahmad Fatoum
---
README | 1 +
meson.build | 2 ++
test/crc32.c | 18
There's certainly more unit tests to be had, but the biggest ROI is
probably feeding barebox-state device trees and verifying that they
work. This same use case exists with RAUC too, where sharness (shell
test harness) is used to test the rauc executable. Let's import it from
there and follow the
The barebox,state binding is quite complex and we have a lot of udev
parsing code that can only be exercised by manually running
barebox-state on the target. Make development less error prone, by
adding tests for the block device bindings. EEPROM and MTD can
follow later.
Tests are executed by
Linux doesn't parse MTD fixed-partitions described in the device tree
for block devices and EEPROMs. For block devices, The dt-utils work around
this by doing the lookup in userspace and then arrive at the parent block
device along with an offset that is passed along. We can do better
though: If
As part of barebox-state by GPT partition type GUID lookup support,
state code in barebox needs direct interaction with the cdev, so it can
enumerate the child partitions. We have recently added __of_cdev_find
with internal linkage, so lets export of_cdev_find with external linkage
for outside
We will need to parse two more sysattrs in a follow-up patch, so factor
this out for reuse. While at it switch to 64-bit strtoull: This may
be more useful for future users and unlike atol doesn't invoke undefined
behavior when parsing fails.
Signed-off-by: Ahmad Fatoum
---
src/libdt.c | 42
This implements the binding extension introduced to barebox here:
https://lore.barebox.org/barebox/20230531145927.1399282-1-a.fat...@pengutronix.de/T/#t
With this, barebox,state backend can optionally point at a device
instead of a partition. If this device is GPT-partitioned and has
a partition
The backend device tree property so far always pointed at a partition.
Let's allow pointing it at GPT storage devices directly and lookup
the correct barebox state partition by the well-known type GUID:
4778ed65-bf42-45fa-9c5b-287a1dc4aab1
The implementation is not as neat as hoped for,
of_get_devicepath is an exported symbol by libdt, so we shouldn't change
its signature or its semantics. Yet, we will want to export more
information out of the udev'ification code in future. already
declares an opaque struct cdev, so let's add a __of_cdev_find helper
that can populate it with
We unconditionally open the device backing a direct bucket in read-write
mode. The barebox_state utility already populates struct
state_backend_storage::readonly though, which we could consult at device
open time. Do so. This could possibly be done for MTD as well, but until
that's tested, for
With the addition of of_find_device_by_uuid as part of the support for
barebox,storage-by-uuid, we don't need to rely on the device symlinks
created by 60-persistent-storage.rules and instead can just use libudev
directly, which we do elsewhere anyway. This has the added benefit
that we unify with
device_find_block_device returns 0 on success, so the way the else if
clause is now, only if there is a block device, the code falls through.
If there is none, a 0 is returned, but devpath is not populated breaking
the contract of the function. Just drop the branch for now and add back
it later in
Hello Michael,
On 11.05.22 10:21, Michael Olbrich wrote:
> Signed-off-by: Michael Olbrich
Tested-by: Ahmad Fatoum
I'd squash the two fixups I just sent when I apply this.
Thanks,
Ahmad
> ---
>
> changes in v3:
> uuid comparison fixed:
> - compare the correct uuids
> - don't crash when no
property may not be always defined. So let's skip trying to do something
with it in that case.
Signed-off-by: Ahmad Fatoum
---
src/libdt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libdt.c b/src/libdt.c
index 302ca7a76375..ca0502ac9483 100644
--- a/src/libdt.c
+++ b/src/libdt.c
These variables were recently added, but are unused. Drop them.
Signed-off-by: Ahmad Fatoum
---
src/libdt.c | 7 ++-
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/libdt.c b/src/libdt.c
index 44491a5e739b..302ca7a76375 100644
--- a/src/libdt.c
+++ b/src/libdt.c
@@ -2365,7
Despite the name, GCC objects at the strncpy use in safe_strncpy on
safety grounds. While that seems to be a false positive, we could
just be using memcpy instead and side step this altogether.
Signed-off-by: Ahmad Fatoum
---
src/dt/common.h | 34 ++
1 file
Increasing the warning level has GCC warn us, so let's heed the warning.
Signed-off-by: Ahmad Fatoum
---
src/dt/common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dt/common.h b/src/dt/common.h
index 69a264cfc1a9..62776c0bb027 100644
--- a/src/dt/common.h
+++
Like the Linux kernel, barebox is built with -fno-strict-aliasing, and
code is written to take advantage of that. As dt-utils imports code from
barebox, we may import code that assumes aliasing to be non-strict, so
we better compile it with the same rules.
Signed-off-by: Ahmad Fatoum
---
When increasing warning level, we see that of_find_device_by_node_path
lacks a prototype despite having external linkage and being exported
in the symbols file. On the other hand, scan_proc_dir has external
linkage, but is only ever needed internally, so let's give it internal
linkage.
blob_bin is freed a few lines above unconditionally, so freeing it
again in the error path will cause a double free.
Signed-off-by: Ahmad Fatoum
---
src/keystore-blob.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/keystore-blob.c b/src/keystore-blob.c
index
23 matches
Mail list logo