Commit Graph

5 Commits (9e1cc9a9d30898f815c3ea0e914c7bf28e5fe5de)

Author SHA1 Message Date
Oleksij Rempel 4855df9af7 isobusfs: fix directory read and seek semantics to match ISO 11783-13
According to ISO 11783-13:2021 (sections C.3.4.2 and C.3.5.2), 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.

Previously, the implementation treated directories strictly as files,
using byte-based offsets and counts. This resulted in incorrect seeking
behavior and protocol violations when listing directories.

This patch aligns the implementation with the standard by:

1. Server side:
   - Introducing `isobusfs_srv_dir_entry_visible()` to consistently
     filter out invalid (unreadable, hidden, oversized) entries. This
     ensures that entry indices remain stable.
   - Implementing `isobusfs_srv_dir_skip_entries()` to advance the
     directory stream by logical visible entries rather than bytes.
   - Updating the "Read File" handler to interpret `count` as the
     maximum number of entries and return the number of entries read
     in the response header.
   - Updating the "Seek File" handler to seek by entry index.

2. Client side:
   - Calculating the request count based on the number of minimal-size
     entries that fit into the maximum data length.
   - Interpreting 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-01-13 19:13:20 +01:00
Oleksij Rempel cdc00bacf0 isobusfs: treat interactive exit as control flow, not error
Stop using -EINTR for cmd_exit(). Introduce ISOBUSFS_CLI_RET_EXIT and
map it to exit code 0 in main(), keeping errno values for real errors.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2026-01-13 19:13:20 +01:00
Yegor Yefremov 72a9fd8ccd isobusfs: fix typos
Typos were found with codespell.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2025-03-02 15:44:40 +01:00
Oleksij Rempel 939e4d7e8c isobusfs: change license to LGPL-2.0-only
Before more contributions will come, change the license and make this
project usable as a library.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2024-02-04 19:15:25 +01:00
Oleksij Rempel 42edaeaf52 Implement ISOBUS File Server (FS) Interface as a Personal Project
Introduce the ISOBUS File Server (FS) interface, compatible with ISO
11783-13. The implementation utilizes the kernel's existing CAN J1939
socket support.

For testing following setup can be used:
ip link add type vcan
ip l s dev vcan0 up

j1939acd -r 64-95 -c /tmp/1122334455667788.jacd 1122334455667788 vcan0 &
j1939acd -r 96-127 -c /tmp/1122334455667789.jacd 1122334455667789 vcan0 &

sleep 1

isobusfs-srv -i vcan0 -n 1122334455667788 -v vol1:/path/to/export/
isobusfs-cli -i vcan0 -n 0x1122334455667789 -m 0x1122334455667788 -I

Interactive mode currently support following commands:
exit - exit interactive mode
quit - exit interactive mode
help - show this help
dmesg - show log buffer
selftest - run selftest
ls - list directory
ll - list directory with long listing format
cd - change directory
pwd - print name of current/working directory
get - get file

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2024-02-02 13:44:07 +01:00