Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5393ddf795 | |||
| 25b58aad4d | |||
| c71eea8e68 | |||
| afbdf92fa6 | |||
| daac34f7c8 | |||
| 88692b79eb | |||
| 035dcde9ba | |||
| cc14ae1c79 | |||
| 78f807b3dd | |||
| fd885f023c | |||
| 033a1d48f5 | |||
| 82285f9c28 | |||
| 43b2708186 | |||
| d749988c80 | |||
| 7921230f83 | |||
| ea60e3466e | |||
| 033a88349c | |||
| 1cd6995713 | |||
| 9e35c39ba8 | |||
| bf540dd68b | |||
| 882d3a0185 | |||
| 113882adda | |||
| ccb6821019 | |||
| ed0825440c | |||
| a9eb71cb1c | |||
| b1715a5a62 | |||
| 21fdcad6fb | |||
| ef94977c5a | |||
| d78a624756 | |||
| ddf1e42ce7 | |||
| 1a52814a4e | |||
| c9bf8ad451 | |||
| 5f767dec5b | |||
| 8bb9d33d16 | |||
| eadf7f104a | |||
| 1af815b7dc | |||
| 683b8c2454 | |||
| 70c8fd9031 | |||
| 47a580dd77 | |||
| e5f4fcaad7 | |||
| 8c97da5b16 | |||
| 551752c3a5 | |||
| c91eb9a9a9 | |||
| 103c6ba68b | |||
| 3aa3efcb52 | |||
| a2054a2b73 | |||
| fd02499b4c | |||
| c2715f7453 | |||
| 1abde6e779 | |||
| a181b9b60b | |||
| d54c7ecbd6 | |||
| 803e0e65cf | |||
| 9700b35370 | |||
| 6c1b92df81 | |||
| d18869a307 | |||
| dfd4cba385 | |||
| 8059e2ce63 | |||
| 9e01ffd161 | |||
| de0504e45b | |||
| 6625146af9 | |||
| 76ffb37444 | |||
| a96e521474 | |||
| 11df8874dc | |||
| a7e1038203 | |||
| 8340a67b31 | |||
| ab0e339e80 | |||
| b19e3b8001 | |||
| e910453156 | |||
| 28c22270f8 | |||
| 8822b60d9d | |||
| 0f3ab4fd4f | |||
| ddd968b025 | |||
| 2421675f3f | |||
| eade8feb05 | |||
| 4d866526dc | |||
| 6935b49eea | |||
| a548abd1f3 |
@@ -0,0 +1 @@
|
||||
d54c7ecbd618afb4df524e0d96dec7fe7cc2935d
|
||||
@@ -11,7 +11,7 @@ PLEASE READ BEFORE REPORTING AN ISSUE
|
||||
|
||||
SSHFS does not have any active, regular contributors or developers. The current maintainer continues to apply pull requests and tries to make regular releases, but unfortunately has no capacity to do any development beyond addressing high-impact issues. When reporting bugs, please understand that unless you are including a pull request or are reporting a critical issue, you will probably not get a response.
|
||||
|
||||
To prevent the issue tracker from being flooded with issues that no-one is intending to work on, and to give more visibilty to critical issues that users should be aware of and that most urgently need attention, I will also close most bug reports once they've been inactive for a while.
|
||||
To prevent the issue tracker from being flooded with issues that no-one is intending to work on, and to give more visibility to critical issues that users should be aware of and that most urgently need attention, I will also close most bug reports once they've been inactive for a while.
|
||||
|
||||
Please note that this isn't meant to imply that you haven't found a bug - you most likely have and I'm grateful that you took the time to report it. Unfortunately, SSHFS is a purely volunteer driven project,
|
||||
and at the moment there simply aren't any volunteers.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
github-actions:
|
||||
patterns:
|
||||
- "*"
|
||||
@@ -0,0 +1,143 @@
|
||||
name: build and test
|
||||
on:
|
||||
push:
|
||||
|
||||
pull_request:
|
||||
|
||||
workflow_dispatch: # this is a nice option that will enable a button w/ inputs
|
||||
inputs:
|
||||
git-ref:
|
||||
description: Git Ref (Optional)
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
name: ${{ matrix.compiler }} / ${{ matrix.buildtype }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [gcc, clang]
|
||||
buildtype: [debugoptimized, release]
|
||||
include:
|
||||
- compiler: gcc
|
||||
cc: gcc
|
||||
- compiler: clang
|
||||
cc: clang
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc clang ninja-build libglib2.0-dev libfuse3-dev openssh-server openssh-client fuse3
|
||||
|
||||
- name: Install meson
|
||||
run: pip3 install meson pytest pytest-timeout
|
||||
|
||||
- name: Print tool versions
|
||||
run: |
|
||||
${{ matrix.cc }} --version
|
||||
meson --version
|
||||
|
||||
- name: Setup SSH
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -q -N ""
|
||||
cat ~/.ssh/id_ed25519.pub > ~/.ssh/authorized_keys
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
sudo systemctl start ssh || sudo service ssh start
|
||||
ssh -o StrictHostKeyChecking=no -o BatchMode=yes localhost true
|
||||
|
||||
- name: Check FUSE availability
|
||||
run: |
|
||||
test -e /dev/fuse
|
||||
command -v fusermount3
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
run: |
|
||||
meson setup build --buildtype=${{ matrix.buildtype }} -Dwerror=true
|
||||
ninja -C build
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: sshfs-${{ matrix.compiler }}-${{ matrix.buildtype }}
|
||||
path: build/sshfs
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Run tests
|
||||
timeout-minutes: 20
|
||||
run: |
|
||||
cd build
|
||||
python3 -m pytest --maxfail=99 --timeout=300 --junitxml=test-results.xml test/
|
||||
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
if: always()
|
||||
with:
|
||||
name: test-results-${{ matrix.compiler }}-${{ matrix.buildtype }}
|
||||
path: |
|
||||
build/test-results.xml
|
||||
build/meson-logs/
|
||||
|
||||
strict-warnings:
|
||||
name: ${{ matrix.compiler }} / strict warnings
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
cc: gcc
|
||||
extra_cflags: "-Wformat=2 -Wformat-security -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wnull-dereference"
|
||||
- compiler: clang
|
||||
cc: clang
|
||||
extra_cflags: "-Wformat=2 -Wformat-security -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wnull-dereference"
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc clang ninja-build libglib2.0-dev libfuse3-dev
|
||||
|
||||
- name: Install meson
|
||||
run: pip3 install meson
|
||||
|
||||
- name: Print tool versions
|
||||
run: |
|
||||
${{ matrix.cc }} --version
|
||||
meson --version
|
||||
|
||||
- name: Build with strict warnings
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CFLAGS: ${{ matrix.extra_cflags }}
|
||||
run: |
|
||||
meson setup build -Dwerror=true
|
||||
ninja -C build
|
||||
@@ -0,0 +1,51 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze C
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@bc0b696b4103f5fe60f15749af68a046868d511a # codeql-bundle-v2.25.4
|
||||
with:
|
||||
languages: c-cpp
|
||||
build-mode: manual
|
||||
queries: security-extended
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc ninja-build pkg-config libglib2.0-dev libfuse3-dev
|
||||
pip3 install meson
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
meson setup build --buildtype=debug
|
||||
ninja -C build sshfs
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@bc0b696b4103f5fe60f15749af68a046868d511a # codeql-bundle-v2.25.4
|
||||
@@ -34,3 +34,4 @@ sshfs.1
|
||||
/patches
|
||||
/m4
|
||||
.deps/
|
||||
/build
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.0.1
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 2.1.5
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
+20
-10
@@ -1,21 +1,31 @@
|
||||
sudo: required
|
||||
dist: xenial
|
||||
dist: focal
|
||||
|
||||
language: c
|
||||
|
||||
cache:
|
||||
- pip
|
||||
|
||||
language:
|
||||
- c
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- shellcheck
|
||||
- valgrind
|
||||
- clang
|
||||
- gcc
|
||||
- gcc-6
|
||||
- clang
|
||||
- python-docutils
|
||||
- python3-pip
|
||||
- python3-setuptools
|
||||
- ninja-build
|
||||
install: test/travis-install.sh
|
||||
script: test/travis-build.sh
|
||||
- meson
|
||||
- python3-pytest
|
||||
- libglib2.0-dev
|
||||
|
||||
install: test/travis-install.sh
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- name: Lint
|
||||
script: ./test/lint.sh
|
||||
install: skip
|
||||
- name: Build + Test
|
||||
script: test/travis-build.sh
|
||||
|
||||
@@ -1,39 +1,52 @@
|
||||
Current Maintainer
|
||||
------------------
|
||||
|
||||
Nikolaus Rath <Nikolaus@rath.org>
|
||||
None.
|
||||
|
||||
|
||||
Past Maintainers
|
||||
----------------
|
||||
|
||||
Nikolaus Rath <Nikolaus@rath.org> (until 05/2022)
|
||||
Miklos Szeredi <miklos@szeredi.hu> (until 12/2015)
|
||||
|
||||
|
||||
Contributors (autogenerated list)
|
||||
---------------------------------
|
||||
|
||||
a1346054 <36859588+a1346054@users.noreply.github.com>
|
||||
Alan Jenkins <alan.christopher.jenkins@gmail.com>
|
||||
Alexander Neumann <alexander@bumpern.de>
|
||||
Anatol Pomozov <anatol.pomozov@gmail.com>
|
||||
Andrew Stone <a@stne.dev>
|
||||
Antonio Rojas <arojas@archlinux.org>
|
||||
Benjamin Fleischer <fleiben@gmail.com>
|
||||
Berserker <berserker.troll@yandex.com>
|
||||
Bill Zissimopoulos <billziss@navimatics.com>
|
||||
bjoe2k4 <bjoe2k4@users.noreply.github.com>
|
||||
Brandon Carter <b-carter@users.noreply.github.com>
|
||||
Cam Cope <github@camcope.me>
|
||||
Chris Wolfe <cwolfe@chromium.org>
|
||||
Clayton G. Hobbs <clay@lakeserv.net>
|
||||
Daniel Lublin <daniel@lublin.se>
|
||||
Dominique Martinet <asmadeus@codewreck.org>
|
||||
DrDaveD <2129743+DrDaveD@users.noreply.github.com>
|
||||
Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
||||
gala <gala132@users.noreply.github.com>
|
||||
Galen Getsov <4815620+ggetsov@users.noreply.github.com>
|
||||
George Vlahavas <vlahavas@gmail.com>
|
||||
G.raud Meyer <graud@gmx.com>
|
||||
harrim4n <git@harrim4n.com>
|
||||
Jakub Jelen <jjelen@redhat.com>
|
||||
jeg139 <54814784+jeg139@users.noreply.github.com>
|
||||
Josh Triplett <josh@joshtriplett.org>
|
||||
Julio Merino <jmmv@google.com>
|
||||
Julio Merino <jmmv@meroh.net>
|
||||
Junichi Uekawa <dancerj@gmail.com>
|
||||
Junichi Uekawa <dancer@netfort.gr.jp>
|
||||
kalvdans <github@kalvdans.no-ip.org>
|
||||
Kim Brose <kim.brose@rwth-aachen.de>
|
||||
Matthew Berginski <matthew.berginski@gmail.com>
|
||||
Michael Forney <mforney@mforney.org>
|
||||
Mike Kelly <mike@pair.com>
|
||||
Mike Salvatore <mike.s.salvatore@gmail.com>
|
||||
@@ -42,6 +55,8 @@ Miklos Szeredi <mszeredi@suse.cz>
|
||||
mssalvatore <mike.s.salvatore@gmail.com>
|
||||
Nikolaus Rath <Nikolaus@rath.org>
|
||||
Percy Jahn <email@percyjahn.de>
|
||||
Peter Belm <peterbelm@gmail.com>
|
||||
Peter Wienemann <peter.wienemann@uni-bonn.de>
|
||||
Qais Patankar <qaisjp@gmail.com>
|
||||
Quentin Rameau <quinq@fifth.space>
|
||||
Reid Wagner <wagnerreid@gmail.com>
|
||||
@@ -49,6 +64,7 @@ Rian Hunter <rian@alum.mit.edu>
|
||||
Rian Hunter <rianhunter@users.noreply.github.com>
|
||||
Samuel Murray <samuel.murray@outlook.com>
|
||||
S. D. Cloudt <s.d.cloudt@student.tue.nl>
|
||||
Simon Arlott <70171+nomis@users.noreply.github.com>
|
||||
smheidrich <smheidrich@weltenfunktion.de>
|
||||
sunwire <50745572+sunwire@users.noreply.github.com>
|
||||
Tim Harder <radhermit@gmail.com>
|
||||
|
||||
+59
-6
@@ -1,3 +1,56 @@
|
||||
Release 3.7.5 (2025-11-11)
|
||||
--------------------------
|
||||
|
||||
* New maintainers added
|
||||
* Main documentation updates to using Markdown
|
||||
* Updated Windows and macOS support
|
||||
* Added IPv6 support in -o directport
|
||||
* Added -o vsock option
|
||||
* Minor bugfixes
|
||||
|
||||
Release 3.7.3 (2022-05-26)
|
||||
--------------------------
|
||||
|
||||
* Minor bugfixes.
|
||||
|
||||
* This is the last release from the current maintainer. SSHFS is now no longer maintained
|
||||
or developed. Github issue tracking and pull requests have therefore been disabled. The
|
||||
mailing list (see below) is still available for use.
|
||||
|
||||
If you would like to take over this project, you are welcome to do so. Please fork it
|
||||
and develop the fork for a while. Once there has been 6 months of reasonable activity,
|
||||
please contact Nikolaus@rath.org and I'll be happy to give you ownership of this
|
||||
repository or replace with a pointer to the fork.
|
||||
|
||||
|
||||
Release 3.7.2 (2021-06-08)
|
||||
--------------------------
|
||||
|
||||
* Added a secondary check so if a mkdir request fails with EPERM an access request will be
|
||||
tried - returning EEXIST if the access was successful.
|
||||
Fixes: https://github.com/libfuse/sshfs/issues/243
|
||||
|
||||
|
||||
Release 3.7.1 (2020-11-09)
|
||||
--------------------------
|
||||
|
||||
* Minor bugfixes.
|
||||
|
||||
|
||||
Release 3.7.0 (2020-01-03)
|
||||
--------------------------
|
||||
|
||||
* New max_conns option enables the use of multiple connections to improve responsiveness
|
||||
during large file transfers. Thanks to Timo Savola for doing most of the implementation
|
||||
work, and thanks to CEA.fr for sponsoring remaining bugfixes and cleanups!
|
||||
|
||||
* The `buflimit` workaround is now disabled by default. The corresponding bug in OpenSSH
|
||||
has been fixed in 2007
|
||||
(cf. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365541#37), so this shouldn't be
|
||||
needed anymore. If you depend on this workaround, please let the SSHFS maintainers know,
|
||||
otherwise support for the workaround will be removed completely in a future version.
|
||||
|
||||
|
||||
Release 3.6.0 (2019-11-03)
|
||||
--------------------------
|
||||
|
||||
@@ -80,13 +133,13 @@ Release 3.1.0 (2017-08-04)
|
||||
|
||||
* For improved backwards compatibility, SSHFS now also silently
|
||||
accepts the old ``-o cache_*`` options.
|
||||
|
||||
|
||||
Release 3.0.0 (2017-07-08)
|
||||
--------------------------
|
||||
|
||||
* sshfs now requires libfuse 3.1.0 or newer.
|
||||
* When supported by the kernel, sshfs now uses writeback caching.
|
||||
* The `cache` option has been renamed to `dir_cache` for clarity.
|
||||
* The `cache` option has been renamed to `dir_cache` for clarity.
|
||||
* Added unit tests
|
||||
* --debug now behaves like -o debug_sshfs, i.e. it enables sshfs
|
||||
debugging messages rather than libfuse debugging messages.
|
||||
@@ -101,7 +154,7 @@ Release 3.0.0 (2017-07-08)
|
||||
* Removed support for `-o workaround=all`. Workarounds should always
|
||||
enabled explicitly and only when needed. There is no point in always
|
||||
enabling a potentially changing set of workarounds.
|
||||
|
||||
|
||||
Release 2.9 (2017-04-17)
|
||||
------------------------
|
||||
|
||||
@@ -140,14 +193,14 @@ Release 2.4 (2012-03-08)
|
||||
------------------------
|
||||
|
||||
* New `slave` option.
|
||||
* New `idmap`, `uidmap` and `gidmap` options.
|
||||
* New `idmap`, `uidmap` and `gidmap` options.
|
||||
* Various small bugfixes.
|
||||
|
||||
Release 2.3 (2011-07-01)
|
||||
------------------------
|
||||
|
||||
* Support hard link creation if server is OpenSSH 5.7 or later
|
||||
* Small improvements and bug fixes
|
||||
* Small improvements and bug fixes
|
||||
* Check mount point and options before connecting to ssh server
|
||||
* New 'delay_connect' option
|
||||
|
||||
@@ -160,7 +213,7 @@ Release 2.2 (2008-10-20)
|
||||
Release 2.1 (2008-07-11)
|
||||
------------------------
|
||||
|
||||
* Small improvements and bug fixes
|
||||
* Small improvements and bug fixes
|
||||
|
||||
Release 2.0 (2008-04-23)
|
||||
------------------------
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
# SSHFS
|
||||
|
||||
|
||||
## About
|
||||
|
||||
SSHFS allows you to mount a remote filesystem using SFTP. Most SSH
|
||||
servers support and enable this SFTP access by default, so SSHFS is
|
||||
very simple to use - there's nothing to do on the server-side.
|
||||
|
||||
|
||||
## Development Status
|
||||
|
||||
|
||||
SSHFS is shipped by all major Linux distributions and has been in
|
||||
production use across a wide range of systems for many years. However,
|
||||
at present SSHFS does not have any active, regular contributors, and
|
||||
there are a number of known issues (see the [bugtracker](https://github.com/libfuse/sshfs/issues)).
|
||||
The current maintainer continues to apply pull requests and makes regular
|
||||
releases, but unfortunately has no capacity to do any development
|
||||
beyond addressing high-impact issues. When reporting bugs, please
|
||||
understand that unless you are including a pull request or are
|
||||
reporting a critical issue, you will probably not get a response.
|
||||
|
||||
|
||||
## How to use
|
||||
|
||||
|
||||
Once sshfs is installed (see next section) running it is very simple:
|
||||
|
||||
```
|
||||
sshfs [user@]hostname:[directory] mountpoint
|
||||
```
|
||||
|
||||
It is recommended to run SSHFS as regular user (not as root). For
|
||||
this to work the mountpoint must be owned by the user. If username is
|
||||
omitted SSHFS will use the local username. If the directory is
|
||||
omitted, SSHFS will mount the (remote) home directory. If you need to
|
||||
enter a password sshfs will ask for it (actually it just runs ssh
|
||||
which asks for the password if needed).
|
||||
|
||||
Also many ssh options can be specified (see the manual pages for
|
||||
*sftp(1)* and *ssh_config(5)*), including the remote port number
|
||||
(`-oport=PORT`)
|
||||
|
||||
To unmount the filesystem:
|
||||
|
||||
```
|
||||
fusermount -u mountpoint
|
||||
```
|
||||
|
||||
On BSD and macOS, to unmount the filesystem:
|
||||
|
||||
```
|
||||
umount mountpoint
|
||||
```
|
||||
|
||||
### Bypassing SSH
|
||||
|
||||
#### Using directport
|
||||
|
||||
Using direct connections to sftp-server to bypass SSH for performance is also possible. To do this, start a network service using sftp-server (part of OpenSSH) on a server, then connect directly using `-o directport=PORT` option.
|
||||
|
||||
On server (listen on port 1234 using socat):
|
||||
|
||||
`socat tcp-listen:1234,reuseaddr,fork exec:/usr/lib/openssh/sftp-server`
|
||||
|
||||
On client:
|
||||
|
||||
`sshfs -o directport=1234 127.0.0.1:/tmp /tmp/mnt`
|
||||
|
||||
Note that this is insecure as connection will happen without encryption. Only use this on localhost or trusted networks. This option is sometimes used by other projects to mount folders inside VMs.
|
||||
|
||||
IPv6 is also possible:
|
||||
|
||||
`socat tcp6-listen:1234,reuseaddr,fork exec:/usr/lib/openssh/sftp-server`
|
||||
|
||||
`sshfs -o directport=1234 [::1]:/tmp /tmp/mnt`
|
||||
|
||||
#### Using vsock
|
||||
|
||||
Similarly to above, Linux [vsock](https://man7.org/linux/man-pages/man7/vsock.7.html) can be used to connect directly to sockets within VMs using `-o vsock=CID:PORT`.
|
||||
|
||||
```
|
||||
# on the host
|
||||
socat VSOCK-LISTEN:12345 EXEC:"/usr/lib/openssh/sftp-server",nofork
|
||||
# on the clientside
|
||||
sshfs -o vsock=2:12345 unused_host: ./tmp
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
First, download the latest SSHFS release from
|
||||
https://github.com/libfuse/sshfs/releases. You also need [libfuse](http://github.com/libfuse/libfuse) 3.1.0 or newer (or a
|
||||
similar library that provides a libfuse3 compatible interface for your operating
|
||||
system). Finally, you need the [Glib](https://developer.gnome.org/glib/stable/) library with development headers (which should be
|
||||
available from your operating system's package manager).
|
||||
|
||||
To build and install, we recommend to use [Meson](http://mesonbuild.com/) (version 0.38 or
|
||||
newer) and [Ninja](https://ninja-build.org/). After extracting the sshfs tarball, create a
|
||||
(temporary) build directory and run Meson:
|
||||
|
||||
```
|
||||
$ mkdir build; cd build
|
||||
$ meson ..
|
||||
```
|
||||
|
||||
Normally, the default build options will work fine. If you
|
||||
nevertheless want to adjust them, you can do so with the *mesonconf*
|
||||
command:
|
||||
|
||||
```
|
||||
$ mesonconf # list options
|
||||
$ mesonconf -D strip=true # set an option
|
||||
```
|
||||
|
||||
To build, test and install SSHFS, you then use Ninja (running the
|
||||
tests requires the [py.test](http://www.pytest.org/) Python module):
|
||||
|
||||
```
|
||||
$ ninja
|
||||
$ python3 -m pytest test/ # optional, but recommended
|
||||
$ sudo ninja install
|
||||
```
|
||||
|
||||
## Getting Help
|
||||
|
||||
|
||||
If you need help, please ask on the <fuse-sshfs@lists.sourceforge.net>
|
||||
mailing list (subscribe at
|
||||
https://lists.sourceforge.net/lists/listinfo/fuse-sshfs).
|
||||
|
||||
Please report any bugs on the GitHub issue tracker at
|
||||
https://github.com/libfuse/sshfs/issues.
|
||||
|
||||
## Packaging Status
|
||||
|
||||
|
||||
<a href="https://repology.org/project/fusefs:sshfs/versions">
|
||||
<img src="https://repology.org/badge/vertical-allrepos/fusefs:sshfs.svg" alt="Packaging status" >
|
||||
</a>
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
SSHFS
|
||||
=====
|
||||
|
||||
|
||||
About
|
||||
-----
|
||||
|
||||
SSHFS allows you to mount a remote filesystem using SFTP. Most SSH
|
||||
servers support and enable this SFTP access by default, so SSHFS is
|
||||
very simple to use - there's nothing to do on the server-side.
|
||||
|
||||
|
||||
Development Status
|
||||
------------------
|
||||
|
||||
SSHFS is shipped by all major Linux distributions and has been in
|
||||
production use across a wide range of systems for many years. However,
|
||||
at present SSHFS does not have any active, regular contributors, and
|
||||
there are a number of known issues (see the bugtracker). The current
|
||||
maintainer continues to apply pull requests and makes regular
|
||||
releases, but unfortunately has no capacity to do any development
|
||||
beyond addressing high-impact issues. When reporting bugs, please
|
||||
understand that unless you are including a pull request or are
|
||||
reporting a critical issue, you will probably not get a response.
|
||||
|
||||
|
||||
How to use
|
||||
----------
|
||||
|
||||
Once sshfs is installed (see next section) running it is very simple::
|
||||
|
||||
sshfs [user@]hostname:[directory] mountpoint
|
||||
|
||||
It is recommended to run SSHFS as regular user (not as root). For
|
||||
this to work the mountpoint must be owned by the user. If username is
|
||||
omitted SSHFS will use the local username. If the directory is
|
||||
omitted, SSHFS will mount the (remote) home directory. If you need to
|
||||
enter a password sshfs will ask for it (actually it just runs ssh
|
||||
which ask for the password if needed).
|
||||
|
||||
Also many ssh options can be specified (see the manual pages for
|
||||
*sftp(1)* and *ssh_config(5)*), including the remote port number
|
||||
(``-oport=PORT``)
|
||||
|
||||
To unmount the filesystem::
|
||||
|
||||
fusermount -u mountpoint
|
||||
|
||||
On BSD and macOS, to unmount the filesystem::
|
||||
|
||||
umount mountpoint
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
First, download the latest SSHFS release from
|
||||
https://github.com/libfuse/sshfs/releases. On Linux and BSD, you will
|
||||
also need to install libfuse_ 3.1.0 or newer. On macOS, you need
|
||||
OSXFUSE_ instead. Finally, you need the Glib_ library with development
|
||||
headers (which should be available from your operating system's
|
||||
package manager).
|
||||
|
||||
To build and install, we recommend to use Meson_ (version 0.38 or
|
||||
newer) and Ninja_. After extracting the sshfs tarball, create a
|
||||
(temporary) build directory and run Meson::
|
||||
|
||||
$ mkdir build; cd build
|
||||
$ meson ..
|
||||
|
||||
Normally, the default build options will work fine. If you
|
||||
nevertheless want to adjust them, you can do so with the *mesonconf*
|
||||
command::
|
||||
|
||||
$ mesonconf # list options
|
||||
$ mesonconf -D strip=true # set an option
|
||||
|
||||
To build, test and install SSHFS, you then use Ninja (running the
|
||||
tests requires the `py.test`_ Python module)::
|
||||
|
||||
$ ninja
|
||||
$ python3 -m pytest test/ # optional, but recommended
|
||||
$ sudo ninja install
|
||||
|
||||
.. _libfuse: http://github.com/libfuse/libfuse
|
||||
.. _OSXFUSE: https://osxfuse.github.io/
|
||||
.. _Glib: https://developer.gnome.org/glib/stable/
|
||||
.. _Meson: http://mesonbuild.com/
|
||||
.. _Ninja: https://ninja-build.org/
|
||||
.. _`py.test`: http://www.pytest.org/
|
||||
|
||||
Getting Help
|
||||
------------
|
||||
|
||||
If you need help, please ask on the <fuse-sshfs@lists.sourceforge.net>
|
||||
mailing list (subscribe at
|
||||
https://lists.sourceforge.net/lists/listinfo/fuse-sshfs).
|
||||
|
||||
Please report any bugs on the GitHub issue tracker at
|
||||
https://github.com/libfuse/libfuse/issues.
|
||||
|
||||
|
||||
Professional Support
|
||||
--------------------
|
||||
|
||||
Professional support is offered via `Rath Consulting`_.
|
||||
|
||||
.. _`Rath Consulting`: http://www.rath-consulting.biz
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define DEFAULT_CACHE_TIMEOUT_SECS 20
|
||||
#define DEFAULT_MAX_CACHE_SIZE 10000
|
||||
@@ -40,7 +41,7 @@ static struct cache cache;
|
||||
struct node {
|
||||
struct stat stat;
|
||||
time_t stat_valid;
|
||||
char **dir;
|
||||
GPtrArray *dir;
|
||||
time_t dir_valid;
|
||||
char *link;
|
||||
time_t link_valid;
|
||||
@@ -63,13 +64,28 @@ struct file_handle {
|
||||
unsigned long fs_fh;
|
||||
};
|
||||
|
||||
struct cache_dirent {
|
||||
char *name;
|
||||
struct stat stat;
|
||||
};
|
||||
|
||||
static void free_node(gpointer node_)
|
||||
{
|
||||
struct node *node = (struct node *) node_;
|
||||
g_strfreev(node->dir);
|
||||
if (node->dir != NULL) {
|
||||
g_ptr_array_free(node->dir, TRUE);
|
||||
}
|
||||
g_free(node);
|
||||
}
|
||||
|
||||
static void free_cache_dirent(gpointer data) {
|
||||
struct cache_dirent *cache_dirent = (struct cache_dirent *) data;
|
||||
if (cache_dirent != NULL) {
|
||||
g_free(cache_dirent->name);
|
||||
g_free(cache_dirent);
|
||||
}
|
||||
}
|
||||
|
||||
static int cache_clean_entry(void *key_, struct node *node, time_t *now)
|
||||
{
|
||||
(void) key_;
|
||||
@@ -186,13 +202,15 @@ void cache_add_attr(const char *path, const struct stat *stbuf, uint64_t wrctr)
|
||||
pthread_mutex_unlock(&cache.lock);
|
||||
}
|
||||
|
||||
static void cache_add_dir(const char *path, char **dir)
|
||||
static void cache_add_dir(const char *path, GPtrArray *dir)
|
||||
{
|
||||
struct node *node;
|
||||
|
||||
pthread_mutex_lock(&cache.lock);
|
||||
node = cache_get(path);
|
||||
g_strfreev(node->dir);
|
||||
if (node->dir != NULL) {
|
||||
g_ptr_array_free(node->dir, TRUE);
|
||||
}
|
||||
node->dir = dir;
|
||||
node->dir_valid = time(NULL) + cache.dir_timeout_secs;
|
||||
if (node->dir_valid > node->valid)
|
||||
@@ -256,9 +274,9 @@ static void *cache_init(struct fuse_conn_info *conn,
|
||||
{
|
||||
void *res;
|
||||
res = cache.next_oper->init(conn, cfg);
|
||||
|
||||
|
||||
// Cache requires a path for each request
|
||||
cfg->nullpath_ok = 0;
|
||||
cfg->nullpath_ok = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -318,9 +336,9 @@ static int cache_releasedir(const char *path, struct fuse_file_info *fi)
|
||||
{
|
||||
int err;
|
||||
struct file_handle *cfi;
|
||||
|
||||
|
||||
cfi = (struct file_handle*) fi->fh;
|
||||
|
||||
|
||||
if(cfi->is_open) {
|
||||
fi->fh = cfi->fs_fh;
|
||||
err = cache.next_oper->releasedir(path, fi);
|
||||
@@ -341,7 +359,10 @@ static int cache_dirfill (void *buf, const char *name,
|
||||
ch = (struct readdir_handle*) buf;
|
||||
err = ch->filler(ch->buf, name, stbuf, off, flags);
|
||||
if (!err) {
|
||||
g_ptr_array_add(ch->dir, g_strdup(name));
|
||||
struct cache_dirent *cdent = g_malloc(sizeof(struct cache_dirent));
|
||||
cdent->name = g_strdup(name);
|
||||
cdent->stat = *stbuf;
|
||||
g_ptr_array_add(ch->dir, cdent);
|
||||
if (stbuf->st_mode & S_IFMT) {
|
||||
char *fullpath;
|
||||
const char *basepath = !ch->path[1] ? "" : ch->path;
|
||||
@@ -361,19 +382,20 @@ static int cache_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
struct readdir_handle ch;
|
||||
struct file_handle *cfi;
|
||||
int err;
|
||||
char **dir;
|
||||
GPtrArray *dir;
|
||||
struct node *node;
|
||||
struct cache_dirent **cdent;
|
||||
|
||||
assert(offset == 0);
|
||||
|
||||
|
||||
pthread_mutex_lock(&cache.lock);
|
||||
node = cache_lookup(path);
|
||||
if (node != NULL && node->dir != NULL) {
|
||||
time_t now = time(NULL);
|
||||
if (node->dir_valid - now >= 0) {
|
||||
for(dir = node->dir; *dir != NULL; dir++)
|
||||
// FIXME: What about st_mode?
|
||||
filler(buf, *dir, NULL, 0, 0);
|
||||
for(cdent = (struct cache_dirent**)node->dir->pdata; *cdent != NULL; cdent++) {
|
||||
filler(buf, (*cdent)->name, &(*cdent)->stat, 0, 0);
|
||||
}
|
||||
pthread_mutex_unlock(&cache.lock);
|
||||
return 0;
|
||||
}
|
||||
@@ -391,22 +413,22 @@ static int cache_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
}
|
||||
cfi->is_open = 1;
|
||||
cfi->fs_fh = fi->fh;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ch.path = path;
|
||||
ch.buf = buf;
|
||||
ch.filler = filler;
|
||||
ch.dir = g_ptr_array_new();
|
||||
g_ptr_array_set_free_func(ch.dir, free_cache_dirent);
|
||||
ch.wrctr = cache_get_write_ctr();
|
||||
err = cache.next_oper->readdir(path, &ch, cache_dirfill, offset, fi, flags);
|
||||
g_ptr_array_add(ch.dir, NULL);
|
||||
dir = (char **) ch.dir->pdata;
|
||||
dir = ch.dir;
|
||||
if (!err) {
|
||||
cache_add_dir(path, dir);
|
||||
} else {
|
||||
g_strfreev(dir);
|
||||
g_ptr_array_free(dir, TRUE);
|
||||
}
|
||||
g_ptr_array_free(ch.dir, FALSE);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU LGPL.
|
||||
See the file COPYING.LIB
|
||||
*/
|
||||
|
||||
#include "fuse_opt.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
struct fuse_opt_context {
|
||||
void *data;
|
||||
const struct fuse_opt *opt;
|
||||
fuse_opt_proc_t proc;
|
||||
int argctr;
|
||||
int argc;
|
||||
char **argv;
|
||||
struct fuse_args outargs;
|
||||
char *opts;
|
||||
int nonopt;
|
||||
};
|
||||
|
||||
void fuse_opt_free_args(struct fuse_args *args)
|
||||
{
|
||||
if (args && args->argv && args->allocated) {
|
||||
int i;
|
||||
for (i = 0; i < args->argc; i++)
|
||||
free(args->argv[i]);
|
||||
free(args->argv);
|
||||
args->argv = NULL;
|
||||
args->allocated = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int alloc_failed(void)
|
||||
{
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fuse_opt_add_arg(struct fuse_args *args, const char *arg)
|
||||
{
|
||||
char **newargv;
|
||||
char *newarg;
|
||||
|
||||
assert(!args->argv || args->allocated);
|
||||
|
||||
newargv = realloc(args->argv, (args->argc + 2) * sizeof(char *));
|
||||
newarg = newargv ? strdup(arg) : NULL;
|
||||
if (!newargv || !newarg)
|
||||
return alloc_failed();
|
||||
|
||||
args->argv = newargv;
|
||||
args->allocated = 1;
|
||||
args->argv[args->argc++] = newarg;
|
||||
args->argv[args->argc] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
|
||||
{
|
||||
assert(pos <= args->argc);
|
||||
if (fuse_opt_add_arg(args, arg) == -1)
|
||||
return -1;
|
||||
|
||||
if (pos != args->argc - 1) {
|
||||
char *newarg = args->argv[args->argc - 1];
|
||||
memmove(&args->argv[pos + 1], &args->argv[pos],
|
||||
sizeof(char *) * (args->argc - pos - 1));
|
||||
args->argv[pos] = newarg;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int next_arg(struct fuse_opt_context *ctx, const char *opt)
|
||||
{
|
||||
if (ctx->argctr + 1 >= ctx->argc) {
|
||||
fprintf(stderr, "fuse: missing argument after `%s'\n", opt);
|
||||
return -1;
|
||||
}
|
||||
ctx->argctr++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_arg(struct fuse_opt_context *ctx, const char *arg)
|
||||
{
|
||||
return fuse_opt_add_arg(&ctx->outargs, arg);
|
||||
}
|
||||
|
||||
int fuse_opt_add_opt(char **opts, const char *opt)
|
||||
{
|
||||
char *newopts;
|
||||
if (!*opts)
|
||||
newopts = strdup(opt);
|
||||
else {
|
||||
unsigned oldlen = strlen(*opts);
|
||||
newopts = realloc(*opts, oldlen + 1 + strlen(opt) + 1);
|
||||
if (newopts) {
|
||||
newopts[oldlen] = ',';
|
||||
strcpy(newopts + oldlen + 1, opt);
|
||||
}
|
||||
}
|
||||
if (!newopts)
|
||||
return alloc_failed();
|
||||
|
||||
*opts = newopts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_opt(struct fuse_opt_context *ctx, const char *opt)
|
||||
{
|
||||
return fuse_opt_add_opt(&ctx->opts, opt);
|
||||
}
|
||||
|
||||
static int call_proc(struct fuse_opt_context *ctx, const char *arg, int key,
|
||||
int iso)
|
||||
{
|
||||
if (key == FUSE_OPT_KEY_DISCARD)
|
||||
return 0;
|
||||
|
||||
if (key != FUSE_OPT_KEY_KEEP && ctx->proc) {
|
||||
int res = ctx->proc(ctx->data, arg, key, &ctx->outargs);
|
||||
if (res == -1 || !res)
|
||||
return res;
|
||||
}
|
||||
if (iso)
|
||||
return add_opt(ctx, arg);
|
||||
else
|
||||
return add_arg(ctx, arg);
|
||||
}
|
||||
|
||||
static int match_template(const char *t, const char *arg, unsigned *sepp)
|
||||
{
|
||||
int arglen = strlen(arg);
|
||||
const char *sep = strchr(t, '=');
|
||||
sep = sep ? sep : strchr(t, ' ');
|
||||
if (sep && (!sep[1] || sep[1] == '%')) {
|
||||
int tlen = sep - t;
|
||||
if (sep[0] == '=')
|
||||
tlen ++;
|
||||
if (arglen >= tlen && strncmp(arg, t, tlen) == 0) {
|
||||
*sepp = sep - t;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (strcmp(t, arg) == 0) {
|
||||
*sepp = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct fuse_opt *find_opt(const struct fuse_opt *opt,
|
||||
const char *arg, unsigned *sepp)
|
||||
{
|
||||
for (; opt && opt->templ; opt++)
|
||||
if (match_template(opt->templ, arg, sepp))
|
||||
return opt;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fuse_opt_match(const struct fuse_opt *opts, const char *opt)
|
||||
{
|
||||
unsigned dummy;
|
||||
return find_opt(opts, opt, &dummy) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int process_opt_param(void *var, const char *format, const char *param,
|
||||
const char *arg)
|
||||
{
|
||||
assert(format[0] == '%');
|
||||
if (format[1] == 's') {
|
||||
char *copy = strdup(param);
|
||||
if (!copy)
|
||||
return alloc_failed();
|
||||
|
||||
*(char **) var = copy;
|
||||
} else {
|
||||
if (sscanf(param, format, var) != 1) {
|
||||
fprintf(stderr, "fuse: invalid parameter in option `%s'\n", arg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_opt(struct fuse_opt_context *ctx,
|
||||
const struct fuse_opt *opt, unsigned sep,
|
||||
const char *arg, int iso)
|
||||
{
|
||||
if (opt->offset == -1U) {
|
||||
if (call_proc(ctx, arg, opt->value, iso) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
void *var = ctx->data + opt->offset;
|
||||
if (sep && opt->templ[sep + 1]) {
|
||||
const char *param = arg + sep;
|
||||
if (opt->templ[sep] == '=')
|
||||
param ++;
|
||||
if (process_opt_param(var, opt->templ + sep + 1,
|
||||
param, arg) == -1)
|
||||
return -1;
|
||||
} else
|
||||
*(int *)var = opt->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_opt_sep_arg(struct fuse_opt_context *ctx,
|
||||
const struct fuse_opt *opt, unsigned sep,
|
||||
const char *arg, int iso)
|
||||
{
|
||||
int res;
|
||||
char *newarg;
|
||||
char *param;
|
||||
|
||||
if (next_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
|
||||
param = ctx->argv[ctx->argctr];
|
||||
newarg = malloc(sep + strlen(param) + 1);
|
||||
if (!newarg)
|
||||
return alloc_failed();
|
||||
|
||||
memcpy(newarg, arg, sep);
|
||||
strcpy(newarg + sep, param);
|
||||
res = process_opt(ctx, opt, sep, newarg, iso);
|
||||
free(newarg);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int process_gopt(struct fuse_opt_context *ctx, const char *arg, int iso)
|
||||
{
|
||||
unsigned sep;
|
||||
const struct fuse_opt *opt = find_opt(ctx->opt, arg, &sep);
|
||||
if (opt) {
|
||||
for (; opt; opt = find_opt(opt + 1, arg, &sep)) {
|
||||
int res;
|
||||
if (sep && opt->templ[sep] == ' ' && !arg[sep])
|
||||
res = process_opt_sep_arg(ctx, opt, sep, arg, iso);
|
||||
else
|
||||
res = process_opt(ctx, opt, sep, arg, iso);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else
|
||||
return call_proc(ctx, arg, FUSE_OPT_KEY_OPT, iso);
|
||||
}
|
||||
|
||||
static int process_real_option_group(struct fuse_opt_context *ctx, char *opts)
|
||||
{
|
||||
char *sep;
|
||||
|
||||
do {
|
||||
int res;
|
||||
sep = strchr(opts, ',');
|
||||
if (sep)
|
||||
*sep = '\0';
|
||||
res = process_gopt(ctx, opts, 1);
|
||||
if (res == -1)
|
||||
return -1;
|
||||
opts = sep + 1;
|
||||
} while (sep);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_option_group(struct fuse_opt_context *ctx, const char *opts)
|
||||
{
|
||||
int res;
|
||||
char *copy;
|
||||
const char *sep = strchr(opts, ',');
|
||||
if (!sep)
|
||||
return process_gopt(ctx, opts, 1);
|
||||
|
||||
copy = strdup(opts);
|
||||
if (!copy) {
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
res = process_real_option_group(ctx, copy);
|
||||
free(copy);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int process_one(struct fuse_opt_context *ctx, const char *arg)
|
||||
{
|
||||
if (ctx->nonopt || arg[0] != '-')
|
||||
return call_proc(ctx, arg, FUSE_OPT_KEY_NONOPT, 0);
|
||||
else if (arg[1] == 'o') {
|
||||
if (arg[2])
|
||||
return process_option_group(ctx, arg + 2);
|
||||
else {
|
||||
if (next_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
|
||||
return process_option_group(ctx, ctx->argv[ctx->argctr]);
|
||||
}
|
||||
} else if (arg[1] == '-' && !arg[2]) {
|
||||
if (add_arg(ctx, arg) == -1)
|
||||
return -1;
|
||||
ctx->nonopt = ctx->outargs.argc;
|
||||
return 0;
|
||||
} else
|
||||
return process_gopt(ctx, arg, 0);
|
||||
}
|
||||
|
||||
static int opt_parse(struct fuse_opt_context *ctx)
|
||||
{
|
||||
if (ctx->argc) {
|
||||
if (add_arg(ctx, ctx->argv[0]) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ctx->argctr = 1; ctx->argctr < ctx->argc; ctx->argctr++)
|
||||
if (process_one(ctx, ctx->argv[ctx->argctr]) == -1)
|
||||
return -1;
|
||||
|
||||
if (ctx->opts) {
|
||||
if (fuse_opt_insert_arg(&ctx->outargs, 1, "-o") == -1 ||
|
||||
fuse_opt_insert_arg(&ctx->outargs, 2, ctx->opts) == -1)
|
||||
return -1;
|
||||
}
|
||||
if (ctx->nonopt && ctx->nonopt == ctx->outargs.argc) {
|
||||
free(ctx->outargs.argv[ctx->outargs.argc - 1]);
|
||||
ctx->outargs.argv[--ctx->outargs.argc] = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuse_opt_parse(struct fuse_args *args, void *data,
|
||||
const struct fuse_opt opts[], fuse_opt_proc_t proc)
|
||||
{
|
||||
int res;
|
||||
struct fuse_opt_context ctx = {
|
||||
.data = data,
|
||||
.opt = opts,
|
||||
.proc = proc,
|
||||
};
|
||||
|
||||
if (!args || !args->argv || !args->argc)
|
||||
return 0;
|
||||
|
||||
ctx.argc = args->argc;
|
||||
ctx.argv = args->argv;
|
||||
|
||||
res = opt_parse(&ctx);
|
||||
if (res != -1) {
|
||||
struct fuse_args tmp = *args;
|
||||
*args = ctx.outargs;
|
||||
ctx.outargs = tmp;
|
||||
}
|
||||
free(ctx.opts);
|
||||
fuse_opt_free_args(&ctx.outargs);
|
||||
return res;
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
/*
|
||||
FUSE: Filesystem in Userspace
|
||||
Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
This program can be distributed under the terms of the GNU GPL.
|
||||
See the file COPYING.
|
||||
*/
|
||||
|
||||
#ifndef _FUSE_OPT_H_
|
||||
#define _FUSE_OPT_H_
|
||||
|
||||
/* This file defines the option parsing interface of FUSE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Option description
|
||||
*
|
||||
* This structure describes a single option, and and action associated
|
||||
* with it, in case it matches.
|
||||
*
|
||||
* More than one such match may occur, in which case the action for
|
||||
* each match is executed.
|
||||
*
|
||||
* There are three possible actions in case of a match:
|
||||
*
|
||||
* i) An integer (int or unsigned) variable determined by 'offset' is
|
||||
* set to 'value'
|
||||
*
|
||||
* ii) The processing function is called, with 'value' as the key
|
||||
*
|
||||
* iii) An integer (any) or string (char *) variable determined by
|
||||
* 'offset' is set to the value of an option parameter
|
||||
*
|
||||
* 'offset' should normally be either set to
|
||||
*
|
||||
* - 'offsetof(struct foo, member)' actions i) and iii)
|
||||
*
|
||||
* - -1 action ii)
|
||||
*
|
||||
* The 'offsetof()' macro is defined in the <stddef.h> header.
|
||||
*
|
||||
* The template determines which options match, and also have an
|
||||
* effect on the action. Normally the action is either i) or ii), but
|
||||
* if a format is present in the template, then action iii) is
|
||||
* performed.
|
||||
*
|
||||
* The types of templates are:
|
||||
*
|
||||
* 1) "-x", "-foo", "--foo", "--foo-bar", etc. These match only
|
||||
* themselves. Invalid values are "--" and anything beginning
|
||||
* with "-o"
|
||||
*
|
||||
* 2) "foo", "foo-bar", etc. These match "-ofoo", "-ofoo-bar" or
|
||||
* the relevant option in a comma separated option list
|
||||
*
|
||||
* 3) "bar=", "--foo=", etc. These are variations of 1) and 2)
|
||||
* which have a parameter
|
||||
*
|
||||
* 4) "bar=%s", "--foo=%lu", etc. Same matching as above but perform
|
||||
* action iii).
|
||||
*
|
||||
* 5) "-x ", etc. Matches either "-xparam" or "-x param" as
|
||||
* two separate arguments
|
||||
*
|
||||
* 6) "-x %s", etc. Combination of 4) and 5)
|
||||
*
|
||||
* If the format is "%s", memory is allocated for the string unlike
|
||||
* with scanf().
|
||||
*/
|
||||
struct fuse_opt {
|
||||
/** Matching template and optional parameter formatting */
|
||||
const char *templ;
|
||||
|
||||
/**
|
||||
* Offset of variable within 'data' parameter of fuse_opt_parse()
|
||||
* or -1
|
||||
*/
|
||||
unsigned long offset;
|
||||
|
||||
/**
|
||||
* Value to set the variable to, or to be passed as 'key' to the
|
||||
* processing function. Ignored if template has a format
|
||||
*/
|
||||
int value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Key option. In case of a match, the processing function will be
|
||||
* called with the specified key.
|
||||
*/
|
||||
#define FUSE_OPT_KEY(templ, key) { templ, -1U, key }
|
||||
|
||||
/**
|
||||
* Last option. An array of 'struct fuse_opt' must end with a NULL
|
||||
* template value
|
||||
*/
|
||||
#define FUSE_OPT_END { .templ = NULL }
|
||||
|
||||
/**
|
||||
* Argument list
|
||||
*/
|
||||
struct fuse_args {
|
||||
/** Argument count */
|
||||
int argc;
|
||||
|
||||
/** Argument vector. NULL terminated */
|
||||
char **argv;
|
||||
|
||||
/** Is 'argv' allocated? */
|
||||
int allocated;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializer for 'struct fuse_args'
|
||||
*/
|
||||
#define FUSE_ARGS_INIT(argc, argv) { argc, argv, 0 }
|
||||
|
||||
/**
|
||||
* Key value passed to the processing function if an option did not
|
||||
* match any template
|
||||
*/
|
||||
#define FUSE_OPT_KEY_OPT -1
|
||||
|
||||
/**
|
||||
* Key value passed to the processing function for all non-options
|
||||
*
|
||||
* Non-options are the arguments beginning with a charater other than
|
||||
* '-' or all arguments after the special '--' option
|
||||
*/
|
||||
#define FUSE_OPT_KEY_NONOPT -2
|
||||
|
||||
/**
|
||||
* Special key value for options to keep
|
||||
*
|
||||
* Argument is not passed to processing function, but behave as if the
|
||||
* processing function returned 1
|
||||
*/
|
||||
#define FUSE_OPT_KEY_KEEP -3
|
||||
|
||||
/**
|
||||
* Special key value for options to discard
|
||||
*
|
||||
* Argument is not passed to processing function, but behave as if the
|
||||
* processing function returned zero
|
||||
*/
|
||||
#define FUSE_OPT_KEY_DISCARD -4
|
||||
|
||||
/**
|
||||
* Processing function
|
||||
*
|
||||
* This function is called if
|
||||
* - option did not match any 'struct fuse_opt'
|
||||
* - argument is a non-option
|
||||
* - option did match and offset was set to -1
|
||||
*
|
||||
* The 'arg' parameter will always contain the whole argument or
|
||||
* option including the parameter if exists. A two-argument option
|
||||
* ("-x foo") is always converted to single arguemnt option of the
|
||||
* form "-xfoo" before this function is called.
|
||||
*
|
||||
* Options of the form '-ofoo' are passed to this function without the
|
||||
* '-o' prefix.
|
||||
*
|
||||
* The return value of this function determines whether this argument
|
||||
* is to be inserted into the output argument vector, or discarded.
|
||||
*
|
||||
* @param data is the user data passed to the fuse_opt_parse() function
|
||||
* @param arg is the whole argument or option
|
||||
* @param key determines why the processing function was called
|
||||
* @param outargs the current output argument list
|
||||
* @return -1 on error, 0 if arg is to be discarded, 1 if arg should be kept
|
||||
*/
|
||||
typedef int (*fuse_opt_proc_t)(void *data, const char *arg, int key,
|
||||
struct fuse_args *outargs);
|
||||
|
||||
/**
|
||||
* Option parsing function
|
||||
*
|
||||
* If 'args' was returned from a previous call to fuse_opt_parse() or
|
||||
* it was constructed from
|
||||
*
|
||||
* A NULL 'args' is equivalent to an empty argument vector
|
||||
*
|
||||
* A NULL 'opts' is equivalent to an 'opts' array containing a single
|
||||
* end marker
|
||||
*
|
||||
* A NULL 'proc' is equivalent to a processing function always
|
||||
* returning '1'
|
||||
*
|
||||
* @param args is the input and output argument list
|
||||
* @param data is the user data
|
||||
* @param opts is the option description array
|
||||
* @param proc is the processing function
|
||||
* @return -1 on error, 0 on success
|
||||
*/
|
||||
int fuse_opt_parse(struct fuse_args *args, void *data,
|
||||
const struct fuse_opt opts[], fuse_opt_proc_t proc);
|
||||
|
||||
/**
|
||||
* Add an option to a comma separated option list
|
||||
*
|
||||
* @param opts is a pointer to an option list, may point to a NULL value
|
||||
* @param opt is the option to add
|
||||
* @return -1 on allocation error, 0 on success
|
||||
*/
|
||||
int fuse_opt_add_opt(char **opts, const char *opt);
|
||||
|
||||
/**
|
||||
* Add an argument to a NULL terminated argument vector
|
||||
*
|
||||
* @param args is the structure containing the current argument list
|
||||
* @param arg is the new argument to add
|
||||
* @return -1 on allocation error, 0 on success
|
||||
*/
|
||||
int fuse_opt_add_arg(struct fuse_args *args, const char *arg);
|
||||
|
||||
/**
|
||||
* Add an argument at the specified position in a NULL terminated
|
||||
* argument vector
|
||||
*
|
||||
* Adds the argument to the N-th position. This is useful for adding
|
||||
* options at the beggining of the array which must not come after the
|
||||
* special '--' option.
|
||||
*
|
||||
* @param args is the structure containing the current argument list
|
||||
* @param pos is the position at which to add the argument
|
||||
* @param arg is the new argument to add
|
||||
* @return -1 on allocation error, 0 on success
|
||||
*/
|
||||
int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg);
|
||||
|
||||
/**
|
||||
* Free the contents of argument list
|
||||
*
|
||||
* The structure itself is not freed
|
||||
*
|
||||
* @param args is the structure containing the argument list
|
||||
*/
|
||||
void fuse_opt_free_args(struct fuse_args *args);
|
||||
|
||||
|
||||
/**
|
||||
* Check if an option matches
|
||||
*
|
||||
* @param opts is the option description array
|
||||
* @param opt is the option to match
|
||||
* @return 1 if a match is found, 0 if not
|
||||
*/
|
||||
int fuse_opt_match(const struct fuse_opt opts[], const char *opt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FUSE_OPT_H_ */
|
||||
@@ -27,4 +27,3 @@ gpg --armor --detach-sign "${TAG}.tar.xz"
|
||||
PREV_TAG="$(git tag --list 'sshfs-3*' --sort=-taggerdate --merged "${TAG}^"| head -1)"
|
||||
echo "Contributors from ${PREV_TAG} to ${TAG}:"
|
||||
git log --pretty="format:%an <%aE>" "${PREV_TAG}..${TAG}" | sort -u
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
project('sshfs', 'c', version: '3.6.0',
|
||||
project('sshfs', 'c', version: '3.7.5',
|
||||
meson_version: '>= 0.40',
|
||||
default_options: [ 'buildtype=debugoptimized' ])
|
||||
|
||||
@@ -26,7 +26,7 @@ endif
|
||||
|
||||
|
||||
rst2man = find_program('rst2man', 'rst2man.py', required: false)
|
||||
|
||||
|
||||
cfg = configuration_data()
|
||||
|
||||
cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||
@@ -34,8 +34,9 @@ cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
|
||||
include_dirs = [ include_directories('.') ]
|
||||
sshfs_sources = ['sshfs.c', 'cache.c']
|
||||
if target_machine.system() == 'darwin'
|
||||
add_global_arguments('-DFUSE_DARWIN_ENABLE_EXTENSIONS=0', language: 'c')
|
||||
cfg.set_quoted('IDMAP_DEFAULT', 'user')
|
||||
sshfs_sources += [ 'compat/fuse_opt.c', 'compat/darwin_compat.c' ]
|
||||
sshfs_sources += [ 'compat/darwin_compat.c' ]
|
||||
include_dirs += [ include_directories('compat') ]
|
||||
else
|
||||
cfg.set_quoted('IDMAP_DEFAULT', 'none')
|
||||
@@ -69,4 +70,3 @@ meson.add_install_script('utils/install_helper.sh',
|
||||
|
||||
|
||||
subdir('test')
|
||||
|
||||
|
||||
@@ -27,21 +27,24 @@ To unmount it::
|
||||
Description
|
||||
===========
|
||||
|
||||
SSHFS allows you to mount a remote filesystem using SSH (more
|
||||
precisely, the SFTP subsystem). Most SSH servers support and enable
|
||||
this SFTP access by default, so SSHFS is very simple to use - there's
|
||||
nothing to do on the server-side.
|
||||
SSHFS allows you to mount a remote filesystem using SSH (more precisely, the SFTP
|
||||
subsystem). Most SSH servers support and enable this SFTP access by default, so SSHFS is
|
||||
very simple to use - there's nothing to do on the server-side.
|
||||
|
||||
SSHFS uses FUSE (Filesystem in Userspace) and should work on any
|
||||
operating system that provides a FUSE implementation. Currently,
|
||||
this includes Linux, FreeBSD and Mac OS X.
|
||||
By default, file permissions are ignored by SSHFS. Any user that can access the filesystem
|
||||
will be able to perform any operation that the remote server permits - based on the
|
||||
credentials that were used to connect to the server. If this is undesired, local
|
||||
permission checking can be enabled with ``-o default_permissions``.
|
||||
|
||||
It is recommended to run SSHFS as regular user (not as root). For
|
||||
this to work the mountpoint must be owned by the user. If username is
|
||||
omitted SSHFS will use the local username. If the directory is
|
||||
omitted, SSHFS will mount the (remote) home directory. If you need to
|
||||
enter a password sshfs will ask for it (actually it just runs ssh
|
||||
which ask for the password if needed).
|
||||
By default, only the mounting user will be able to access the filesystem. Access for other
|
||||
users can be enabled by passing ``-o allow_other``. In this case you most likely also
|
||||
want to use ``-o default_permissions``.
|
||||
|
||||
It is recommended to run SSHFS as regular user (not as root). For this to work the
|
||||
mountpoint must be owned by the user. If username is omitted SSHFS will use the local
|
||||
username. If the directory is omitted, SSHFS will mount the (remote) home directory. If
|
||||
you need to enter a password sshfs will ask for it (actually it just runs ssh which ask
|
||||
for the password if needed).
|
||||
|
||||
|
||||
Options
|
||||
@@ -153,8 +156,14 @@ Options
|
||||
-o directport=PORT
|
||||
directly connect to PORT bypassing ssh
|
||||
|
||||
-o slave
|
||||
communicate over stdin and stdout bypassing network
|
||||
-o vsock=CID:PORT
|
||||
directly connect using a vsock to CID:PORT bypassing ssh
|
||||
|
||||
-o passive
|
||||
communicate over stdin and stdout bypassing network. Useful for
|
||||
mounting local filesystem on the remote side. An example using
|
||||
dpipe command would be ``dpipe /usr/lib/openssh/sftp-server = ssh
|
||||
RemoteHostname sshfs :/directory/to/be/shared ~/mnt/src -o passive``
|
||||
|
||||
-o disable_hardlink
|
||||
With this option set, attempts to call `link(2)` will fail with
|
||||
@@ -184,17 +193,17 @@ Options
|
||||
directory cache holds the names of directory entries. Enabling it
|
||||
allows `readdir(3)` system calls to be processed without network
|
||||
access.
|
||||
|
||||
|
||||
-o dcache_max_size=N
|
||||
sets the maximum size of the directory cache.
|
||||
|
||||
|
||||
-o dcache_timeout=N
|
||||
sets timeout for directory cache in seconds.
|
||||
|
||||
|
||||
-o dcache_{stat,link,dir}_timeout=N
|
||||
sets separate timeout for {attributes, symlinks, names} in the
|
||||
directory cache.
|
||||
|
||||
|
||||
-o dcache_clean_interval=N
|
||||
sets the interval for automatic cleaning of the directory cache.
|
||||
|
||||
@@ -203,15 +212,25 @@ Options
|
||||
when full.
|
||||
|
||||
-o direct_io
|
||||
This option disables the use of page cache (file content cache) in
|
||||
This option disables the use of page cache (file content cache) in
|
||||
the kernel for this filesystem.
|
||||
This has several affects:
|
||||
|
||||
1. Each read() or write() system call will initiate one or more read or
|
||||
write operations, data will not be cached in the kernel.
|
||||
2. The return value of the read() and write() system calls will correspond
|
||||
to the return values of the read and write operations. This is useful
|
||||
|
||||
2. The return value of the read() and write() system calls will correspond
|
||||
to the return values of the read and write operations. This is useful
|
||||
for example if the file size is not known in advance (before reading it).
|
||||
e.g. /proc filesystem
|
||||
e.g. /proc filesystem
|
||||
|
||||
-o max_conns=N
|
||||
sets the maximum number of simultaneous SSH connections
|
||||
to use. Each connection is established with a separate SSH process.
|
||||
The primary purpose of this feature is to improve the responsiveness of the
|
||||
file system during large file transfers. When using more than once
|
||||
connection, the *password_stdin* and *passive* options can not be
|
||||
used, and the *buflimit* workaround is not supported.
|
||||
|
||||
In addition, SSHFS accepts several options common to all FUSE file
|
||||
systems. These are described in the `mount.fuse` manpage (look
|
||||
@@ -258,7 +277,7 @@ SSHFS hangs for no apparent reason
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
In some cases, attempts to access the SSHFS mountpoint may freeze if
|
||||
no filesystem activity has occured for some time. This is typically
|
||||
no filesystem activity has occurred for some time. This is typically
|
||||
caused by the SSH connection being dropped because of inactivity
|
||||
without SSHFS being informed about that. As a workaround, you can try
|
||||
to mount with ``-o ServerAliveInterval=15``. This will force the SSH
|
||||
@@ -295,7 +314,7 @@ interrupted.
|
||||
Mounting from /etc/fstab
|
||||
========================
|
||||
|
||||
To mount an SSHFS filesystem from ``/etc/fstab``, simply use ``sshfs`
|
||||
To mount an SSHFS filesystem from ``/etc/fstab``, simply use ``sshfs``
|
||||
as the file system type. (For backwards compatibility, you may also
|
||||
use ``fuse.sshfs``).
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
machine=$(uname -m)
|
||||
mkdir build-$machine
|
||||
cd build-$machine
|
||||
mkdir "build-$machine"
|
||||
cd "build-$machine"
|
||||
meson ..
|
||||
ninja
|
||||
|
||||
+44
-21
@@ -3,24 +3,28 @@ import pytest
|
||||
import time
|
||||
import re
|
||||
|
||||
# If a test fails, wait a moment before retrieving the captured
|
||||
# stdout/stderr. When using a server process, this makes sure that we capture
|
||||
# any potential output of the server that comes *after* a test has failed. For
|
||||
# example, if a request handler raises an exception, the server first signals an
|
||||
# error to FUSE (causing the test to fail), and then logs the exception. Without
|
||||
# the extra delay, the exception will go into nowhere.
|
||||
@pytest.mark.hookwrapper
|
||||
# If a test fails, wait a moment before retrieving the captured stdout/stderr.
|
||||
# When using a server process, this makes sure that we capture any potential
|
||||
# output of the server that comes *after* a test has failed. For example, if a
|
||||
# request handler raises an exception, the server first signals an error to
|
||||
# FUSE (causing the test to fail), and then logs the exception. Without the
|
||||
# extra delay, the exception will go into nowhere.
|
||||
|
||||
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_pyfunc_call(pyfuncitem):
|
||||
outcome = yield
|
||||
failed = outcome.excinfo is not None
|
||||
if failed:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def pass_capfd(request, capfd):
|
||||
'''Provide capfd object to UnitTest instances'''
|
||||
"""Provide capfd object to UnitTest instances"""
|
||||
request.instance.capfd = capfd
|
||||
|
||||
|
||||
def check_test_output(capfd):
|
||||
(stdout, stderr) = capfd.readouterr()
|
||||
|
||||
@@ -31,39 +35,57 @@ def check_test_output(capfd):
|
||||
# Strip out false positives
|
||||
for (pattern, flags, count) in capfd.false_positives:
|
||||
cp = re.compile(pattern, flags)
|
||||
(stdout, cnt) = cp.subn('', stdout, count=count)
|
||||
(stdout, cnt) = cp.subn("", stdout, count=count)
|
||||
if count == 0 or count - cnt > 0:
|
||||
stderr = cp.sub('', stderr, count=count - cnt)
|
||||
stderr = cp.sub("", stderr, count=count - cnt)
|
||||
|
||||
patterns = [ r'\b{}\b'.format(x) for x in
|
||||
('exception', 'error', 'warning', 'fatal', 'traceback',
|
||||
'fault', 'crash(?:ed)?', 'abort(?:ed)',
|
||||
'uninitiali[zs]ed') ]
|
||||
patterns += ['^==[0-9]+== ']
|
||||
patterns = [
|
||||
r"\b{}\b".format(x)
|
||||
for x in (
|
||||
"exception",
|
||||
"error",
|
||||
"warning",
|
||||
"fatal",
|
||||
"traceback",
|
||||
"fault",
|
||||
"crash(?:ed)?",
|
||||
"abort(?:ed)",
|
||||
"uninitiali[zs]ed",
|
||||
)
|
||||
]
|
||||
patterns += ["^==[0-9]+== "]
|
||||
for pattern in patterns:
|
||||
cp = re.compile(pattern, re.IGNORECASE | re.MULTILINE)
|
||||
hit = cp.search(stderr)
|
||||
if hit:
|
||||
raise AssertionError('Suspicious output to stderr (matched "%s")' % hit.group(0))
|
||||
raise AssertionError(
|
||||
'Suspicious output to stderr (matched "%s")' % hit.group(0)
|
||||
)
|
||||
hit = cp.search(stdout)
|
||||
if hit:
|
||||
raise AssertionError('Suspicious output to stdout (matched "%s")' % hit.group(0))
|
||||
raise AssertionError(
|
||||
'Suspicious output to stdout (matched "%s")' % hit.group(0)
|
||||
)
|
||||
|
||||
|
||||
def register_output(self, pattern, count=1, flags=re.MULTILINE):
|
||||
'''Register *pattern* as false positive for output checking
|
||||
"""Register *pattern* as false positive for output checking
|
||||
|
||||
This prevents the test from failing because the output otherwise
|
||||
appears suspicious.
|
||||
'''
|
||||
"""
|
||||
|
||||
self.false_positives.append((pattern, flags, count))
|
||||
|
||||
|
||||
# This is a terrible hack that allows us to access the fixtures from the
|
||||
# pytest_runtest_call hook. Among a lot of other hidden assumptions, it probably
|
||||
# relies on tests running sequential (i.e., don't dare to use e.g. the xdist
|
||||
# plugin)
|
||||
current_capfd = None
|
||||
@pytest.yield_fixture(autouse=True)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def save_cap_fixtures(request, capfd):
|
||||
global current_capfd
|
||||
capfd.false_positives = []
|
||||
@@ -71,7 +93,7 @@ def save_cap_fixtures(request, capfd):
|
||||
# Monkeypatch in a function to register false positives
|
||||
type(capfd).register_output = register_output
|
||||
|
||||
if request.config.getoption('capture') == 'no':
|
||||
if request.config.getoption("capture") == "no":
|
||||
capfd = None
|
||||
current_capfd = capfd
|
||||
bak = current_capfd
|
||||
@@ -82,6 +104,7 @@ def save_cap_fixtures(request, capfd):
|
||||
assert bak is current_capfd
|
||||
current_capfd = None
|
||||
|
||||
|
||||
@pytest.hookimpl(trylast=True)
|
||||
def pytest_runtest_call(item):
|
||||
capfd = current_capfd
|
||||
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
pip3 install --user pre-commit
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
+1
-1
@@ -2,7 +2,7 @@ test_scripts = [ 'conftest.py', 'pytest.ini', 'test_sshfs.py',
|
||||
'util.py' ]
|
||||
custom_target('test_scripts', input: test_scripts,
|
||||
output: test_scripts, build_by_default: true,
|
||||
command: ['cp', '-fPp',
|
||||
command: ['cp', '-fPp',
|
||||
'@INPUT@', meson.current_build_dir() ])
|
||||
|
||||
# Provide something helpful when running 'ninja test'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
[pytest]
|
||||
addopts = --verbose --assert=rewrite --tb=native -x -r a
|
||||
|
||||
markers = uses_fuse: Mark to indicate that FUSE is available on the system running the test
|
||||
|
||||
+572
-104
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
sys.exit(pytest.main([__file__] + sys.argv[1:]))
|
||||
|
||||
import subprocess
|
||||
@@ -13,78 +14,128 @@ import stat
|
||||
import shutil
|
||||
import filecmp
|
||||
import errno
|
||||
from contextlib import contextmanager
|
||||
from tempfile import NamedTemporaryFile
|
||||
from util import (wait_for_mount, umount, cleanup, base_cmdline,
|
||||
basename, fuse_test_marker, safe_sleep)
|
||||
from util import (
|
||||
wait_for_mount,
|
||||
umount,
|
||||
cleanup,
|
||||
base_cmdline,
|
||||
basename,
|
||||
fuse_test_marker,
|
||||
safe_sleep,
|
||||
os_create,
|
||||
os_open,
|
||||
)
|
||||
from os.path import join as pjoin
|
||||
|
||||
TEST_FILE = __file__
|
||||
|
||||
pytestmark = fuse_test_marker()
|
||||
|
||||
with open(TEST_FILE, 'rb') as fh:
|
||||
with open(TEST_FILE, "rb") as fh:
|
||||
TEST_DATA = fh.read()
|
||||
|
||||
def name_generator(__ctr=[0]):
|
||||
__ctr[0] += 1
|
||||
return 'testfile_%d' % __ctr[0]
|
||||
|
||||
@pytest.mark.parametrize("debug", (False, True))
|
||||
@pytest.mark.parametrize("cache_timeout", (0,1))
|
||||
@pytest.mark.parametrize("sync_rd", (True, False))
|
||||
def test_sshfs(tmpdir, debug, cache_timeout, sync_rd, capfd):
|
||||
|
||||
def name_generator(__ctr=[0]) -> str:
|
||||
"""Generate a fresh filename on each call"""
|
||||
|
||||
__ctr[0] += 1
|
||||
return f"testfile_{__ctr[0]}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"debug",
|
||||
[pytest.param(False, id="debug=false"), pytest.param(True, id="debug=true")],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"cache_timeout",
|
||||
[pytest.param(0, id="cache_timeout=0"), pytest.param(1, id="cache_timeout=1")],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"sync_rd",
|
||||
[pytest.param(True, id="sync_rd=true"), pytest.param(False, id="sync_rd=false")],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"multiconn",
|
||||
[
|
||||
pytest.param(True, id="multiconn=true"),
|
||||
pytest.param(False, id="multiconn=false"),
|
||||
],
|
||||
)
|
||||
def test_sshfs(
|
||||
tmpdir, debug: bool, cache_timeout: int, sync_rd: bool, multiconn: bool, capfd
|
||||
) -> None:
|
||||
|
||||
# Avoid false positives from debug messages
|
||||
#if debug:
|
||||
# if debug:
|
||||
# capfd.register_output(r'^ unique: [0-9]+, error: -[0-9]+ .+$',
|
||||
# count=0)
|
||||
|
||||
# Avoid false positives from storing key for localhost
|
||||
capfd.register_output(r"^Warning: Permanently added 'localhost' .+", count=0)
|
||||
|
||||
# Test if we can ssh into localhost without password
|
||||
try:
|
||||
res = subprocess.call(['ssh', '-o', 'KbdInteractiveAuthentication=no',
|
||||
'-o', 'ChallengeResponseAuthentication=no',
|
||||
'-o', 'PasswordAuthentication=no',
|
||||
'localhost', '--', 'true'], stdin=subprocess.DEVNULL,
|
||||
timeout=10)
|
||||
res = subprocess.call(
|
||||
[
|
||||
"ssh",
|
||||
"-o",
|
||||
"StrictHostKeyChecking=no",
|
||||
"-o",
|
||||
"KbdInteractiveAuthentication=no",
|
||||
"-o",
|
||||
"ChallengeResponseAuthentication=no",
|
||||
"-o",
|
||||
"PasswordAuthentication=no",
|
||||
"localhost",
|
||||
"--",
|
||||
"true",
|
||||
],
|
||||
stdin=subprocess.DEVNULL,
|
||||
timeout=10,
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
res = 1
|
||||
if res != 0:
|
||||
pytest.fail('Unable to ssh into localhost without password prompt.')
|
||||
pytest.fail("Unable to ssh into localhost without password prompt.")
|
||||
|
||||
mnt_dir = str(tmpdir.mkdir('mnt'))
|
||||
src_dir = str(tmpdir.mkdir('src'))
|
||||
mnt_dir = str(tmpdir.mkdir("mnt"))
|
||||
src_dir = str(tmpdir.mkdir("src"))
|
||||
|
||||
cmdline = base_cmdline + [ pjoin(basename, 'sshfs'),
|
||||
'-f', 'localhost:' + src_dir, mnt_dir ]
|
||||
cmdline = base_cmdline + [
|
||||
pjoin(basename, "sshfs"),
|
||||
"-f",
|
||||
f"localhost:{src_dir}",
|
||||
mnt_dir,
|
||||
]
|
||||
if debug:
|
||||
cmdline += [ '-o', 'sshfs_debug' ]
|
||||
cmdline += ["-o", "sshfs_debug"]
|
||||
|
||||
if sync_rd:
|
||||
cmdline += [ '-o', 'sync_readdir' ]
|
||||
cmdline += ["-o", "sync_readdir"]
|
||||
|
||||
# SSHFS Cache
|
||||
if cache_timeout == 0:
|
||||
cmdline += [ '-o', 'dir_cache=no' ]
|
||||
cmdline += ["-o", "dir_cache=no"]
|
||||
else:
|
||||
cmdline += [ '-o', 'dcache_timeout=%d' % cache_timeout,
|
||||
'-o', 'dir_cache=yes' ]
|
||||
cmdline += ["-o", f"dcache_timeout={cache_timeout}", "-o", "dir_cache=yes"]
|
||||
|
||||
# FUSE Cache
|
||||
cmdline += [ '-o', 'entry_timeout=0',
|
||||
'-o', 'attr_timeout=0' ]
|
||||
cmdline += ["-o", "entry_timeout=0", "-o", "attr_timeout=0"]
|
||||
|
||||
|
||||
new_env = dict(os.environ) # copy, don't modify
|
||||
if multiconn:
|
||||
cmdline += ["-o", "max_conns=3"]
|
||||
|
||||
new_env = dict(os.environ) # copy, don't modify
|
||||
|
||||
# Abort on warnings from glib
|
||||
new_env['G_DEBUG'] = 'fatal-warnings'
|
||||
|
||||
new_env["G_DEBUG"] = "fatal-warnings"
|
||||
|
||||
mount_process = subprocess.Popen(cmdline, env=new_env)
|
||||
try:
|
||||
wait_for_mount(mount_process, mnt_dir)
|
||||
|
||||
tst_statvfs(mnt_dir)
|
||||
tst_statvfs(src_dir, mnt_dir)
|
||||
tst_readdir(src_dir, mnt_dir)
|
||||
tst_open_read(src_dir, mnt_dir)
|
||||
tst_open_write(src_dir, mnt_dir)
|
||||
@@ -94,6 +145,10 @@ def test_sshfs(tmpdir, debug, cache_timeout, sync_rd, capfd):
|
||||
tst_passthrough(src_dir, mnt_dir, cache_timeout)
|
||||
tst_mkdir(mnt_dir)
|
||||
tst_rmdir(src_dir, mnt_dir, cache_timeout)
|
||||
tst_rename(mnt_dir)
|
||||
tst_rename_over(mnt_dir)
|
||||
tst_chmod(mnt_dir)
|
||||
tst_fsync(src_dir, mnt_dir)
|
||||
tst_unlink(src_dir, mnt_dir, cache_timeout)
|
||||
tst_symlink(mnt_dir)
|
||||
if os.getuid() == 0:
|
||||
@@ -108,30 +163,26 @@ def test_sshfs(tmpdir, debug, cache_timeout, sync_rd, capfd):
|
||||
tst_truncate_path(mnt_dir)
|
||||
tst_truncate_fd(mnt_dir)
|
||||
tst_open_unlink(mnt_dir)
|
||||
except:
|
||||
tst_open_writeonly_read(mnt_dir)
|
||||
tst_access(mnt_dir)
|
||||
tst_mkdir_exist(mnt_dir)
|
||||
tst_readdir_repeated(mnt_dir)
|
||||
tst_rename_sibling(mnt_dir)
|
||||
tst_rename_open_release(mnt_dir)
|
||||
except Exception as exc:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
raise exc
|
||||
else:
|
||||
umount(mount_process, mnt_dir)
|
||||
|
||||
@contextmanager
|
||||
def os_open(name, flags):
|
||||
fd = os.open(name, flags)
|
||||
try:
|
||||
yield fd
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
def os_create(name):
|
||||
os.close(os.open(name, os.O_CREAT | os.O_RDWR))
|
||||
|
||||
def tst_unlink(src_dir, mnt_dir, cache_timeout):
|
||||
name = name_generator()
|
||||
fullname = mnt_dir + "/" + name
|
||||
with open(pjoin(src_dir, name), 'wb') as fh:
|
||||
fh.write(b'hello')
|
||||
with open(pjoin(src_dir, name), "wb") as fh:
|
||||
fh.write(b"hello")
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout+1)
|
||||
safe_sleep(cache_timeout + 1)
|
||||
assert name in os.listdir(mnt_dir)
|
||||
os.unlink(fullname)
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
@@ -140,22 +191,24 @@ def tst_unlink(src_dir, mnt_dir, cache_timeout):
|
||||
assert name not in os.listdir(mnt_dir)
|
||||
assert name not in os.listdir(src_dir)
|
||||
|
||||
|
||||
def tst_mkdir(mnt_dir):
|
||||
dirname = name_generator()
|
||||
fullname = mnt_dir + "/" + dirname
|
||||
os.mkdir(fullname)
|
||||
fstat = os.stat(fullname)
|
||||
assert stat.S_ISDIR(fstat.st_mode)
|
||||
assert os.listdir(fullname) == []
|
||||
assert fstat.st_nlink in (1,2)
|
||||
assert os.listdir(fullname) == []
|
||||
assert fstat.st_nlink in (1, 2)
|
||||
assert dirname in os.listdir(mnt_dir)
|
||||
|
||||
|
||||
def tst_rmdir(src_dir, mnt_dir, cache_timeout):
|
||||
name = name_generator()
|
||||
fullname = mnt_dir + "/" + name
|
||||
os.mkdir(pjoin(src_dir, name))
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout+1)
|
||||
safe_sleep(cache_timeout + 1)
|
||||
assert name in os.listdir(mnt_dir)
|
||||
os.rmdir(fullname)
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
@@ -164,6 +217,84 @@ def tst_rmdir(src_dir, mnt_dir, cache_timeout):
|
||||
assert name not in os.listdir(mnt_dir)
|
||||
assert name not in os.listdir(src_dir)
|
||||
|
||||
|
||||
def tst_rename(mnt_dir):
|
||||
src_name = pjoin(mnt_dir, name_generator())
|
||||
dst_name = pjoin(mnt_dir, name_generator())
|
||||
data = b"rename test data\n"
|
||||
|
||||
with open(src_name, "wb") as fh:
|
||||
fh.write(data)
|
||||
assert os.path.exists(src_name)
|
||||
|
||||
os.rename(src_name, dst_name)
|
||||
|
||||
assert not os.path.exists(src_name)
|
||||
assert os.path.basename(src_name) not in os.listdir(mnt_dir)
|
||||
assert os.path.basename(dst_name) in os.listdir(mnt_dir)
|
||||
with open(dst_name, "rb") as fh:
|
||||
assert fh.read() == data
|
||||
|
||||
os.unlink(dst_name)
|
||||
|
||||
|
||||
def tst_rename_over(mnt_dir):
|
||||
src_name = pjoin(mnt_dir, name_generator())
|
||||
dst_name = pjoin(mnt_dir, name_generator())
|
||||
src_data = b"source content\n"
|
||||
dst_data = b"destination content\n"
|
||||
|
||||
with open(src_name, "wb") as fh:
|
||||
fh.write(src_data)
|
||||
with open(dst_name, "wb") as fh:
|
||||
fh.write(dst_data)
|
||||
|
||||
os.rename(src_name, dst_name)
|
||||
|
||||
assert not os.path.exists(src_name)
|
||||
assert os.path.basename(src_name) not in os.listdir(mnt_dir)
|
||||
with open(dst_name, "rb") as fh:
|
||||
assert fh.read() == src_data
|
||||
|
||||
os.unlink(dst_name)
|
||||
|
||||
|
||||
def tst_chmod(mnt_dir):
|
||||
filename = pjoin(mnt_dir, name_generator())
|
||||
with open(filename, "wb") as fh:
|
||||
fh.write(b"chmod test\n")
|
||||
|
||||
os.chmod(filename, 0o644)
|
||||
fstat = os.stat(filename)
|
||||
assert stat.S_IMODE(fstat.st_mode) == 0o644
|
||||
|
||||
os.chmod(filename, 0o755)
|
||||
fstat = os.stat(filename)
|
||||
assert stat.S_IMODE(fstat.st_mode) == 0o755
|
||||
|
||||
os.unlink(filename)
|
||||
|
||||
|
||||
def tst_fsync(src_dir, mnt_dir):
|
||||
name = name_generator()
|
||||
mnt_name = pjoin(mnt_dir, name)
|
||||
src_name = pjoin(src_dir, name)
|
||||
data = b"fsync test data\n"
|
||||
|
||||
fd = os.open(mnt_name, os.O_CREAT | os.O_WRONLY)
|
||||
try:
|
||||
os.write(fd, data)
|
||||
os.fsync(fd)
|
||||
# Read from backing store while fd is still open, before
|
||||
# close/release has a chance to flush
|
||||
with open(src_name, "rb") as fh:
|
||||
assert fh.read() == data
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
os.unlink(mnt_name)
|
||||
|
||||
|
||||
def tst_symlink(mnt_dir):
|
||||
linkname = name_generator()
|
||||
fullname = mnt_dir + "/" + linkname
|
||||
@@ -174,6 +305,10 @@ def tst_symlink(mnt_dir):
|
||||
assert fstat.st_nlink == 1
|
||||
assert linkname in os.listdir(mnt_dir)
|
||||
|
||||
os.unlink(fullname)
|
||||
assert linkname not in os.listdir(mnt_dir)
|
||||
|
||||
|
||||
def tst_create(mnt_dir):
|
||||
name = name_generator()
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
@@ -191,6 +326,7 @@ def tst_create(mnt_dir):
|
||||
assert fstat.st_nlink == 1
|
||||
assert fstat.st_size == 0
|
||||
|
||||
|
||||
def tst_chown(mnt_dir):
|
||||
filename = pjoin(mnt_dir, name_generator())
|
||||
os.mkdir(filename)
|
||||
@@ -210,37 +346,38 @@ def tst_chown(mnt_dir):
|
||||
assert fstat.st_uid == uid_new
|
||||
assert fstat.st_gid == gid_new
|
||||
|
||||
|
||||
def tst_open_read(src_dir, mnt_dir):
|
||||
name = name_generator()
|
||||
with open(pjoin(src_dir, name), 'wb') as fh_out, \
|
||||
open(TEST_FILE, 'rb') as fh_in:
|
||||
with open(pjoin(src_dir, name), "wb") as fh_out, open(TEST_FILE, "rb") as fh_in:
|
||||
shutil.copyfileobj(fh_in, fh_out)
|
||||
|
||||
assert filecmp.cmp(pjoin(mnt_dir, name), TEST_FILE, False)
|
||||
|
||||
|
||||
def tst_open_write(src_dir, mnt_dir):
|
||||
name = name_generator()
|
||||
fd = os.open(pjoin(src_dir, name),
|
||||
os.O_CREAT | os.O_RDWR)
|
||||
fd = os.open(pjoin(src_dir, name), os.O_CREAT | os.O_RDWR)
|
||||
os.close(fd)
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
with open(fullname, 'wb') as fh_out, \
|
||||
open(TEST_FILE, 'rb') as fh_in:
|
||||
with open(fullname, "wb") as fh_out, open(TEST_FILE, "rb") as fh_in:
|
||||
shutil.copyfileobj(fh_in, fh_out)
|
||||
|
||||
assert filecmp.cmp(fullname, TEST_FILE, False)
|
||||
|
||||
|
||||
def tst_append(src_dir, mnt_dir):
|
||||
name = name_generator()
|
||||
os_create(pjoin(src_dir, name))
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
with os_open(fullname, os.O_WRONLY) as fd:
|
||||
os.write(fd, b'foo\n')
|
||||
with os_open(fullname, os.O_WRONLY|os.O_APPEND) as fd:
|
||||
os.write(fd, b'bar\n')
|
||||
os.write(fd, b"foo\n")
|
||||
with os_open(fullname, os.O_WRONLY | os.O_APPEND) as fd:
|
||||
os.write(fd, b"bar\n")
|
||||
|
||||
with open(fullname, "rb") as fh:
|
||||
assert fh.read() == b"foo\nbar\n"
|
||||
|
||||
with open(fullname, 'rb') as fh:
|
||||
assert fh.read() == b'foo\nbar\n'
|
||||
|
||||
def tst_seek(src_dir, mnt_dir):
|
||||
name = name_generator()
|
||||
@@ -248,32 +385,141 @@ def tst_seek(src_dir, mnt_dir):
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
with os_open(fullname, os.O_WRONLY) as fd:
|
||||
os.lseek(fd, 1, os.SEEK_SET)
|
||||
os.write(fd, b'foobar\n')
|
||||
os.write(fd, b"foobar\n")
|
||||
with os_open(fullname, os.O_WRONLY) as fd:
|
||||
os.lseek(fd, 4, os.SEEK_SET)
|
||||
os.write(fd, b'com')
|
||||
os.write(fd, b"com")
|
||||
|
||||
with open(fullname, "rb") as fh:
|
||||
assert fh.read() == b"\0foocom\n"
|
||||
|
||||
with open(fullname, 'rb') as fh:
|
||||
assert fh.read() == b'\0foocom\n'
|
||||
|
||||
def tst_open_unlink(mnt_dir):
|
||||
name = pjoin(mnt_dir, name_generator())
|
||||
data1 = b'foo'
|
||||
data2 = b'bar'
|
||||
data1 = b"foo"
|
||||
data2 = b"bar"
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
with open(fullname, 'wb+', buffering=0) as fh:
|
||||
with open(fullname, "wb+", buffering=0) as fh:
|
||||
fh.write(data1)
|
||||
os.unlink(fullname)
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
os.stat(fullname)
|
||||
assert exc_info.value.errno == errno.ENOENT
|
||||
assert exc_info.value.errno == errno.ENOENT
|
||||
assert name not in os.listdir(mnt_dir)
|
||||
fh.write(data2)
|
||||
fh.seek(0)
|
||||
assert fh.read() == data1+data2
|
||||
assert fh.read() == data1 + data2
|
||||
|
||||
|
||||
def tst_statvfs(src_dir, mnt_dir):
|
||||
vfs = os.statvfs(mnt_dir)
|
||||
ref = os.statvfs(src_dir)
|
||||
# When the server supports statvfs@openssh.com, values should
|
||||
# match the backing store. Otherwise sshfs returns synthetic
|
||||
# values that still pass the loose checks.
|
||||
if vfs.f_bsize == ref.f_bsize:
|
||||
assert vfs.f_frsize == ref.f_frsize
|
||||
assert vfs.f_blocks == ref.f_blocks
|
||||
assert vfs.f_namemax == ref.f_namemax
|
||||
else:
|
||||
assert vfs.f_bsize > 0
|
||||
assert vfs.f_blocks > 0
|
||||
assert vfs.f_namemax > 0
|
||||
|
||||
|
||||
def tst_open_writeonly_read(mnt_dir):
|
||||
name = pjoin(mnt_dir, name_generator())
|
||||
fd = os.open(name, os.O_CREAT | os.O_WRONLY)
|
||||
try:
|
||||
os.write(fd, b"hello")
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
os.read(fd, 10)
|
||||
assert exc_info.value.errno == errno.EBADF
|
||||
finally:
|
||||
os.close(fd)
|
||||
os.unlink(name)
|
||||
|
||||
|
||||
def tst_access(mnt_dir):
|
||||
filename = pjoin(mnt_dir, name_generator())
|
||||
with open(filename, "wb") as fh:
|
||||
fh.write(b"test")
|
||||
os.chmod(filename, 0o644)
|
||||
assert os.access(filename, os.R_OK)
|
||||
if os.getuid() != 0:
|
||||
assert not os.access(filename, os.X_OK)
|
||||
os.unlink(filename)
|
||||
|
||||
|
||||
def tst_mkdir_exist(mnt_dir):
|
||||
name = name_generator()
|
||||
fullname = pjoin(mnt_dir, name)
|
||||
os.mkdir(fullname)
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
os.mkdir(fullname)
|
||||
assert exc_info.value.errno == errno.EEXIST
|
||||
os.rmdir(fullname)
|
||||
|
||||
|
||||
def tst_readdir_repeated(mnt_dir):
|
||||
dirname = pjoin(mnt_dir, name_generator())
|
||||
os.mkdir(dirname)
|
||||
names = []
|
||||
for i in range(5):
|
||||
n = name_generator()
|
||||
names.append(n)
|
||||
with open(pjoin(dirname, n), "wb") as fh:
|
||||
fh.write(b"x")
|
||||
|
||||
# Verify repeated directory listings return consistent results
|
||||
listing1 = sorted(os.listdir(dirname))
|
||||
listing2 = sorted(os.listdir(dirname))
|
||||
assert listing1 == sorted(names)
|
||||
assert listing1 == listing2
|
||||
|
||||
for n in names:
|
||||
os.unlink(pjoin(dirname, n))
|
||||
os.rmdir(dirname)
|
||||
|
||||
|
||||
def tst_rename_sibling(mnt_dir):
|
||||
# Verify renaming one file doesn't break access to a sibling
|
||||
name_a = pjoin(mnt_dir, name_generator())
|
||||
name_b = pjoin(mnt_dir, name_generator())
|
||||
name_c = pjoin(mnt_dir, name_generator())
|
||||
|
||||
with open(name_a, "wb") as fh:
|
||||
fh.write(b"aaa")
|
||||
with open(name_b, "wb") as fh:
|
||||
fh.write(b"bbb")
|
||||
|
||||
os.rename(name_a, name_c)
|
||||
|
||||
assert not os.path.exists(name_a)
|
||||
assert os.path.exists(name_b)
|
||||
with open(name_b, "rb") as fh:
|
||||
assert fh.read() == b"bbb"
|
||||
|
||||
os.unlink(name_b)
|
||||
os.unlink(name_c)
|
||||
|
||||
|
||||
def tst_rename_open_release(mnt_dir):
|
||||
src = pjoin(mnt_dir, name_generator())
|
||||
dst = pjoin(mnt_dir, name_generator())
|
||||
|
||||
fd = os.open(src, os.O_CREAT | os.O_RDWR)
|
||||
try:
|
||||
os.write(fd, b"data")
|
||||
os.rename(src, dst)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
assert not os.path.exists(src)
|
||||
with open(dst, "rb") as fh:
|
||||
assert fh.read() == b"data"
|
||||
os.unlink(dst)
|
||||
|
||||
def tst_statvfs(mnt_dir):
|
||||
os.statvfs(mnt_dir)
|
||||
|
||||
def tst_link(mnt_dir, cache_timeout):
|
||||
name1 = pjoin(mnt_dir, name_generator())
|
||||
@@ -293,11 +539,19 @@ def tst_link(mnt_dir, cache_timeout):
|
||||
# we need to wait until the cached value has expired.
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout)
|
||||
|
||||
|
||||
fstat1 = os.lstat(name1)
|
||||
fstat2 = os.lstat(name2)
|
||||
for attr in ('st_mode', 'st_dev', 'st_uid', 'st_gid',
|
||||
'st_size', 'st_atime', 'st_mtime', 'st_ctime'):
|
||||
for attr in (
|
||||
"st_mode",
|
||||
"st_dev",
|
||||
"st_uid",
|
||||
"st_gid",
|
||||
"st_size",
|
||||
"st_atime",
|
||||
"st_mtime",
|
||||
"st_ctime",
|
||||
):
|
||||
assert getattr(fstat1, attr) == getattr(fstat2, attr)
|
||||
assert os.path.basename(name2) in os.listdir(mnt_dir)
|
||||
assert filecmp.cmp(name1, name2, False)
|
||||
@@ -307,9 +561,14 @@ def tst_link(mnt_dir, cache_timeout):
|
||||
assert os.path.basename(name2) not in os.listdir(mnt_dir)
|
||||
with pytest.raises(FileNotFoundError):
|
||||
os.lstat(name2)
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout + 1)
|
||||
fstat1 = os.lstat(name1)
|
||||
assert fstat1.st_nlink == 1
|
||||
|
||||
os.unlink(name1)
|
||||
|
||||
|
||||
def tst_readdir(src_dir, mnt_dir):
|
||||
newdir = name_generator()
|
||||
src_newdir = pjoin(src_dir, newdir)
|
||||
@@ -325,7 +584,7 @@ def tst_readdir(src_dir, mnt_dir):
|
||||
|
||||
listdir_is = os.listdir(mnt_newdir)
|
||||
listdir_is.sort()
|
||||
listdir_should = [ os.path.basename(file_), os.path.basename(subdir) ]
|
||||
listdir_should = [os.path.basename(file_), os.path.basename(subdir)]
|
||||
listdir_should.sort()
|
||||
assert listdir_is == listdir_should
|
||||
|
||||
@@ -334,11 +593,12 @@ def tst_readdir(src_dir, mnt_dir):
|
||||
os.rmdir(subdir)
|
||||
os.rmdir(src_newdir)
|
||||
|
||||
|
||||
def tst_truncate_path(mnt_dir):
|
||||
assert len(TEST_DATA) > 1024
|
||||
|
||||
filename = pjoin(mnt_dir, name_generator())
|
||||
with open(filename, 'wb') as fh:
|
||||
with open(filename, "wb") as fh:
|
||||
fh.write(TEST_DATA)
|
||||
|
||||
fstat = os.stat(filename)
|
||||
@@ -348,21 +608,26 @@ def tst_truncate_path(mnt_dir):
|
||||
# Add zeros at the end
|
||||
os.truncate(filename, size + 1024)
|
||||
assert os.stat(filename).st_size == size + 1024
|
||||
with open(filename, 'rb') as fh:
|
||||
with open(filename, "rb") as fh:
|
||||
assert fh.read(size) == TEST_DATA
|
||||
assert fh.read(1025) == b'\0' * 1024
|
||||
assert fh.read(1025) == b"\0" * 1024
|
||||
|
||||
# Truncate data
|
||||
os.truncate(filename, size - 1024)
|
||||
assert os.stat(filename).st_size == size - 1024
|
||||
with open(filename, 'rb') as fh:
|
||||
assert fh.read(size) == TEST_DATA[:size-1024]
|
||||
with open(filename, "rb") as fh:
|
||||
assert fh.read(size) == TEST_DATA[: size - 1024]
|
||||
|
||||
# Truncate to zero
|
||||
os.truncate(filename, 0)
|
||||
assert os.stat(filename).st_size == 0
|
||||
|
||||
os.unlink(filename)
|
||||
|
||||
|
||||
def tst_truncate_fd(mnt_dir):
|
||||
assert len(TEST_DATA) > 1024
|
||||
with NamedTemporaryFile('w+b', 0, dir=mnt_dir) as fh:
|
||||
with NamedTemporaryFile("w+b", 0, dir=mnt_dir) as fh:
|
||||
fd = fh.fileno()
|
||||
fh.write(TEST_DATA)
|
||||
fstat = os.fstat(fd)
|
||||
@@ -374,13 +639,18 @@ def tst_truncate_fd(mnt_dir):
|
||||
assert os.fstat(fd).st_size == size + 1024
|
||||
fh.seek(0)
|
||||
assert fh.read(size) == TEST_DATA
|
||||
assert fh.read(1025) == b'\0' * 1024
|
||||
assert fh.read(1025) == b"\0" * 1024
|
||||
|
||||
# Truncate data
|
||||
os.ftruncate(fd, size - 1024)
|
||||
assert os.fstat(fd).st_size == size - 1024
|
||||
fh.seek(0)
|
||||
assert fh.read(size) == TEST_DATA[:size-1024]
|
||||
assert fh.read(size) == TEST_DATA[: size - 1024]
|
||||
|
||||
# Truncate to zero via fd
|
||||
os.ftruncate(fd, 0)
|
||||
assert os.fstat(fd).st_size == 0
|
||||
|
||||
|
||||
def tst_utimens(mnt_dir, tol=0):
|
||||
filename = pjoin(mnt_dir, name_generator())
|
||||
@@ -389,20 +659,21 @@ def tst_utimens(mnt_dir, tol=0):
|
||||
|
||||
atime = fstat.st_atime + 42.28
|
||||
mtime = fstat.st_mtime - 42.23
|
||||
if sys.version_info < (3,3):
|
||||
if sys.version_info < (3, 3):
|
||||
os.utime(filename, (atime, mtime))
|
||||
else:
|
||||
atime_ns = fstat.st_atime_ns + int(42.28*1e9)
|
||||
mtime_ns = fstat.st_mtime_ns - int(42.23*1e9)
|
||||
atime_ns = fstat.st_atime_ns + int(42.28 * 1e9)
|
||||
mtime_ns = fstat.st_mtime_ns - int(42.23 * 1e9)
|
||||
os.utime(filename, None, ns=(atime_ns, mtime_ns))
|
||||
|
||||
fstat = os.lstat(filename)
|
||||
|
||||
assert abs(fstat.st_atime - atime) < tol
|
||||
assert abs(fstat.st_mtime - mtime) < tol
|
||||
if sys.version_info >= (3,3):
|
||||
assert abs(fstat.st_atime_ns - atime_ns) < tol*1e9
|
||||
assert abs(fstat.st_mtime_ns - mtime_ns) < tol*1e9
|
||||
if sys.version_info >= (3, 3):
|
||||
assert abs(fstat.st_atime_ns - atime_ns) < tol * 1e9
|
||||
assert abs(fstat.st_mtime_ns - mtime_ns) < tol * 1e9
|
||||
|
||||
|
||||
def tst_utimens_now(mnt_dir):
|
||||
fullname = pjoin(mnt_dir, name_generator())
|
||||
@@ -416,29 +687,226 @@ def tst_utimens_now(mnt_dir):
|
||||
assert fstat.st_atime != 0
|
||||
assert fstat.st_mtime != 0
|
||||
|
||||
|
||||
def tst_passthrough(src_dir, mnt_dir, cache_timeout):
|
||||
name = name_generator()
|
||||
src_name = pjoin(src_dir, name)
|
||||
mnt_name = pjoin(src_dir, name)
|
||||
mnt_name = pjoin(mnt_dir, name)
|
||||
assert name not in os.listdir(src_dir)
|
||||
assert name not in os.listdir(mnt_dir)
|
||||
with open(src_name, 'w') as fh:
|
||||
fh.write('Hello, world')
|
||||
with open(src_name, "w") as fh:
|
||||
fh.write("Hello, world")
|
||||
assert name in os.listdir(src_dir)
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout+1)
|
||||
safe_sleep(cache_timeout + 1)
|
||||
assert name in os.listdir(mnt_dir)
|
||||
assert os.stat(src_name) == os.stat(mnt_name)
|
||||
src_st = os.stat(src_name)
|
||||
mnt_st = os.stat(mnt_name)
|
||||
assert src_st.st_size == mnt_st.st_size
|
||||
assert src_st.st_uid == mnt_st.st_uid
|
||||
assert src_st.st_gid == mnt_st.st_gid
|
||||
assert abs(src_st.st_mtime - mnt_st.st_mtime) <= 1
|
||||
|
||||
name = name_generator()
|
||||
src_name = pjoin(src_dir, name)
|
||||
mnt_name = pjoin(src_dir, name)
|
||||
mnt_name = pjoin(mnt_dir, name)
|
||||
assert name not in os.listdir(src_dir)
|
||||
assert name not in os.listdir(mnt_dir)
|
||||
with open(mnt_name, 'w') as fh:
|
||||
fh.write('Hello, world')
|
||||
with open(mnt_name, "w") as fh:
|
||||
fh.write("Hello, world")
|
||||
assert name in os.listdir(src_dir)
|
||||
if cache_timeout:
|
||||
safe_sleep(cache_timeout+1)
|
||||
safe_sleep(cache_timeout + 1)
|
||||
assert name in os.listdir(mnt_dir)
|
||||
assert os.stat(src_name) == os.stat(mnt_name)
|
||||
src_st = os.stat(src_name)
|
||||
mnt_st = os.stat(mnt_name)
|
||||
assert src_st.st_size == mnt_st.st_size
|
||||
assert src_st.st_uid == mnt_st.st_uid
|
||||
assert src_st.st_gid == mnt_st.st_gid
|
||||
assert abs(src_st.st_mtime - mnt_st.st_mtime) <= 1
|
||||
|
||||
|
||||
def _check_ssh_localhost():
|
||||
try:
|
||||
res = subprocess.call(
|
||||
["ssh", "-o", "StrictHostKeyChecking=no",
|
||||
"-o", "KbdInteractiveAuthentication=no",
|
||||
"-o", "ChallengeResponseAuthentication=no",
|
||||
"-o", "PasswordAuthentication=no",
|
||||
"localhost", "--", "true"],
|
||||
stdin=subprocess.DEVNULL, timeout=10,
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
res = 1
|
||||
if res != 0:
|
||||
pytest.fail("Unable to ssh into localhost without password prompt.")
|
||||
|
||||
|
||||
_mount_ctr = [0]
|
||||
|
||||
|
||||
def _mount_sshfs(tmpdir, extra_opts=None):
|
||||
"""Helper to mount sshfs with custom options. Returns (mount_process, mnt_dir, src_dir)."""
|
||||
_check_ssh_localhost()
|
||||
_mount_ctr[0] += 1
|
||||
mnt_dir = str(tmpdir.mkdir(f"mnt{_mount_ctr[0]}"))
|
||||
src_dir = str(tmpdir.mkdir(f"src{_mount_ctr[0]}"))
|
||||
|
||||
cmdline = base_cmdline + [
|
||||
pjoin(basename, "sshfs"),
|
||||
"-f",
|
||||
f"localhost:{src_dir}",
|
||||
mnt_dir,
|
||||
"-o", "entry_timeout=0",
|
||||
"-o", "attr_timeout=0",
|
||||
]
|
||||
if extra_opts:
|
||||
for opt in extra_opts:
|
||||
cmdline += ["-o", opt]
|
||||
|
||||
new_env = dict(os.environ)
|
||||
new_env["G_DEBUG"] = "fatal-warnings"
|
||||
|
||||
mount_process = subprocess.Popen(cmdline, env=new_env)
|
||||
try:
|
||||
wait_for_mount(mount_process, mnt_dir)
|
||||
except:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
return mount_process, mnt_dir, src_dir
|
||||
|
||||
|
||||
def test_disable_hardlink(tmpdir, capfd):
|
||||
capfd.register_output(r"^Warning: Permanently added 'localhost' .+", count=0)
|
||||
|
||||
# Control: verify hardlinks work without disable_hardlink.
|
||||
# If the server lacks the extension, skip this test entirely.
|
||||
mount_process, mnt_dir, src_dir = _mount_sshfs(tmpdir, [])
|
||||
try:
|
||||
name1 = pjoin(mnt_dir, name_generator())
|
||||
name2 = pjoin(mnt_dir, name_generator())
|
||||
with open(name1, "wb") as fh:
|
||||
fh.write(b"test")
|
||||
try:
|
||||
os.link(name1, name2)
|
||||
except OSError:
|
||||
os.unlink(name1)
|
||||
pytest.skip("server does not support hardlink extension")
|
||||
os.unlink(name2)
|
||||
os.unlink(name1)
|
||||
except Exception:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
else:
|
||||
umount(mount_process, mnt_dir)
|
||||
|
||||
# Now test with disable_hardlink — links should fail
|
||||
mount_process, mnt_dir, src_dir = _mount_sshfs(tmpdir, ["disable_hardlink"])
|
||||
try:
|
||||
name1 = pjoin(mnt_dir, name_generator())
|
||||
name2 = pjoin(mnt_dir, name_generator())
|
||||
with open(name1, "wb") as fh:
|
||||
fh.write(b"test")
|
||||
with pytest.raises(OSError) as exc_info:
|
||||
os.link(name1, name2)
|
||||
assert exc_info.value.errno in (errno.ENOSYS, errno.EPERM)
|
||||
os.unlink(name1)
|
||||
except Exception:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
else:
|
||||
umount(mount_process, mnt_dir)
|
||||
|
||||
|
||||
def test_follow_symlinks(tmpdir, capfd):
|
||||
capfd.register_output(r"^Warning: Permanently added 'localhost' .+", count=0)
|
||||
mount_process, mnt_dir, src_dir = _mount_sshfs(tmpdir, ["follow_symlinks"])
|
||||
try:
|
||||
target_name = name_generator()
|
||||
target = pjoin(src_dir, target_name)
|
||||
with open(target, "wb") as fh:
|
||||
fh.write(b"symlink target data")
|
||||
|
||||
link = pjoin(src_dir, name_generator())
|
||||
os.symlink(target_name, link)
|
||||
|
||||
mnt_link = pjoin(mnt_dir, os.path.basename(link))
|
||||
# With follow_symlinks, stat should return the target's attributes
|
||||
# and the entry should appear as a regular file, not a symlink
|
||||
fstat = os.lstat(mnt_link)
|
||||
assert stat.S_ISREG(fstat.st_mode)
|
||||
with open(mnt_link, "rb") as fh:
|
||||
assert fh.read() == b"symlink target data"
|
||||
|
||||
os.unlink(link)
|
||||
os.unlink(target)
|
||||
except Exception:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
else:
|
||||
umount(mount_process, mnt_dir)
|
||||
|
||||
|
||||
def test_direct_io(tmpdir, capfd):
|
||||
capfd.register_output(r"^Warning: Permanently added 'localhost' .+", count=0)
|
||||
mount_process, mnt_dir, src_dir = _mount_sshfs(tmpdir, ["direct_io"])
|
||||
try:
|
||||
name = name_generator()
|
||||
mnt_name = pjoin(mnt_dir, name)
|
||||
src_name = pjoin(src_dir, name)
|
||||
data = b"direct io test data\n" * 100
|
||||
|
||||
with open(mnt_name, "wb") as fh:
|
||||
fh.write(data)
|
||||
with open(mnt_name, "rb") as fh:
|
||||
assert fh.read() == data
|
||||
with open(src_name, "rb") as fh:
|
||||
assert fh.read() == data
|
||||
|
||||
os.unlink(mnt_name)
|
||||
except Exception:
|
||||
cleanup(mount_process, mnt_dir)
|
||||
raise
|
||||
else:
|
||||
umount(mount_process, mnt_dir)
|
||||
|
||||
|
||||
def test_bad_sftp_reply_len(tmpdir):
|
||||
"""sshfs must reject a zero-length SFTP reply instead of underflowing."""
|
||||
helper = tmpdir.join("bad_sftp.py")
|
||||
helper.write(
|
||||
'#!/usr/bin/env python3\n'
|
||||
'import os, struct, sys\n'
|
||||
'def read_pkt():\n'
|
||||
' hdr = os.read(0, 4)\n'
|
||||
' if len(hdr) < 4: sys.exit(0)\n'
|
||||
' n = struct.unpack(">I", hdr)[0]\n'
|
||||
' while n:\n'
|
||||
' c = os.read(0, n)\n'
|
||||
' if not c: sys.exit(0)\n'
|
||||
' n -= len(c)\n'
|
||||
'read_pkt()\n'
|
||||
'os.write(1, struct.pack(">IBI", 5, 2, 3))\n' # SSH_FXP_VERSION v3
|
||||
'read_pkt()\n'
|
||||
'os.write(1, struct.pack(">IB", 0, 0))\n' # len=0 reply (5 bytes on wire)
|
||||
)
|
||||
helper.chmod(0o755)
|
||||
|
||||
mnt_dir = str(tmpdir.mkdir("mnt"))
|
||||
cmdline = base_cmdline + [
|
||||
pjoin(basename, "sshfs"),
|
||||
"-f",
|
||||
"dummy:/",
|
||||
mnt_dir,
|
||||
"-o", f"ssh_command={helper}",
|
||||
]
|
||||
res = subprocess.run(
|
||||
cmdline,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
timeout=10,
|
||||
text=True,
|
||||
)
|
||||
assert res.returncode != 0
|
||||
assert "bad reply len: 0" in res.stderr
|
||||
|
||||
+12
-8
@@ -6,36 +6,40 @@ set -e
|
||||
# that we still need to fix
|
||||
export ASAN_OPTIONS="detect_leaks=0"
|
||||
|
||||
export LSAN_OPTIONS="suppressions=$(pwd)/test/lsan_suppress.txt"
|
||||
export LSAN_OPTIONS="suppressions=${PWD}/test/lsan_suppress.txt"
|
||||
export CC
|
||||
|
||||
TEST_CMD="python3 -m pytest --maxfail=99 test/"
|
||||
|
||||
# Standard build with Valgrind
|
||||
for CC in gcc gcc-6 clang; do
|
||||
mkdir build-${CC}; cd build-${CC}
|
||||
if [ ${CC} == 'gcc-6' ]; then
|
||||
for CC in gcc clang; do
|
||||
(
|
||||
mkdir "build-${CC}"; cd "build-${CC}"
|
||||
if [ "${CC}" == 'gcc-6' ]; then
|
||||
build_opts='-D b_lundef=false'
|
||||
else
|
||||
build_opts=''
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
meson -D werror=true ${build_opts} ../
|
||||
ninja
|
||||
|
||||
TEST_WITH_VALGRIND=true ${TEST_CMD}
|
||||
cd ..
|
||||
)
|
||||
done
|
||||
(cd build-$CC; sudo ninja install)
|
||||
(cd "build-${CC}"; sudo ninja install)
|
||||
|
||||
# Sanitized build
|
||||
CC=clang
|
||||
for san in undefined address; do
|
||||
mkdir build-${san}; cd build-${san}
|
||||
(
|
||||
mkdir "build-${san}"
|
||||
cd "build-${san}"
|
||||
# b_lundef=false is required to work around clang
|
||||
# bug, cf. https://groups.google.com/forum/#!topic/mesonbuild/tgEdAXIIdC4
|
||||
meson -D b_sanitize=${san} -D b_lundef=false -D werror=true ..
|
||||
ninja
|
||||
${TEST_CMD}
|
||||
sudo ninja install
|
||||
cd ..
|
||||
)
|
||||
done
|
||||
|
||||
@@ -2,25 +2,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Meson 0.45 requires Python 3.5 or newer
|
||||
sudo python3 -m pip install pytest meson==0.44
|
||||
valgrind --version
|
||||
ninja --version
|
||||
meson --version
|
||||
|
||||
# Install fuse
|
||||
wget https://github.com/libfuse/libfuse/archive/master.zip
|
||||
unzip master.zip
|
||||
cd libfuse-master
|
||||
mkdir build
|
||||
cd build
|
||||
export CC=gcc-6
|
||||
meson ..
|
||||
ninja
|
||||
sudo ninja install
|
||||
test -e /usr/local/lib/pkgconfig || sudo mkdir /usr/local/lib/pkgconfig
|
||||
sudo mv /usr/local/lib/*/pkgconfig/* /usr/local/lib/pkgconfig/
|
||||
ls -d1 /usr/local/lib/*-linux-gnu | sudo tee /etc/ld.so.conf.d/usrlocal.conf
|
||||
printf '%s\n' /usr/local/lib/*-linux-gnu | sudo tee /etc/ld.so.conf.d/usrlocal.conf
|
||||
sudo ldconfig
|
||||
|
||||
# Setup ssh
|
||||
|
||||
+50
-25
@@ -5,34 +5,51 @@ import os
|
||||
import stat
|
||||
import time
|
||||
from os.path import join as pjoin
|
||||
from contextlib import contextmanager
|
||||
|
||||
basename = pjoin(os.path.dirname(__file__), '..')
|
||||
basename = pjoin(os.path.dirname(__file__), "..")
|
||||
|
||||
def wait_for_mount(mount_process, mnt_dir,
|
||||
test_fn=os.path.ismount):
|
||||
|
||||
def os_create(name):
|
||||
os.close(os.open(name, os.O_CREAT | os.O_RDWR))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def os_open(name, flags):
|
||||
fd = os.open(name, flags)
|
||||
try:
|
||||
yield fd
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def wait_for_mount(mount_process, mnt_dir, test_fn=os.path.ismount):
|
||||
elapsed = 0
|
||||
while elapsed < 30:
|
||||
if test_fn(mnt_dir):
|
||||
return True
|
||||
if mount_process.poll() is not None:
|
||||
pytest.fail('file system process terminated prematurely')
|
||||
pytest.fail("file system process terminated prematurely")
|
||||
time.sleep(0.1)
|
||||
elapsed += 0.1
|
||||
pytest.fail("mountpoint failed to come up")
|
||||
|
||||
|
||||
def cleanup(mount_process, mnt_dir):
|
||||
subprocess.call(['fusermount', '-z', '-u', mnt_dir],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.STDOUT)
|
||||
subprocess.call(
|
||||
["fusermount", "-z", "-u", mnt_dir],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
mount_process.terminate()
|
||||
try:
|
||||
mount_process.wait(1)
|
||||
except subprocess.TimeoutExpired:
|
||||
mount_process.kill()
|
||||
|
||||
|
||||
|
||||
def umount(mount_process, mnt_dir):
|
||||
subprocess.check_call(['fusermount3', '-z', '-u', mnt_dir ])
|
||||
subprocess.check_call(["fusermount3", "-z", "-u", mnt_dir])
|
||||
assert not os.path.ismount(mnt_dir)
|
||||
|
||||
# Give mount process a little while to terminate. Popen.wait(timeout)
|
||||
@@ -43,18 +60,19 @@ def umount(mount_process, mnt_dir):
|
||||
if code is not None:
|
||||
if code == 0:
|
||||
return
|
||||
pytest.fail('file system process terminated with code %s' % (code,))
|
||||
pytest.fail(f"file system process terminated with code {code}")
|
||||
time.sleep(0.1)
|
||||
elapsed += 0.1
|
||||
pytest.fail('mount process did not terminate')
|
||||
pytest.fail("mount process did not terminate")
|
||||
|
||||
|
||||
def safe_sleep(secs):
|
||||
'''Like time.sleep(), but sleep for at least *secs*
|
||||
"""Like time.sleep(), but sleep for at least *secs*
|
||||
|
||||
`time.sleep` may sleep less than the given period if a signal is
|
||||
received. This function ensures that we sleep for at least the
|
||||
desired time.
|
||||
'''
|
||||
"""
|
||||
|
||||
now = time.time()
|
||||
end = now + secs
|
||||
@@ -62,24 +80,27 @@ def safe_sleep(secs):
|
||||
time.sleep(end - now)
|
||||
now = time.time()
|
||||
|
||||
|
||||
def fuse_test_marker():
|
||||
'''Return a pytest.marker that indicates FUSE availability
|
||||
"""Return a pytest.marker that indicates FUSE availability
|
||||
|
||||
If system/user/environment does not support FUSE, return
|
||||
a `pytest.mark.skip` object with more details. If FUSE is
|
||||
supported, return `pytest.mark.uses_fuse()`.
|
||||
'''
|
||||
"""
|
||||
|
||||
skip = lambda x: pytest.mark.skip(reason=x)
|
||||
def skip(reason: str):
|
||||
return pytest.mark.skip(reason=reason)
|
||||
|
||||
with subprocess.Popen(['which', 'fusermount'], stdout=subprocess.PIPE,
|
||||
universal_newlines=True) as which:
|
||||
with subprocess.Popen(
|
||||
["which", "fusermount"], stdout=subprocess.PIPE, universal_newlines=True
|
||||
) as which:
|
||||
fusermount_path = which.communicate()[0].strip()
|
||||
|
||||
if not fusermount_path or which.returncode != 0:
|
||||
return skip("Can't find fusermount executable")
|
||||
|
||||
if not os.path.exists('/dev/fuse'):
|
||||
if not os.path.exists("/dev/fuse"):
|
||||
return skip("FUSE kernel module does not seem to be loaded")
|
||||
|
||||
if os.getuid() == 0:
|
||||
@@ -87,20 +108,24 @@ def fuse_test_marker():
|
||||
|
||||
mode = os.stat(fusermount_path).st_mode
|
||||
if mode & stat.S_ISUID == 0:
|
||||
return skip('fusermount executable not setuid, and we are not root.')
|
||||
return skip("fusermount executable not setuid, and we are not root.")
|
||||
|
||||
try:
|
||||
fd = os.open('/dev/fuse', os.O_RDWR)
|
||||
fd = os.open("/dev/fuse", os.O_RDWR)
|
||||
except OSError as exc:
|
||||
return skip('Unable to open /dev/fuse: %s' % exc.strerror)
|
||||
return skip(f"Unable to open /dev/fuse: {exc.strerror}")
|
||||
else:
|
||||
os.close(fd)
|
||||
|
||||
return pytest.mark.uses_fuse()
|
||||
|
||||
|
||||
# Use valgrind if requested
|
||||
if os.environ.get('TEST_WITH_VALGRIND', 'no').lower().strip() \
|
||||
not in ('no', 'false', '0'):
|
||||
base_cmdline = [ 'valgrind', '-q', '--' ]
|
||||
if os.environ.get("TEST_WITH_VALGRIND", "no").lower().strip() not in (
|
||||
"no",
|
||||
"false",
|
||||
"0",
|
||||
):
|
||||
base_cmdline = ["valgrind", "-q", "--"]
|
||||
else:
|
||||
base_cmdline = []
|
||||
|
||||
Reference in New Issue
Block a user