Move part of isobusfs which can be reused by other applications to the
libj1939. By the way, reuse some of new libj1939 code in the j1939cat.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Modify the isobusfs_log function in isobusfs_cmn.c to explicitly limit
the lengths of the time_buffer, level_str, and log_entry strings in
the snprintf format string to 40, 10, and 150 characters respectively.
This change acknowledges that truncation may still occur, but it is now
explicit and controlled.
This change silences the following warning:
cmake -DCMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=gcc -B build
cmake --build build
/home/isobusfs/isobusfs_cmn.c: In function 'isobusfs_log':
/home/isobusfs/isobusfs_cmn.c:104:30: warning: '%s' directive output
may be truncated writing up to 191 bytes into a region of size between
182 and 245 [-Wformat-truncation=]
104 | "[%s] [%s]: %s", time_buffer, level_str, log_entry);
| ^~ ~~~~~~~~~
/home/isobusfs/isobusfs_cmn.c:103:9: note: 'snprintf' output 12 or more
bytes (assuming 266) into a destination of size 256
103 | snprintf(complete_log_entry, sizeof(complete_log_entry),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104 | "[%s] [%s]: %s", time_buffer, level_str, log_entry);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
The memset in isobusfs_srv_volume_status_resp() was attempting to make a
padding beyond the buffer. Fix it.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Kernel may notify us about some error, which may happens if the bus was
in the error state. But this is not a good reason to kill application,
especially the server side.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Fix following clang warnings:
CC isobusfs/isobusfs_srv_fa.o
isobusfs/isobusfs_srv_fa.c:387:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (ret < 0) {
^~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:387:2: note: remove the 'if' if its condition is
always false
if (ret < 0) {
^~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:368:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (name_len > ISOBUSFS_MAX_PATH_NAME_LENGTH) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:368:2: note: remove the 'if' if its condition is
always false
if (name_len > ISOBUSFS_MAX_PATH_NAME_LENGTH) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:362:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (name_len > msg->len - sizeof(*req)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:362:2: note: remove the 'if' if its condition is
always false
if (name_len > msg->len - sizeof(*req)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:356:6: warning: variable 'handle' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!client) {
^~~~~~~
isobusfs/isobusfs_srv_fa.c:411:15: note: uninitialized use occurs here
res.handle = handle;
^~~~~~
isobusfs/isobusfs_srv_fa.c:356:2: note: remove the 'if' if its condition is
always false
if (!client) {
^~~~~~~~~~~~~~
isobusfs/isobusfs_srv_fa.c:352:16: note: initialize the variable 'handle' to
silence this warning
uint8_t handle;
^
= '\0'
isobusfs/isobusfs_srv_fa.c:505:9: warning: variable 'entry_count' set but not
used [-Wunused-but-set-variable]
size_t entry_count = 0;
^
5 warnings generated.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Fixes the following warning:
| isobusfs/isobusfs_cmn.c: In function 'isobusfs_get_timeout_ms':
| isobusfs/isobusfs_cmn.c:140:51: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int64_t' {aka 'long long int'} [-Wformat=]
| 140 | warn("timeout too long: %ld ms", time_diff);
| | ~~^ ~~~~~~~~~
| | | |
| | | int64_t {aka long long int}
| | long int
| | %lld
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>
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>