diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a85144ef685..9afb567afa1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -732,7 +732,6 @@ jobs: libopenni2-dev \ libftdi-dev \ libi2c-dev \ - libfuse-dev \ libjpeg-dev \ libpcl-dev \ libsoxr-dev @@ -1417,7 +1416,6 @@ jobs: libopenni2-dev \ libftdi-dev \ libi2c-dev \ - libfuse-dev \ libjpeg-dev \ libpcl-dev @@ -1605,7 +1603,6 @@ jobs: libopenni2-dev \ libftdi-dev \ libi2c-dev \ - libfuse-dev \ libjpeg-dev \ libpcl-dev @@ -1813,7 +1810,6 @@ jobs: libopenni2-dev \ libftdi-dev \ libi2c-dev \ - libfuse-dev \ libjpeg-dev \ libpcl-dev diff --git a/cmake/YarpFindDependencies.cmake b/cmake/YarpFindDependencies.cmake index cf3acd94629..ec78e51123f 100644 --- a/cmake/YarpFindDependencies.cmake +++ b/cmake/YarpFindDependencies.cmake @@ -414,10 +414,6 @@ checkandset_dependency(Libv4l2) find_package(Libv4lconvert QUIET) checkandset_dependency(Libv4lconvert) -find_package(Fuse QUIET) -checkandset_dependency(Fuse) - - ################################################################################ # Options @@ -659,7 +655,6 @@ print_dependency(FLEX) print_dependency(I2C) print_dependency(Libv4l2) print_dependency(Libv4lconvert) -print_dependency(Fuse) print_dependency(ZLIB) print_dependency(SOXR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a42615a5483..9df9507e3e0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,8 +78,3 @@ endif() if(YARP_COMPILE_RobotTestingFramework_ADDONS) add_subdirectory(robottestingframework-plugins) endif() - -# unmaintained stuff -if(YARP_COMPILE_EXECUTABLES) - add_subdirectory(yarpfs) -endif() diff --git a/src/yarpfs/CMakeLists.txt b/src/yarpfs/CMakeLists.txt deleted file mode 100644 index b55d44a700e..00000000000 --- a/src/yarpfs/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) -# SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium -# SPDX-License-Identifier: BSD-3-Clause - -include(CMakeDependentOption) -cmake_dependent_option( - CREATE_YARPFS - "Compile yarpfs executable" FALSE - YARP_COMPILE_UNMAINTAINED FALSE -) -mark_as_advanced(CREATE_YARPFS) - -if(CREATE_YARPFS) - add_executable(yarpfs) - - set(yarpfs_SRCS - yarpfs.cpp - link.cpp - ) - set(yarpfs_HDRS - yarpfns.h - yarputils.h - ) - - target_sources(yarpfs - PRIVATE - ${yarpfs_SRCS} - ${yarpfs_HDRS} - ) - - target_link_libraries(yarpfs - PRIVATE - YARP::YARP_os - YARP::YARP_init - ) - - target_compile_definitions(yarpfs PRIVATE ${Fuse_DEFINITIONS}) - target_include_directories(yarpfs PRIVATE ${Fuse_INCLUDE_DIRS}) - target_link_libraries(yarpfs PRIVATE ${Fuse_LIBRARIES}) - - set_property(TARGET yarpfs PROPERTY FOLDER "Unsupported") -endif() diff --git a/src/yarpfs/README.TXT b/src/yarpfs/README.TXT deleted file mode 100644 index 3dda8af8bfe..00000000000 --- a/src/yarpfs/README.TXT +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) -# SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium -# SPDX-FileCopyrightText: 2007 Giacomo Spigler -# SPDX-License-Identifier: BSD-3-Clause - -This directory contains experimental code for creating a mapping -from the YARP Network to a file system, using the super-cool FUSE -library. - -The code is just a start, hardly anything is implemented yet. -Stay away if you wish to preserve your sanity. - -=================================================================== - -If you want to play with this here are some tips: - -+ Make sure you are using YARP from CVS. The name server was updated - to simplify yarpfs. - -+ Learn about sshfs and get it installed. This hasn't anything to - do with yarpfs, it will just force you through the first - set of hurdles that aren't yet documented for yarpfs (installing - fuse kernel module if needed, learning how to mount things, etc). - If you can't get sshfs working, you won't be able to get yarpfs - working either. - -+ Install the development environment for fuse (on debian: libfuse-dev) - -+ Run cmake and compile - -+ Make a directory for mounting, e.g.: [as root] mkdir -p /mnt/yarp - -+ Run server in debug mode, e.g.: [as root] ./yarpfs /mnt/yarp -d - -+ Change into the directory and look around: [as root] cd /mnt/yarp; ls - -+ You should see a directory tree reflecting the ports that - exist in your YARP Network. - -+ The "leaf" files called "rw" can be read from - and written to, and the data comes from and goes to the port - associated with their containing directory. diff --git a/src/yarpfs/link.cpp b/src/yarpfs/link.cpp deleted file mode 100644 index 0a34fc79514..00000000000 --- a/src/yarpfs/link.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-FileCopyrightText: 2007 Giacomo Spigler - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -//#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "yarputils.h" -#include "yarpfns.h" - - -int yarp_readlink(const char *path, char *buf, size_t size) { - - YPath ypath(path); - if (!ypath.isSymLink()) { - return -ENOENT; - } - - memcpy(buf,ypath.getLink().c_str(),size); - - return 0; -} - - -int yarp_unlink(const char *path) { - - - - return 0; -} - - -int yarp_symlink(const char *to, const char *from) { - //TODO: actually, it only works with ln -s /read rd, and yet it throwns - // some errors - - //YPath ypath(from); - //if (!ypath.isStem()) { //Check that the path exists? Is it right? - // return -ENOENT; - //} - - //Create the new Contact - //Contact src = Network::queryName(from); - //printf("source [%s] is %s\n", from, src.toString().c_str()); - //Contact dest(to, src.getCarrier(), src.getHost(), src.getPort()); - //printf("dest [%s] should be %s\n", to, src.toString().c_str()); - //Network::registerContact(dest); - - printf("SYMLINK requested from [%s] to [%s]\n", from, to); - - // special symlink entry - //Contact src = Network::queryName(to); - Contact dest(from, "symlink", "none", 1); - printf("Planning to register %s / %d / %d\n", - dest.toString().c_str(), - dest.isValid(), - dest.getPort()); - Network::registerContact(dest); - Network::setProperty(from,"link",Value(to)); - - return 0; -} - - -int yarp_link(const char *from, const char *to) { - //TODO: will it ever be possible to hard link ports? - // If possible, it might be an alias for yarp_simlink, as with YARP - // there isn't a sym/hard linking difference - - //Create the new Contact - Contact src = Network::queryName(from); - - printf("source [%s] is %s\n", from, src.toString().c_str()); - - Contact dest(to, src.getCarrier(), src.getHost(), src.getPort()); - - printf("dest [%s] should be %s\n", to, src.toString().c_str()); - - - return 0; -} diff --git a/src/yarpfs/yarpfns.h b/src/yarpfs/yarpfns.h deleted file mode 100644 index 5154027d9c1..00000000000 --- a/src/yarpfs/yarpfns.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-FileCopyrightText: 2007 Giacomo Spigler - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef YARPFNS_INC -#define YARPFNS_INC - -#include - -// in yarpfs.cpp -int yarp_getattr(const char *path, struct stat *stbuf); -int yarp_readdir(const char *path, void *buf, fuse_fill_dir_t filler, - off_t offset, struct fuse_file_info *fi); -int yarp_open(const char *path, struct fuse_file_info *fi); -int yarp_release(const char *path, struct fuse_file_info *fi); -int yarp_read(const char *path, char *buf, size_t size, off_t offset, - struct fuse_file_info *fi); -int yarp_write(const char *path, const char *buf, size_t size, - off_t offset, struct fuse_file_info *fi); -int yarp_rename(const char *from, const char *to); -int yarp_rmdir(const char *path); -int yarp_truncate(const char *path, off_t size); -void *yarp_init(struct fuse_conn_info *conn); - -// in link.cpp -int yarp_readlink(const char *path, char *buf, size_t size); -int yarp_unlink(const char *path); -int yarp_symlink(const char *from, const char *to); -int yarp_link(const char *from, const char *to); - -#endif diff --git a/src/yarpfs/yarpfs.cpp b/src/yarpfs/yarpfs.cpp deleted file mode 100644 index 4cdcfc61e1c..00000000000 --- a/src/yarpfs/yarpfs.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-FileCopyrightText: 2007 Giacomo Spigler - * SPDX-License-Identifier: BSD-3-Clause - */ - -#define FUSE_USE_VERSION 26 - -#include -//#include -#include -#include -#include -//#include - -#include -#include - -#include -#include - -#include - -using namespace yarp::os; -using namespace yarp::os::impl; - - -#include "yarputils.h" -#include "yarpfns.h" - - - -int yarp_getattr(const char *path, struct stat *stbuf) -{ - int res = 0; - - YPath ypath(path); - - memset(stbuf, 0, sizeof(struct stat)); - printf("Checking attr // port %d, stem %d, act %d, sym %d\n", - ypath.isPort(), - ypath.isStem(), - ypath.isAct(), - ypath.isSymLink()); - if (ypath.isSymLink()) { - stbuf->st_mode = S_IFLNK | 0755; - stbuf->st_nlink = 1; - stbuf->st_size = ypath.getLink().length()+1; - printf("Link size %d\n", stbuf->st_size); - } else if (ypath.isStem()) { - stbuf->st_mode = S_IFDIR | 0755; - stbuf->st_nlink = 2; - } else if (ypath.isAct()) { - stbuf->st_mode = S_IFREG | 0444; - stbuf->st_nlink = 1; - stbuf->st_size = 0; //strlen(yarp_str); - } - else { - res = -ENOENT; - } - - return res; -} - -int yarp_readdir(const char *path, void *buf, fuse_fill_dir_t filler, - off_t offset, struct fuse_file_info *fi) -{ - (void /* unused */) offset; - (void /* unused */) fi; - - printf(">>>>>>>>>>>READING DIR\n"); - - - filler(buf, ".", NULL, 0); - filler(buf, "..", NULL, 0); - - YPath ypath(path); - - if (ypath.isPort()) { - filler(buf, "rw", NULL, 0); - //filler(buf, "write", NULL, 0); //deprecated - //filler(buf, "status", NULL, 0); - return 0; - } - - NameConfig nc; - - std::string name = nc.getNamespace(); - Bottle msg, reply; - msg.addString("bot"); - msg.addString("list"); - Network::write(name.c_str(), - msg, - reply); - - printf("Got %s\n", reply.toString().c_str()); - - std::set lines; - - - for (int i=1; icheck("name",Value("")).asString(); - if (name!="") { - if (strstr(name.c_str(),rpath.c_str())== - name.c_str()) { - printf(">>> %s is in path %s\n", name.c_str(), - rpath.c_str()); - std::string part(name.c_str()+rpath.length()); - if (part[0]=='/') { - part = part.substr(1,part.length()-1); - } - printf(" %s is the addition\n", part.c_str()); - - char *brk = (char*)strstr(part.c_str(),"/"); - if (brk!=NULL) { - *brk = '\0'; - } - std::string item(part.c_str()); - printf(" %s is the item\n", item.c_str()); - if (item!="") { - lines.insert(item); - } - } - } - } - } - - // return result in alphabetical order - for (const auto& line : lines) { - printf("adding item %s\n", line.c_str()); - filler(buf, line.c_str(), NULL, 0); - } - - return 0; -} - - -int yarp_open(const char *path, struct fuse_file_info *fi) -{ - fi->direct_io = 1; - fi->fh = (uint64_t) (new YHandle(path)); - - if (fi->fh == 0) { - return -EACCES; - } - - return 0; -} - - -int yarp_release(const char *path, struct fuse_file_info *fi) -{ - if (YHANDLE(fi) != NULL) { - delete YHANDLE(fi); - fi->fh = 0; - } - return 0; -} - - -int yarp_read(const char *path, char *buf, size_t size, off_t offset, - struct fuse_file_info *fi) -{ - size_t len; - (void /* unused */) fi; - - - YHandle *fh = YHANDLE(fi); - if (fh==NULL) { - return -ENOENT; - } - - string tail = fh->getTail(); - string head = fh->getHead(); - // lets just try to implement read for now - if (tail!="rw") { - return -ENOENT; - } - - return fh->read(buf,size,offset); -} - - -int yarp_write(const char *path, const char *buf, size_t size, - off_t offset, struct fuse_file_info *fi) -{ - size_t len; - (void /* unused */) fi; - - YHandle *fh = YHANDLE(fi); - if (fh==NULL) { - return -ENOENT; - } - - string tail = fh->getTail(); - string head = fh->getHead(); - // lets just try to implement write for now - if (tail!="rw") { - return -ENOENT; - } - - return fh->write(buf,size,offset); -} - - -int yarp_rename(const char *from, const char *to) { - //TODO: the current code just renames ports, eg: - // /read can become /rd, but /read/rd1 cannot become /rd/rd1 - // every subport/subdirectory should have to be renamed - - YPath ypath(from); - if (!ypath.isPort()) { //Check that the path exists? Is it right? - return -ENOENT; - } - - - //Create the new Contact - Contact src = Network::queryName(from); - Network::unregisterContact(src); - - Contact dest(to, src.getCarrier(), src.getHost(), src.getPort()); - - Network::registerContact(dest); - - return 0; -} - - -int yarp_rmdir(const char *path) { - //TODO: delete directories. Current code just links ports - // eg: delete every subport/subdirectory - - YPath ypath(path); - if (!ypath.isPort()) { - return -ENOENT; - } - - - //Create the new Contact - Contact src = Network::queryName(path); - //if(!src.isValid()) { - // return -ENOENT; - //} - - Network::unregisterContact(src); - - return 0; -} - - -int yarp_truncate(const char *path, off_t size) -{ - return 0; -} - - -void *yarp_init(struct fuse_conn_info *conn) { - Network yarp; - printf("Initializing...\n"); - return NULL; -} - - -static struct fuse_operations yarp_oper; - -int main(int argc, char *argv[]) -{ - yarp_oper.getattr = yarp_getattr; - yarp_oper.readdir = yarp_readdir; - yarp_oper.open = yarp_open; - yarp_oper.release = yarp_release; - yarp_oper.read = yarp_read; - yarp_oper.write = yarp_write; - yarp_oper.truncate = yarp_truncate; - yarp_oper.init = yarp_init; - - //Linking & Renaming - yarp_oper.readlink = yarp_readlink; - yarp_oper.symlink = yarp_symlink; - yarp_oper.link = yarp_link; - yarp_oper.rename = yarp_rename; - - yarp_oper.unlink = yarp_unlink; - yarp_oper.rmdir =yarp_rmdir; - - return fuse_main(argc, argv, &yarp_oper, NULL); -} diff --git a/src/yarpfs/yarputils.h b/src/yarpfs/yarputils.h deleted file mode 100644 index 4618ba51736..00000000000 --- a/src/yarpfs/yarputils.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT) - * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium - * SPDX-FileCopyrightText: 2007 Giacomo Spigler - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef YARPUTILS_H -#define YARPUTILS_H - -//#define FUSE_USE_VERSION 26 - -#include -//#include -#include -#include -#include -//#include - -#include -#include -#include - -#include -#include - -using namespace yarp::os; -using namespace yarp::os::impl; - - - -/* - -We try to map from filesystem paths to port names. - -The "directory" is the port name, and the "file" part is -an aspect of the port - properties, or read/write pipes. - - */ -class YPath { -private: - string path, head, tail; - bool dirty; - bool _isStem, _isPort, _isAct; - bool _isSymLink; - std::string link; - - // New version of check method. Relies on very up-to-date yarp server. - // Deals better with non existent directories/files. - void check() { - if (dirty) { - // limit for now: no "rw" directories - bool leafLike = (tail=="rw"); - - NameConfig nc; - std::string name = nc.getNamespace(); - Bottle msg, reply; - msg.addString("bot"); - msg.addString("list"); - msg.addString(leafLike?(head.c_str()):path.c_str()); - Network::write(name.c_str(), - msg, - reply); - printf("Check: got %s\n", reply.toString().c_str()); - _isAct = false; - _isStem = false; - _isPort = false; - _isSymLink = false; - link = ""; - if (leafLike) { - if (reply.size()>1) { - _isAct = true; - } - } else { - if (reply.size()>1) { - _isStem = true; - if (reply.size()==2) { - Property p; - p.fromString(reply.get(1).toString()); - //printf("Property p: %s\n", p.toString().c_str()); - if (p.check("name",Value("[none]")).asString()== - path.c_str()) { - _isPort = true; - } - if (p.check("carrier",Value("[none]")).asString()== - "symlink") { - _isSymLink = true; - } - } - } - } - dirty = false; - } - } - -public: - YPath(const char *path) { - set(path); - } - - void set(const char *path) { - this->path = path; - head = path; - tail = path; - size_t at = tail.rfind("/"); - if (at!=tail.npos) { - tail = tail.substr(at+1,tail.length()); - head = head.substr(0,at); - } - printf("PATH [%s] [%s] [%s]\n", head.c_str(), tail.c_str(), - this->path.c_str()); - dirty = true; - } - - string getHead() { - return head; - } - - string getTail() { - return tail; - } - - bool isStem() { - check(); - return _isStem; - } - - bool isPort() { - check(); - return _isPort; - } - - bool isAct() { - check(); - return _isAct; - } - - bool isSymLink() { - check(); - return _isSymLink; - } - - std::string getLink() { - if (link=="") { - Value * v = Network::getProperty(path.c_str(),"link"); - if (v!=NULL) { - link = v->asString(); - delete v; - } - } - return link; - } -}; - - - -class YHandle { -private: - YPath ypath; - BufferedPort port; - bool writing, reading, opened; -public: - YHandle(const char *path) : ypath(path) { - writing = false; - reading = false; - opened = false; - } - - string getHead() { - return ypath.getHead(); - } - - string getTail() { - return ypath.getTail(); - } - - bool isStem() { - return ypath.isStem(); - } - - bool isPort() { - return ypath.isPort(); - } - - bool isAct() { - return ypath.isAct(); - } - - bool isSymLink() { - return ypath.isSymLink(); - } - - std::string getLink() { - return ypath.getLink(); - } - - int open() { - if (!opened) { - port.setStrict(true); - port.open("..."); - opened = true; - } - return 0; - } - - int write(const char *buf, size_t size, off_t offset) { - open(); - if (!writing) { - Network::connect(port.getName(),getHead().c_str()); - writing = true; - } - Bottle& bot = port.prepare(); - bot.clear(); - string src(buf,size); - bot.fromString(src.c_str()); - port.write(true); - return size; - } - - int read(char *buf, size_t size, off_t offset) { - - open(); - if (!reading) { - Network::connect(getHead().c_str(),port.getName()); - reading = true; - } - - Bottle *bot = port.read(); - if (bot==NULL) { - return 0; - } - string str = bot->toString().c_str(); - str = str + "\n"; - - const char *yarp_str = str.c_str(); - printf(">>> Got %s\n", str.c_str()); - - offset = 0; - size_t len = strlen(yarp_str); - if (offset < len) { - if (offset + size > len) - size = len - offset; - memcpy(buf, yarp_str + offset, size); - } else - size = 0; - - return size; - } -}; - -#define YHANDLE(x) ((YHandle*)((x)->fh)) - -#endif