Commit Graph

1285 Commits (61eb881dc92ffc3ba9d05d8b77532eabd6278eee)

Author SHA1 Message Date
Oleksij Rempel 61eb881dc9 isobusfs: fix directory read and seek semantics to match ISO 11783-13
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>
2026-05-22 19:55:38 +02:00
Oleksij Rempel a5bd791999 isobusfs: treat interactive exit as control flow, not error
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>
2026-05-22 19:55:37 +02:00
Oleksij Rempel 5a681968a2 isobusfs: selftest: Handle read requests larger than file size
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>
2026-05-22 19:55:35 +02:00
Oleksij Rempel 95aae6bf83
Merge pull request #626 from SamantazFox/patch-1
J1939: VP1/VP2 PG fixes
2026-05-12 15:48:35 +02:00
Oleksij Rempel bf5fe736c3 canlogserver: fix infinite loops during signal handling
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>
2026-05-12 10:22:48 +02:00
Marc Kleine-Budde 14245b7c79
Merge pull request #627 from SamantazFox/patch-2
J1939: Handle localtime_r() failure in TD PG
2026-05-11 10:16:48 +02:00
Samantaz Fox 90383a0cca
Fill unassigned bytes with 0xFF in J1939 VP2 2026-05-08 17:18:03 +02:00
Samantaz Fox d5cb91c8ea
Handle localtime_r() failure in j1939 timedate
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.
2026-05-08 17:00:31 +02:00
Samantaz Fox 9743a2ffcf
Add j1939 VP2 details
Add 3 missing unused bytes (for a message len of 8) to the j1939 VP2 struct, as well as range information for the existing parameters.
2026-05-05 20:56:39 +00:00
Samantaz Fox d5ed23583c
Update j1939 VP1 parameters ranges
Lat/longitude parameters have a range of -210 to +211.1081215
2026-05-05 20:48:33 +00:00
Samantaz Fox 60301896d1
Update j1939 VP1 repetition rate
Since J1939DA:SEP2015, the repetition rate of VP1 has been changed to 1s.
2026-05-05 20:44:47 +00:00
Marc Kleine-Budde 99ab67143a
Merge pull request #625 from marckleinebudde/bcmserver-fix-buffer-overflow
bcmserver: fix buffer overflow
2026-03-10 10:58:56 +01:00
Marc Kleine-Budde a0aeaed234 bcmserver: main(): rxmsg: increase buffer size to hold long network interface names
Message-ID: <DM6PR17MB28748DA25E52E1BD3EC593E6937AA@DM6PR17MB2874.namprd17.prod.outlook.com>
2026-03-10 10:46:12 +01:00
Marc Kleine-Budde 3cae8a449b bcmserver: main(): convert from sprintf() to snprintf() to avoid buffer overflow
Message-ID: <DM6PR17MB28748DA25E52E1BD3EC593E6937AA@DM6PR17MB2874.namprd17.prod.outlook.com>
2026-03-10 10:46:11 +01:00
Marc Kleine-Budde 44e6eb45e3
Merge pull request #624 from marckleinebudde/canerrsim-fix-buffer-overflow
canerrsim: main(): avoid buffer overflow: check length of interface name
2026-03-09 12:27:28 +01:00
Marc Kleine-Budde 9e444073b1 canerrsim: main(): avoid buffer overflow: check length of interface name
Closes: https://github.com/linux-can/can-utils/issues/623
2026-03-09 12:23:29 +01:00
Marc Kleine-Budde 9d4f3c82a2 canerrsim: add missing \n at end of error messages 2026-03-09 12:21:33 +01:00
Marc Kleine-Budde 7e8e247b2f canerrsim: convert from show_custom_format_and_exit() to err_exit() 2026-03-09 12:20:50 +01:00
Marc Kleine-Budde 3fe1c42bbf canerrsim: err_exit(): add support for printf style formats 2026-03-09 12:18:10 +01:00
Marc Kleine-Budde 1520ab5b98
Merge pull request #620 from marckleinebudde/mcp251xfd-fix-strchr
mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of `strchr()` to `char *`
2026-03-04 11:38:43 +01:00
Marc Kleine-Budde aa902ae2af mcp251xfd: mcp251xfd_regmap_read(): don't assign return value of strchr() to `char *`
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
2026-03-04 11:35:38 +01:00
Marc Kleine-Budde a0b592178e
Merge pull request #621 from marckleinebudde/remove-mips
github-actions: remove mips for now

Closes: https://github.com/linux-can/can-utils/issues/611
2026-03-04 11:34:12 +01:00
Marc Kleine-Budde 4f2fdecfba github-actions: remove mips for now
It's being phased out on Ubuntu rolling release.
2026-03-04 11:30:14 +01:00
Marc Kleine-Budde cbbe4b41ea
Merge pull request #616 from pastalian/cmake-compat
cmake: set policy version to 3.10
2026-01-19 09:49:51 +01:00
Takuya Wakazono 2da0c7e95e cmake: set policy version to 3.10
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.
```
2026-01-19 15:37:11 +09:00
Marc Kleine-Budde 1f038b3cd8
Merge pull request #614 from hartkopp/master
canxl extension: use plain union instead of typedef
2025-12-18 19:26:31 +01:00
Oliver Hartkopp 392ccc970b canxl extension: use plain union instead of typedef
"In general, a pointer, or a struct that has elements that can reasonably
be directly accessed should never be a typedef."

https://www.kernel.org/doc/html/v5.0/process/coding-style.html#typedefs

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-18 18:23:38 +01:00
Oliver Hartkopp 7939678070 can-utils: unify indention
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-13 10:38:15 +01:00
Marc Kleine-Budde 88a0417a6b
Merge pull request #609 from dphipps-qnx/fix_cmsg_types
candump: Use SCM_* consts instead of SO_* for cmsg_type
2025-12-05 16:26:30 +01:00
Darcy Phipps 65e715d56d candump: Use SCM_* consts instead of SO_* for cmsg_type
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.
2025-12-05 09:35:50 -05:00
Oliver Hartkopp 374fecde09 cangen: disable generation of unsupported CAN frame types in mixed mode
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>
2025-12-03 16:09:12 +01:00
Oliver Hartkopp bfbf0c851f cangen: auto enable FD/XL content in mixed mode
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>
2025-12-03 16:09:12 +01:00
Oliver Hartkopp ed7822c9a2 candump: print CAN XL specific flags as extra message infos
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>
2025-11-26 19:04:50 +01:00
Marc Kleine-Budde e9ea9d1168
Merge pull request #607 from marckleinebudde/cansend-fix-typo
cansend: fix typo in CANFD_FDF flag name
2025-11-07 12:55:39 +01:00
Marc Kleine-Budde 2d793d38d2 cansend: fix typo in CANFD_FDF flag name
Closes: https://github.com/linux-can/can-utils/issues/606
Fixes: 3e0e6ae3a4 ("cansend: print canfd_frame.flags in help text")
2025-11-07 12:51:19 +01:00
Marc Kleine-Budde 340a3b8c92
Merge pull request #605 from marckleinebudde/lib_h-selfcontained
lib.h: include linux/can.h
2025-11-07 12:34:08 +01:00
Marc Kleine-Budde 8838ce80fc
Merge pull request #604 from marckleinebudde/cansend-canfd-flags
cansend: print canfd_frame.flags in help text
2025-11-07 12:33:02 +01:00
Marc Kleine-Budde d6c57240ed lib.h: include linux/can.h
Make lib.h self contained, so that language servers can parse it without
errors.
2025-11-07 12:30:15 +01:00
Marc Kleine-Budde 3e0e6ae3a4 cansend: print canfd_frame.flags in help text 2025-11-07 12:05:04 +01:00
Oliver Hartkopp 8bf5f8873f Fix optional nanosecond timestamp
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>
2025-09-03 12:55:26 +02:00
Rikus Wessels 0094905376 Fix possible sscanf buffer overflow 2025-09-03 12:42:51 +02:00
Rikus Wessels 987bc8aac2
Optional nanosecond timestamp logging (#592)
* Optional nanosecond timestamp logging

* Removed limited string reading
2025-09-03 11:11:47 +02:00
Oliver Hartkopp 6b46063eee cangen: add CAN XL RRS bit generation
Allow to generate Remote Request Substitution bit content.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-06-24 19:48:14 +02:00
Marc Kleine-Budde 93a7b2dfd3
Merge pull request #596 from inomotech-foss/master
Allow more fine-grained control over CMake targets
2025-05-22 10:22:19 +02:00
Simon Berger af09afb734
Update CMakeLists.txt
Co-authored-by: Marc Kleine-Budde <mkl@blackshift.org>
2025-05-22 10:14:39 +02:00
Simon Berger 69efecc428
Allow more fine-grained control over CMake targets 2025-05-21 16:40:24 +00:00
Marc Kleine-Budde 3698814740
Merge pull request #595 from marckleinebudde/can-calc-bittiming-more-data-bitrates
can-calc-bit-timing: common_data_bitrates: add some slower bitrates
2025-05-03 15:02:56 +02:00
Marc Kleine-Budde 6ed0f0ea7f can-calc-bit-timing: common_data_bitrates: add some slower bitrates
There are real world use cases for CAN-FD data bitrates below 1
MBit/s. Add some to the common_data_bitrates array.

Link: https://lore.kernel.org/79BCE02A-D4EC-4362-B0D3-3FE76FB17B78@vpprocess.com
2025-05-03 14:53:54 +02:00
Marc Kleine-Budde 287469245c
Merge pull request #123 from twasilczyk/slcand-android
Don't fail when it wasn't possible to fetch the interface name.
2025-04-06 10:11:38 +02:00
Tomasz Wasilczyk 7a318636e7 slcand: Don't fail when it wasn't possible to fetch the interface name.
On some systems SIOCGIFNAME may fail with ENOTTY, but the actual
slcanX interface gets properly configured. Instead of crashing hard on
such case, let's gracefuly degrade and just not display the interface
name.
2025-04-06 10:03:36 +02:00