Skip to content

Commit

Permalink
Fixup whitespace and configure CI to keep it that way
Browse files Browse the repository at this point in the history
  • Loading branch information
ccope authored Aug 30, 2021
1 parent 803e0e6 commit d54c7ec
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 61 deletions.
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
dist: focal
sudo: enabled

language:
- c
language: c

cache:
- pip

addons:
apt:
packages:
- shellcheck
- valgrind
- gcc
- clang
Expand All @@ -16,6 +19,13 @@ addons:
- meson
- python3-pytest
- libglib2.0-dev

install: test/travis-install.sh
script: test/travis-build.sh

jobs:
include:
- name: Lint
script: ./test/lint.sh
install: skip
- name: Build + Test
script: test/travis-build.sh
14 changes: 7 additions & 7 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Release 3.7.0 (2020-01-03)
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)
--------------------------

Expand Down Expand Up @@ -108,13 +108,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.
Expand All @@ -129,7 +129,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)
------------------------

Expand Down Expand Up @@ -168,14 +168,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

Expand All @@ -188,7 +188,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)
------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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 # list options
$ mesonconf -D strip=true # set an option

To build, test and install SSHFS, you then use Ninja (running the
Expand Down
12 changes: 6 additions & 6 deletions cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ 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;

Expand Down Expand Up @@ -318,9 +318,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);
Expand Down Expand Up @@ -365,7 +365,7 @@ static int cache_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
struct node *node;

assert(offset == 0);

pthread_mutex_lock(&cache.lock);
node = cache_lookup(path);
if (node != NULL && node->dir != NULL) {
Expand All @@ -391,8 +391,8 @@ 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;
Expand Down
1 change: 0 additions & 1 deletion make_release_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ endif


rst2man = find_program('rst2man', 'rst2man.py', required: false)

cfg = configuration_data()

cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
Expand Down Expand Up @@ -69,4 +69,3 @@ meson.add_install_script('utils/install_helper.sh',


subdir('test')

40 changes: 20 additions & 20 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
/*
Handling of multiple SFTP connections
--------------------------------------
An SFTP server is free to return responses to outstanding requests in arbitrary
order. However, execution of requests may only be re-ordered and parallelized as long
as "the results in the responses will be the same as if [the client] had sent the
Expand All @@ -158,11 +158,11 @@
involved) wait for the other requests to complete. This means that e.g. a readdir
request would have to block on most other activity in the same directory, eliminating a
major advantage of using multiple connections.
In practice, we can luckily take advantage of the knowledge that most FUSE requests are
the result of (synchronous) syscalls from userspace that will block until the
corresponding FUSE response has been sent.
If -o sshfs_sync is used, SSHFS always waits for the SFTP server response before
returning a FUSE response to userspace. If userspace makes concurrent system calls,
there is no ordering guarantee in the first place, so we do not have to worry about
Expand Down Expand Up @@ -523,7 +523,7 @@ static struct fuse_opt sshfs_opts[] = {
/* For backwards compatibility */
SSHFS_OPT("cache=yes", dir_cache, 1),
SSHFS_OPT("cache=no", dir_cache, 0),

FUSE_OPT_KEY("writeback_cache=no", FUSE_OPT_KEY_DISCARD),
FUSE_OPT_KEY("unreliable_append", FUSE_OPT_KEY_DISCARD),

Expand Down Expand Up @@ -1073,7 +1073,7 @@ static struct conn* get_conn(const struct sshfs_file *sf,

if (sshfs.max_conns == 1)
return &sshfs.conns[0];

if (sf != NULL)
return sf->conn;

Expand Down Expand Up @@ -1906,7 +1906,7 @@ static void *sshfs_init(struct fuse_conn_info *conn,

// SFTP only supports 1-second time resolution
conn->time_gran = 1000000000;

return NULL;
}

Expand Down Expand Up @@ -2371,13 +2371,13 @@ static int sshfs_mkdir(const char *path, mode_t mode)
// Commutes with pending write(), so we can use any connection
err = sftp_request(get_conn(NULL, NULL), SSH_FXP_MKDIR, &buf, SSH_FXP_STATUS, NULL);
buf_free(&buf);

if (err == -EPERM) {
if (sshfs.op->access(path, R_OK) == 0) {
return -EEXIST;
}
}

return err;
}

Expand All @@ -2394,7 +2394,7 @@ static int sshfs_mknod(const char *path, mode_t mode, dev_t rdev)

// Commutes with pending write(), so we can use any connection
conn = get_conn(NULL, NULL);

buf_init(&buf, 0);
buf_add_path(&buf, path);
buf_add_uint32(&buf, SSH_FXF_WRITE | SSH_FXF_CREAT | SSH_FXF_EXCL);
Expand Down Expand Up @@ -2532,7 +2532,7 @@ static int sshfs_rename(const char *from, const char *to, unsigned int flags)
}
pthread_mutex_unlock(&sshfs.lock);
}

return err;
}

Expand Down Expand Up @@ -2589,12 +2589,12 @@ static int sshfs_chmod(const char *path, mode_t mode,
buf_init(&buf, 0);
if (sf == NULL)
buf_add_path(&buf, path);
else
else
buf_add_buf(&buf, &sf->handle);

buf_add_uint32(&buf, SSH_FILEXFER_ATTR_PERMISSIONS);
buf_add_uint32(&buf, mode);

/* FIXME: really needs LSETSTAT extension (debian Bug#640038) */
// Commutes with pending write(), so we can use any connection
// if the file is not open.
Expand All @@ -2618,7 +2618,7 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid,
if (!sshfs_file_is_conn(sf))
return -EIO;
}

if (sshfs.remote_uid_detected) {
if (uid == sshfs.local_uid)
uid = sshfs.remote_uid;
Expand All @@ -2635,7 +2635,7 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid,
buf_init(&buf, 0);
if (sf == NULL)
buf_add_path(&buf, path);
else
else
buf_add_buf(&buf, &sf->handle);
buf_add_uint32(&buf, SSH_FILEXFER_ATTR_UIDGID);
buf_add_uint32(&buf, uid);
Expand Down Expand Up @@ -2685,7 +2685,7 @@ static int sshfs_utimens(const char *path, const struct timespec tv[2],
buf_init(&buf, 0);
if (sf == NULL)
buf_add_path(&buf, path);
else
else
buf_add_buf(&buf, &sf->handle);
buf_add_uint32(&buf, SSH_FILEXFER_ATTR_ACMODTIME);
buf_add_uint32(&buf, asec);
Expand Down Expand Up @@ -2740,7 +2740,7 @@ static int sshfs_open_common(const char *path, mode_t mode,

if (fi->flags & O_APPEND)
pflags |= SSH_FXF_APPEND;

sf = g_new0(struct sshfs_file, 1);
list_init(&sf->write_reqs);
pthread_cond_init(&sf->write_finished, NULL);
Expand All @@ -2750,7 +2750,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
pthread_mutex_lock(&sshfs.lock);
sf->modifver= sshfs.modifver;
if (sshfs.max_conns > 1) {
ce = g_hash_table_lookup(sshfs.conntab, path);
ce = g_hash_table_lookup(sshfs.conntab, path);
if (!ce) {
ce = g_malloc(sizeof(struct conntab_entry));
ce->refcount = 0;
Expand Down Expand Up @@ -3354,7 +3354,7 @@ static int sshfs_truncate(const char *path, off_t size,
sshfs_inc_modifver();
if (sshfs.truncate_workaround)
return sshfs_truncate_workaround(path, size, fi);

buf_init(&buf, 0);

if (sf != NULL)
Expand Down Expand Up @@ -3397,7 +3397,7 @@ static int sshfs_getattr(const char *path, struct stat *stbuf,
buf_add_buf(&buf, &sf->handle);
err = sftp_request(sf->conn, SSH_FXP_FSTAT, &buf,
SSH_FXP_ATTRS, &outbuf);
}
}
if (!err) {
err = buf_get_attrs(&outbuf, stbuf, NULL);
#ifdef __APPLE__
Expand Down
16 changes: 8 additions & 8 deletions sshfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,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.

Expand All @@ -209,17 +209,17 @@ 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
Expand Down
1 change: 1 addition & 0 deletions test/appveyor-build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

machine=$(uname -m)
mkdir "build-$machine"
Expand Down
4 changes: 4 additions & 0 deletions test/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
pip3 install --user pre-commit
pre-commit run --all-files --show-diff-on-failure
Loading

0 comments on commit d54c7ec

Please sign in to comment.