mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-26 10:01:03 +02:00
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>
This commit is contained in:
committed by
Oleksij Rempel
parent
6004c64f06
commit
42edaeaf52
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// SPDX-FileCopyrightText: 2023 Oleksij Rempel <linux@rempel-privat.de>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "isobusfs_cmn.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int isobusfs_cmn_dh_validate_dir_path(const char *path, bool writable)
|
||||
{
|
||||
struct stat path_stat;
|
||||
int mode = R_OK;
|
||||
int ret;
|
||||
|
||||
mode |= writable ? W_OK : 0;
|
||||
ret = access(path, mode);
|
||||
if (ret == -1) {
|
||||
ret = -errno;
|
||||
pr_err("failed to acces path %s, for read %s. %s", path,
|
||||
writable ? "and write" : "", strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = stat(path, &path_stat);
|
||||
if (ret == -1) {
|
||||
ret = -errno;
|
||||
pr_err("failed to get stat information on path %s. %s", path,
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(path_stat.st_mode)) {
|
||||
pr_err("path %s is not a directory", path);
|
||||
return -ENOTDIR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user