C implementation of a FUSE filesystem for mounting FTP servers, based on PyFtpfs.
- Mounts FTP servers as a local filesystem using FUSE
- Read and write support for files
- Directory caching with configurable timeout (default 5 seconds/30 seconds)
- Temporary write system for VS Code compatibility
- Support for FTP listing formats Unix and Windows
- Thread-safe connections with lock handling
- Multiple connection options (port, user, password, encoding)
- Full operations: create, read, write, delete, rename, directories
sudo apt-get install libfuse3-dev libcurl4-openssl-dev build-essentialsudo dnf install fuse3-devel libcurl-devel gcc makesudo pacman -S fuse3 curl gcc makechmod +x install.sh
sudo ./install.shThe script will automatically detect your operating system and install all necessary dependencies.
make
sudo make installsudo make uninstall
# or
sudo /usr/local/bin/uninstall_cftpfs.shcftpfs <host> <mountpoint> [options]| Option | Description | Default |
|---|---|---|
-p, --port=PORT |
FTP Port | 21 |
-u, --user=USER |
FTP User | anonymous |
-P, --password=PASS |
FTP Password | (empty) |
-e, --encoding=ENC |
Encoding | utf-8 |
-d, --debug |
Debug mode with detailed logs | - |
-f, --foreground |
Run in foreground | - |
-h, --help |
Show help | - |
Mount in foreground with user and password:
cftpfs ftp.example.com /mnt/ftp -u myuser -P mypassword -fMount in background:
cftpfs ftp.example.com /mnt/ftp -u user -P passwordMount anonymous FTP server:
cftpfs ftp.gnu.org /mnt/gnu -ffusermount -u /mnt/ftpThe project is organized into the following modules:
cFtpfs/
├── include/
│ └── cftpfs.h # Definitions and data structures
├── src/
│ ├── main.c # Entry point and FUSE operations
│ ├── ftp_client.c # FTP client using libcurl
│ ├── ftp_client_mock.c # Mock version for testing
│ ├── cache.c # Directory cache system
│ ├── handles.c # File handle management
│ └── parser.c # FTP listing parser (Unix/Windows)
├── Makefile # Compilation script
├── install.sh # Automatic installation script
└── README.md # Documentation
- Navigation:
getattr,readdir - Reading:
open,read - Writing:
create,write,truncate - Management:
unlink,mkdir,rmdir,rename - Metadata:
chmod,chown,utimens(stubs - not supported by standard FTP)
- Timeout: Configurable (default 30s) for directory listings and attributes.
- Strategy: Copy-on-read to avoid race conditions.
- Invalidation: Automatic on write operations.
- Does not support real permission changes (chmod) - standard FTP does not allow it
- Does not support owner changes (chown)
- Does not support timestamp changes (utimens)
- Symlinks are detected but not followed
- Fixed cache timeout logic (though configurable via flags now)
make mockUses a simulated FTP client that returns test data. Useful for development and testing without a real FTP server.
makeRequires libcurl installed. Uses real FTP connections.
- Reading: Similar to standard FTP client.
- Writing: Optimized for editors (VS Code) with temporary files.
- Cache: Reduces network operations for directory listings.
- Connection: Uses persistent connections (Keep-Alive) to avoid handshake overhead.
Ensure the FUSE module is loaded:
sudo modprobe fuseEnsure your user is in the fuse group:
sudo usermod -a -G fuse $USER
# Log out and log back in to apply changesVerify that the FTP server allows passive connections and that the port is open:
telnet ftp.example.com 21This error was fixed in the current version. If it persists, ensure you are using the latest version of the code.
- Performance: Native C implementation is faster.
- Memory: Lower memory consumption.
- Dependencies: Uses libcurl instead of ftplib (Python).
- Threading: Manual implementation with pthreads.
Apache 2.0 - Same as the original PyFtpfs project.
C implementation based on PyFtpfs.
Contributions are welcome. Please:
- Fork the repository
- Create a branch for your feature (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
- v1.0.0 - Initial complete version
- Full FUSE operations support
- Cache system
- Temporary file management
- Unix/Windows listing parser
- Automatic installer
- Memory error fixes
- Performance improvements (persistent connections)
This project is based on PyFtpfs and uses:
- FUSE3 for the user-space filesystem
- libcurl for FTP connections
- pthreads for threading
To report bugs or request features, please open an issue in the repository.