Fix directory operations to comply with ISO 11783-13:2021 (sections
C.3.4.2 and C.3.5.2), which specifies that directory operations differ
significantly from standard file operations:
- The Count parameter in a Read File request represents the number of
directory entries to read, not the number of bytes.
- The Offset parameter in a Seek File request represents the logical
entry index, not a byte offset.
The previous implementation treated directories strictly as files,
using byte-based offsets and counts. This resulted in incorrect seeking
behavior and protocol violations when listing directories.
Align the implementation with the standard by:
1. Server side:
- Introduce isobusfs_srv_dir_entry_visible() to consistently
filter out invalid (unreadable, hidden, oversized) entries. This
ensures that entry indices remain stable.
- Implement isobusfs_srv_dir_skip_entries() to advance the
directory stream by logical visible entries rather than bytes.
- Update the Read File handler to interpret count as the
maximum number of entries and return the number of entries read
in the response header.
- Update the Seek File handler to seek by entry index.
2. Client side:
- Calculate the request count based on the number of minimal-size
entries that fit into the maximum data length.
- Interpret the response count as the number of entries received
rather than the byte length of the payload.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
The cmd_exit() function used -EINTR to signal a clean exit from the
interactive mode. This is semantically incorrect because EINTR is an
errno value meant for system call interruptions, not application-level
control flow.
Stop using -EINTR for cmd_exit(). Introduce ISOBUSFS_CLI_RET_EXIT (a
positive return code) to distinguish control flow from actual errors.
Map this to exit code 0 in main(), keeping negative errno values for
real errors. This makes the exit path explicit and prevents confusion
with actual interrupted system calls.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Add expected_size field to test patterns to properly validate cases
where the requested read size exceeds the actual file size. This allows
testing the server's behavior when clients request more data than is
available.
When a read request is larger than the file, the server correctly
returns data up to EOF. The test framework now distinguishes between
this expected scenario and genuine read failures.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Fix infinite loops that prevent graceful termination when the server
receives SIGINT or SIGTERM signals. Without this fix, Ctrl-C and kill
commands are ignored, making it impossible to stop the server cleanly.
Two scenarios cause the infinite loops:
1) The bind() retry loop: When the port is busy, the loop retries
indefinitely without checking the running flag set by the signal
handler.
2) The accept() loop: The loop is unconditional, so when accept() is
interrupted by a signal and returns EINTR, the loop immediately
restarts, ignoring the shutdown request.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
When the call to localtime_r() fails (by returning NULL, as per the POSIX specification), make sure to fill the hour/minute offsets with the fallback values as specified in the J1939DA supporting information.
The `file_path` of `strchr(file_path, '/')` is a `const char *`. In this
case the `strchr()` in debian experimental returns a `const char *`,
leading to this error message:
```
mcp251xfd/mcp251xfd-regmap.c:75:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
75 | tmp = strchr(file_path, '/');
| ^
```
Fix the error by using the return value from `strchr()` directly in the
`if()`.
Link: https://github.com/linux-can/can-utils/actions/runs/22649777324/job/65679726209?pr=619
This project does not rely on any behavior from CMake <3.10, and
compatibility with CMake <3.10 is expected to be removed in future
releases.
https://cmake.org/cmake/help/v4.0/manual/cmake-policies.7.html#policies-introduced-by-cmake-3-10
```
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
```
There are explicit #defines for SCM_TIMESTAMP and SCM_TIMESTAMPING. They
currently happen to have the same value as SO_TIMESTAMP and
SO_TIMESTAMPING but the former should be used when checking cmsg_type in
case one day they do not.
The mixed mode is able to automatically detect the potential supported
CAN frame types CAN CC/FD/XL by checking the CAN device MTU at startup.
Usually the MTU shows which CAN frame types can be sent but in the case of
CAN XL in CANXL-only mode CC and FD frames can not be sent on the CAN_RAW
socket.
Since this patch [1] the CAN_RAW socket rejects unsupported CAN frames and
returns -EINVAL as error code. With this change in cangen the CC and FD
frame generation can be disabled in mixed mode at runtime.
[1] https://lore.kernel.org/linux-can/20251125123859.3924-17-socketcan@hartkopp.net/T/#u
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Automatically create FD/XL content in mixed mode when the CAN interface
is capable to deal with it.
Suggested-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
The extra message infos BRS and ESI have been printed when enabled with
the '-x' option. Since CAN XL has similar flags (SEC and RRS) those flags
have been wrongly printed as CAN FD flags.
This patch introduces separate flags for the CAN XL frames and prints them
when a CAN XL frame is processed.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
The extension of the timestamp size is missing in log2asc.c and canplayer.c
Fixes: 987bc8aac2 ("Optional nanosecond timestamp logging")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>