Compare commits

...

19 Commits

Author SHA1 Message Date
Miklos Szeredi 49203ee923 Released 2.3 2011-07-01 14:24:49 +02:00
Miklos Szeredi 6c1968e9e5 Update COPYING 2011-07-01 14:15:39 +02:00
Miklos Szeredi a575d48234 Add hard link operation
Works if the server supports the "hardlink@openssh.com" protocol
extension.
2011-07-01 14:01:29 +02:00
Miklos Szeredi eac5268e87 Fix possible deadlock on reconnection
Reported by Florian Zumbiehl
2011-03-25 13:38:39 +01:00
Miklos Szeredi 6d5e12e1b6 Fix cleanup when ssh connection is terminated.
This prevents sshfs hanging when the server is rebooted, for example.
2011-01-25 11:46:15 +01:00
Miklos Szeredi b1b0c4b6f5 * Set FD_CLOEXEC on fuse device. This prevents deadlocks that
happen in some circumstances (bugzilla.kernel.org #12864).
2010-04-28 08:59:12 +00:00
Miklos Szeredi f018ac3b1c * Check that the remote path specified refers to the same type of
file as the mountpoint, i.e. both are directories or both are
non-directories (debian bug #535343).  Reported by Greg Kochanski

* Allow mounting a single non-directory from the server
2009-07-15 15:57:04 +00:00
Miklos Szeredi 2431a280eb tear down mount on connect failure 2009-07-15 15:08:55 +00:00
Miklos Szeredi 0eabd86300 Check mountpoint and fuse options before starting an ssh
session (debian bug #535333).  This is only supported if compiled
against libfuse-2.6 or later. Reported by Greg Kochanski
2009-07-15 14:27:52 +00:00
Miklos Szeredi ae4614e690 Add option 'delay_connect': This will always create the sshfs mount,
even if the connection to the server can't be established.
2009-07-15 14:20:58 +00:00
Miklos Szeredi b1fa0408fb * Print usage information and version to stdout, not stderr.
Libfuse also needs to be fixed up.  Reported by Kārlis Repsons
2009-02-12 07:11:33 +00:00
Miklos Szeredi 09e37d536f Released 2.2 2008-10-20 12:15:07 +00:00
Miklos Szeredi be44229cfe Escape commas in fsname option if libfuse supports it 2008-10-20 12:03:16 +00:00
Miklos Szeredi c7dbdc1f77 Fix harmless glib assertations with "cache=no" 2008-10-08 18:23:33 +00:00
Miklos Szeredi 8a4015a3b6 * Handle numerical IPv6 addresses enclosed in square brackets. Reported by Andre-John Mas * Fix error if username contains a comma character. Reported by Yang Zhang 2008-10-08 11:07:48 +00:00
Miklos Szeredi fd52ef3e51 Released 2.1 2008-07-11 10:59:12 +00:00
Miklos Szeredi 1abdbe64a3 Add '-F' option to specify the ssh config file 2008-06-24 15:24:01 +00:00
Miklos Szeredi 4b28b15c34 Fix bug in caching which could cause file corruption for append mode writes 2008-05-06 15:10:28 +00:00
Miklos Szeredi 1a76a16bd9 man page update from Bartosz 2008-04-25 06:39:37 +00:00
10 changed files with 846 additions and 92 deletions
-17
View File
@@ -1,17 +0,0 @@
.deps
COPYING
INSTALL
FAQ.txt
Makefile
Makefile.in
aclocal.m4
*.cache
config.*
configure
compile
depcomp
install-sh
missing
sshfs
stamp*
.deps
+36
View File
@@ -0,0 +1,36 @@
#
# NOTE! Don't add files that are generated in specific
# subdirectories here. Add them in the ".gitignore" file
# in that subdirectory instead.
#
# NOTE! Please use 'git ls-files -i --exclude-standard'
# command after changing this file, to see if there are
# any tracked files which get ignored after the change.
.*
!.gitignore
*.o
*.lo
*.la
*.gz
\#*#
*.orig
*~
Makefile.in
Makefile
*.m4
stamp-h*
config.*
/sshfs
/ltmain.sh
/configure
/install-sh
/mkinstalldirs
/missing
/*.cache
/depcomp
/compile
/libtool
/INSTALL
/.pc
/patches
/m4
+339
View File
@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+93
View File
@@ -1,3 +1,96 @@
2011-07-01 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.3
2011-07-01 Miklos Szeredi <miklos@szeredi.hu>
* Add hard link operation. Works if the server supports the
"hardlink@openssh.com" protocol extension.
2011-03-25 Miklos Szeredi <miklos@szeredi.hu>
* Fix possible deadlock on reconnection. Reported by Florian
Zumbiehl
2011-01-25 Miklos Szeredi <miklos@szeredi.hu>
* Fix cleanup when ssh connection is terminated. This prevents
sshfs hanging when the server is rebooted, for example.
2010-03-16 Miklos Szeredi <miklos@szeredi.hu>
* Set FD_CLOEXEC on fuse device. This prevents deadlocks that
happen in some circumstances (bugzilla.kernel.org #12864).
Reported by Tim Connors
2009-07-15 Miklos Szeredi <miklos@szeredi.hu>
* Check mountpoint and fuse options before starting an ssh
session (debian bug #535333). This is only supported if compiled
against libfuse-2.6 or later. Reported by Greg Kochanski
* Check that the remote path specified refers to the same type of
file as the mountpoint, i.e. both are directories or both are
non-directories (debian bug #535343). Reported by Greg Kochanski
* Allow mounting a single non-directory from the server
2009-07-15 Sebastian Dransfeld <sebastid@tango.flipp.net>
* Add option 'delay_connect': This will always create the sshfs mount,
even if the connection to the server can't be established.
2009-01-27 Miklos Szeredi <miklos@szeredi.hu>
* Print usage information and version to stdout, not stderr.
Libfuse also needs to be fixed up. Reported by Kārlis Repsons
2008-10-20 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.2
2008-10-20 Miklos Szeredi <miklos@szeredi.hu>
* Escape commas in fsname option if libfuse supports it
2008-10-08 Miklos Szeredi <miklos@szeredi.hu>
* Handle numerical IPv6 addresses enclosed in square brackets.
Reported by Andre-John Mas
* Fix error if username contains a comma character. Reported by
Yang Zhang
* Fix harmless glib assertations with "cache=no"
2008-07-11 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.1
2008-07-11 Miklos Szeredi <miklos@szeredi.hu>
* Fix statvfs extension to match the current protocol in
opensshfs
* Check version numbers of extensions, so such changes wouldn't
cause stupid behavior
2008-06-24 Miklos Szeredi <miklos@szeredi.hu>
* Add '-F' option to specify the ssh config file. Patch by Pat
Pascal.
2008-05-06 Miklos Szeredi <miklos@szeredi.hu>
* Fix bug in caching which could cause file corruption for append
mode writes. Reported by Jose Alonso
2008-05-05 Miklos Szeredi <miklos@szeredi.hu>
* Fix compile on OS X. Original patch from Michael G Schwern
* Fix compile on Solaris. Reported by Jean-Jacques Sarton
2008-04-23 Miklos Szeredi <miklos@szeredi.hu>
* Released 2.0
+12
View File
@@ -1,3 +1,15 @@
What is new in 2.1, 2.2 and 2.3
-------------------------------
* Support hard link creation if server is OpenSSH 5.7 or later
* Check mount point and options before connecting to ssh server
* Handle commas in usernames
* Small improvements and bug fixes
What is new in 2.0
------------------
+44 -12
View File
@@ -28,6 +28,7 @@ struct cache {
GHashTable *table;
pthread_mutex_t lock;
time_t last_cleaned;
uint64_t write_ctr;
};
static struct cache cache;
@@ -47,6 +48,7 @@ struct fuse_cache_dirhandle {
fuse_dirh_t h;
fuse_dirfil_t filler;
GPtrArray *dir;
uint64_t wrctr;
};
static void free_node(gpointer node_)
@@ -103,11 +105,22 @@ static void cache_purge_parent(const char *path)
void cache_invalidate(const char *path)
{
if (!cache.on)
return;
pthread_mutex_lock(&cache.lock);
cache_purge(path);
pthread_mutex_unlock(&cache.lock);
}
void cache_invalidate_write(const char *path)
{
pthread_mutex_lock(&cache.lock);
cache_purge(path);
cache.write_ctr++;
pthread_mutex_unlock(&cache.lock);
}
static void cache_invalidate_dir(const char *path)
{
pthread_mutex_lock(&cache.lock);
@@ -148,19 +161,24 @@ static struct node *cache_get(const char *path)
return node;
}
void cache_add_attr(const char *path, const struct stat *stbuf)
void cache_add_attr(const char *path, const struct stat *stbuf, uint64_t wrctr)
{
struct node *node;
time_t now;
if (!cache.on)
return;
pthread_mutex_lock(&cache.lock);
node = cache_get(path);
now = time(NULL);
node->stat = *stbuf;
node->stat_valid = time(NULL) + cache.stat_timeout;
if (node->stat_valid > node->valid)
node->valid = node->stat_valid;
cache_clean();
if (wrctr == cache.write_ctr) {
node = cache_get(path);
now = time(NULL);
node->stat = *stbuf;
node->stat_valid = time(NULL) + cache.stat_timeout;
if (node->stat_valid > node->valid)
node->valid = node->stat_valid;
cache_clean();
}
pthread_mutex_unlock(&cache.lock);
}
@@ -222,13 +240,25 @@ static int cache_get_attr(const char *path, struct stat *stbuf)
return err;
}
uint64_t cache_get_write_ctr(void)
{
uint64_t res;
pthread_mutex_lock(&cache.lock);
res = cache.write_ctr;
pthread_mutex_unlock(&cache.lock);
return res;
}
static int cache_getattr(const char *path, struct stat *stbuf)
{
int err = cache_get_attr(path, stbuf);
if (err) {
uint64_t wrctr = cache_get_write_ctr();
err = cache.next_oper->oper.getattr(path, stbuf);
if (!err)
cache_add_attr(path, stbuf);
cache_add_attr(path, stbuf, wrctr);
}
return err;
}
@@ -268,7 +298,7 @@ static int cache_dirfill(fuse_cache_dirh_t ch, const char *name,
const char *basepath = !ch->path[1] ? "" : ch->path;
fullpath = g_strdup_printf("%s/%s", basepath, name);
cache_add_attr(fullpath, stbuf);
cache_add_attr(fullpath, stbuf, ch->wrctr);
g_free(fullpath);
}
}
@@ -299,6 +329,7 @@ static int cache_getdir(const char *path, fuse_dirh_t h, fuse_dirfil_t filler)
ch.h = h;
ch.filler = filler;
ch.dir = g_ptr_array_new();
ch.wrctr = cache_get_write_ctr();
err = cache.next_oper->cache_getdir(path, &ch, cache_dirfill);
g_ptr_array_add(ch.dir, NULL);
dir = (char **) ch.dir->pdata;
@@ -421,7 +452,7 @@ static int cache_write(const char *path, const char *buf, size_t size,
{
int res = cache.next_oper->oper.write(path, buf, size, offset, fi);
if (res >= 0)
cache_invalidate(path);
cache_invalidate_write(path);
return res;
}
@@ -449,9 +480,10 @@ static int cache_fgetattr(const char *path, struct stat *stbuf,
{
int err = cache_get_attr(path, stbuf);
if (err) {
uint64_t wrctr = cache_get_write_ctr();
err = cache.next_oper->oper.fgetattr(path, stbuf, fi);
if (!err)
cache_add_attr(path, stbuf);
cache_add_attr(path, stbuf, wrctr);
}
return err;
}
+2 -1
View File
@@ -24,5 +24,6 @@ struct fuse_cache_operations {
struct fuse_operations *cache_init(struct fuse_cache_operations *oper);
int cache_parse_options(struct fuse_args *args);
void cache_add_attr(const char *path, const struct stat *stbuf);
void cache_add_attr(const char *path, const struct stat *stbuf, uint64_t wrctr);
void cache_invalidate(const char *path);
uint64_t cache_get_write_ctr(void);
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(sshfs-fuse, 2.0)
AC_INIT(sshfs-fuse, 2.3)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
@@ -37,7 +37,7 @@ fi
AM_CONDITIONAL(SSH_NODELAY_SO, test "$enable_sshnodelay" = "yes")
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
PKG_CHECK_MODULES(SSHFS, [fuse >= 2.2 glib-2.0 gthread-2.0])
PKG_CHECK_MODULES(SSHFS, [fuse >= 2.3 glib-2.0 gthread-2.0])
have_fuse_opt_parse=no
oldlibs="$LIBS"
LIBS="$LIBS $SSHFS_LIBS"
+40 -2
View File
@@ -1,8 +1,27 @@
.TH SSHFS "1" "April 2008" "SSHFS version 2.0" "User Commands"
.SH NAME
SSHFS \- filesystem client based on ssh
.SH SYNOPSIS
.SS mounting
.TP
\fBsshfs\fP [\fIuser\fP@]\fBhost\fP:[\fIdir\fP] \fBmountpoint\fP [\fIoptions\fP]
.SS unmounting
.TP
\fBfusermount -u mountpoint\fP
.SH DESCRIPTION
usage: sshfs [user@]host:[dir] mountpoint [options]
SSHFS (Secure SHell FileSystem) is a file system for Linux (and other
operating systems with a FUSE implementation, such as Mac OS X or FreeBSD)
capable of operating on files on a remote computer using just a secure
shell login on the remote computer. On the local computer where the SSHFS
is mounted, the implementation makes use of the FUSE (Filesystem in
Userspace) kernel module. The practical effect of this is that the end user
can seamlessly interact with remote files being securely served over SSH
just as if they were local files on his/her computer. On the remote
computer the SFTP subsystem of SSH is used.
.PP
If \fIhost\fP is a numeric IPv6 address, it needs to be enclosed in
square brackets.
.SH OPTIONS
.SS "general options:"
.TP
\fB\-o\fR opt,[opt...]
@@ -21,12 +40,18 @@ equivalent to '\-o port=PORT'
\fB\-C\fR
equivalent to '\-o compression=yes'
.TP
\fB\-F\fR ssh_configfile
specifies alternative ssh configuration file
.TP
\fB\-1\fR
equivalent to '\-o ssh_protocol=1'
.TP
\fB\-o\fR reconnect
reconnect to server
.TP
\fB\-o\fR delay_connect
delay connection to server
.TP
\fB\-o\fR sshfs_sync
synchronous writes
.TP
@@ -36,7 +61,7 @@ synchronous reads (no speculative readahead)
\fB\-o\fR sshfs_debug
print some debugging information
.TP
\fB\-o\fR cache=YESNO
\fB\-o\fR cache=BOOL
enable caching {yes,no} (default: yes)
.TP
\fB\-o\fR cache_timeout=N
@@ -47,6 +72,7 @@ sets timeout for {stat,dir,link} cache
.TP
\fB\-o\fR workaround=LIST
colon separated list of workarounds
.RS 8
.TP
none
no workarounds enabled
@@ -65,15 +91,18 @@ fix truncate for old servers (default: off)
.TP
[no]buflimit
fix buffer fillup bug in server (default: on)
.RE
.TP
\fB\-o\fR idmap=TYPE
user/group ID mapping, possible types are:
.RS 8
.TP
none
no translation of the ID space (default)
.TP
user
only translate UID of connecting user
.RE
.TP
\fB\-o\fR ssh_command=CMD
execute CMD instead of 'ssh'
@@ -212,3 +241,12 @@ original encoding of file names (default: UTF-8)
.TP
\fB\-o\fR to_code=CHARSET
new encoding of the file names (default: ISO-8859-2)
.PD
.SH "AUTHORS"
.LP
SSHFS has been written by Miklos Szeredi <miklos@szeredi.hu>.
.LP
This man page was written by Bartosz Fenski <fenio@debian.org> for the
Debian GNU/Linux distribution (but it may be used by others).
+278 -58
View File
@@ -11,6 +11,7 @@
#include <fuse.h>
#include <fuse_opt.h>
#include <fuse_lowlevel.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
@@ -24,6 +25,7 @@
#include <netdb.h>
#include <signal.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/socket.h>
@@ -36,10 +38,15 @@
#include "cache.h"
#if FUSE_VERSION >= 23
#define SSHFS_USE_INIT
#ifndef MAP_LOCKED
#define MAP_LOCKED 0
#endif
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif
#define SSH_FXP_INIT 1
#define SSH_FXP_VERSION 2
#define SSH_FXP_OPEN 3
@@ -97,6 +104,7 @@
#define SFTP_EXT_POSIX_RENAME "posix-rename@openssh.com"
#define SFTP_EXT_STATVFS "statvfs@openssh.com"
#define SFTP_EXT_HARDLINK "hardlink@openssh.com"
#define PROTO_VERSION 3
@@ -184,6 +192,7 @@ struct sshfs {
int debug;
int foreground;
int reconnect;
int delay_connect;
char *host;
char *base_path;
GHashTable *reqtab;
@@ -209,6 +218,8 @@ struct sshfs {
char *password;
int ext_posix_rename;
int ext_statvfs;
int ext_hardlink;
mode_t mnt_mode;
/* statistics */
uint64_t bytes_sent;
@@ -278,6 +289,7 @@ enum {
KEY_HELP,
KEY_VERSION,
KEY_FOREGROUND,
KEY_CONFIGFILE,
};
#define SSHFS_OPT(t, p, v) { t, offsetof(struct sshfs, p), v }
@@ -301,6 +313,7 @@ static struct fuse_opt sshfs_opts[] = {
SSHFS_OPT("follow_symlinks", follow_symlinks, 1),
SSHFS_OPT("no_check_root", no_check_root, 1),
SSHFS_OPT("password_stdin", password_stdin, 1),
SSHFS_OPT("delay_connect", delay_connect, 1),
FUSE_OPT_KEY("-p ", KEY_PORT),
FUSE_OPT_KEY("-C", KEY_COMPRESS),
@@ -311,6 +324,7 @@ static struct fuse_opt sshfs_opts[] = {
FUSE_OPT_KEY("debug", KEY_FOREGROUND),
FUSE_OPT_KEY("-d", KEY_FOREGROUND),
FUSE_OPT_KEY("-f", KEY_FOREGROUND),
FUSE_OPT_KEY("-F ", KEY_CONFIGFILE),
FUSE_OPT_END
};
@@ -510,8 +524,26 @@ static inline void buf_add_path(struct buffer *buf, const char *path)
{
char *realpath;
realpath = g_strdup_printf("%s%s", sshfs.base_path,
path[1] ? path+1 : ".");
if (sshfs.base_path[0]) {
if (path[1]) {
if (sshfs.base_path[strlen(sshfs.base_path)-1] != '/') {
realpath = g_strdup_printf("%s/%s",
sshfs.base_path,
path + 1);
} else {
realpath = g_strdup_printf("%s%s",
sshfs.base_path,
path + 1);
}
} else {
realpath = g_strdup(sshfs.base_path);
}
} else {
if (path[1])
realpath = g_strdup(path + 1);
else
realpath = g_strdup(".");
}
buf_add_string(buf, realpath);
g_free(realpath);
}
@@ -650,29 +682,29 @@ static int buf_get_attrs(struct buffer *buf, struct stat *stbuf, int *flagsp)
static int buf_get_statvfs(struct buffer *buf, struct statvfs *stbuf)
{
uint32_t bsize;
uint32_t frsize;
uint64_t bsize;
uint64_t frsize;
uint64_t blocks;
uint64_t bfree;
uint64_t bavail;
uint64_t files;
uint64_t ffree;
uint64_t favail;
uint32_t fsid;
uint32_t flag;
uint32_t namemax;
uint64_t fsid;
uint64_t flag;
uint64_t namemax;
if (buf_get_uint32(buf, &bsize) == -1 ||
buf_get_uint32(buf, &frsize) == -1 ||
if (buf_get_uint64(buf, &bsize) == -1 ||
buf_get_uint64(buf, &frsize) == -1 ||
buf_get_uint64(buf, &blocks) == -1 ||
buf_get_uint64(buf, &bfree) == -1 ||
buf_get_uint64(buf, &bavail) == -1 ||
buf_get_uint64(buf, &files) == -1 ||
buf_get_uint64(buf, &ffree) == -1 ||
buf_get_uint64(buf, &favail) == -1 ||
buf_get_uint32(buf, &fsid) == -1 ||
buf_get_uint32(buf, &flag) == -1 ||
buf_get_uint32(buf, &namemax) == -1) {
buf_get_uint64(buf, &fsid) == -1 ||
buf_get_uint64(buf, &flag) == -1 ||
buf_get_uint64(buf, &namemax) == -1) {
return -1;
}
@@ -1284,17 +1316,18 @@ static void *process_requests(void *data_)
break;
}
pthread_mutex_lock(&sshfs.lock);
sshfs.processing_thread_started = 0;
close_conn();
g_hash_table_foreach_remove(sshfs.reqtab, (GHRFunc) clean_req, NULL);
sshfs.connver ++;
sshfs.outstanding_len = 0;
pthread_cond_broadcast(&sshfs.outstanding_cond);
pthread_mutex_unlock(&sshfs.lock);
if (!sshfs.reconnect) {
/* harakiri */
kill(getpid(), SIGTERM);
} else {
pthread_mutex_lock(&sshfs.lock);
sshfs.processing_thread_started = 0;
close_conn();
g_hash_table_foreach_remove(sshfs.reqtab, (GHRFunc) clean_req,
NULL);
sshfs.connver ++;
pthread_mutex_unlock(&sshfs.lock);
}
return NULL;
}
@@ -1338,12 +1371,17 @@ static int sftp_init_reply_ok(struct buffer *buf, uint32_t *version)
DEBUG("Extension: %s <%s>\n", ext, extdata);
if (strcmp(ext, SFTP_EXT_POSIX_RENAME) == 0) {
if (strcmp(ext, SFTP_EXT_POSIX_RENAME) == 0 &&
strcmp(extdata, "1") == 0) {
sshfs.ext_posix_rename = 1;
sshfs.rename_workaround = 0;
}
if (strcmp(ext, SFTP_EXT_STATVFS) == 0)
if (strcmp(ext, SFTP_EXT_STATVFS) == 0 &&
strcmp(extdata, "2") == 0)
sshfs.ext_statvfs = 1;
if (strcmp(ext, SFTP_EXT_HARDLINK) == 0 &&
strcmp(extdata, "1") == 0)
sshfs.ext_hardlink = 1;
} while (buf2.len < buf2.size);
}
return 0;
@@ -1518,11 +1556,16 @@ static int sftp_check_root(const char *base_path)
if (!(flags & SSH_FILEXFER_ATTR_PERMISSIONS))
goto out;
if (!S_ISDIR(stbuf.st_mode)) {
if (S_ISDIR(sshfs.mnt_mode) && !S_ISDIR(stbuf.st_mode)) {
fprintf(stderr, "%s:%s: Not a directory\n", sshfs.host,
remote_dir);
goto out;
}
if ((sshfs.mnt_mode ^ stbuf.st_mode) & S_IFMT) {
fprintf(stderr, "%s:%s: type of file differs from mountpoint\n",
sshfs.host, remote_dir);
goto out;
}
err = 0;
@@ -1566,6 +1609,11 @@ static int start_processing_thread(void)
return -EIO;
}
if (sshfs.detect_uid) {
sftp_detect_uid();
sshfs.detect_uid = 0;
}
sigemptyset(&newset);
sigaddset(&newset, SIGTERM);
sigaddset(&newset, SIGINT);
@@ -1583,11 +1631,10 @@ static int start_processing_thread(void)
return 0;
}
#ifdef SSHFS_USE_INIT
#if FUSE_VERSION >= 26
static void *sshfs_init(struct fuse_conn_info *conn)
#else
static void *sshfs_init(void)
static void *sshfs_init(void)
#endif
{
#if FUSE_VERSION >= 26
@@ -1596,13 +1643,11 @@ static void *sshfs_init(struct fuse_conn_info *conn)
sshfs.sync_read = 1;
#endif
if (sshfs.detect_uid)
sftp_detect_uid();
if (!sshfs.delay_connect)
start_processing_thread();
start_processing_thread();
return NULL;
}
#endif
static int sftp_request_wait(struct request *req, uint8_t type,
uint8_t expect_type, struct buffer *outbuf)
@@ -2036,6 +2081,25 @@ static int sshfs_rename(const char *from, const char *to)
return err;
}
static int sshfs_link(const char *from, const char *to)
{
int err = -ENOSYS;
if (sshfs.ext_hardlink) {
struct buffer buf;
buf_init(&buf, 0);
buf_add_string(&buf, SFTP_EXT_HARDLINK);
buf_add_path(&buf, from);
buf_add_path(&buf, to);
err = sftp_request(SSH_FXP_EXTENDED, &buf, SSH_FXP_STATUS,
NULL);
buf_free(&buf);
}
return err;
}
static int sshfs_chmod(const char *path, mode_t mode)
{
int err;
@@ -2116,6 +2180,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
uint32_t pflags = 0;
struct iovec iov;
uint8_t type;
uint64_t wrctr = cache_get_write_ctr();
if ((fi->flags & O_ACCMODE) == O_RDONLY)
pflags = SSH_FXF_READ;
@@ -2171,7 +2236,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
}
if (!err) {
cache_add_attr(path, &stbuf);
cache_add_attr(path, &stbuf, wrctr);
buf_finish(&sf->handle);
fi->fh = (unsigned long) sf;
} else {
@@ -2779,9 +2844,7 @@ static int processing_init(void)
static struct fuse_cache_operations sshfs_oper = {
.oper = {
#ifdef SSHFS_USE_INIT
.init = sshfs_init,
#endif
.getattr = sshfs_getattr,
.readlink = sshfs_readlink,
.mknod = sshfs_mknod,
@@ -2790,6 +2853,7 @@ static struct fuse_cache_operations sshfs_oper = {
.unlink = sshfs_unlink,
.rmdir = sshfs_rmdir,
.rename = sshfs_rename,
.link = sshfs_link,
.chmod = sshfs_chmod,
.chown = sshfs_chown,
.truncate = sshfs_truncate,
@@ -2812,7 +2876,7 @@ static struct fuse_cache_operations sshfs_oper = {
static void usage(const char *progname)
{
fprintf(stderr,
printf(
"usage: %s [user@]host:[dir] mountpoint [options]\n"
"\n"
"general options:\n"
@@ -2823,12 +2887,14 @@ static void usage(const char *progname)
"SSHFS options:\n"
" -p PORT equivalent to '-o port=PORT'\n"
" -C equivalent to '-o compression=yes'\n"
" -F ssh_configfile specifies alternative ssh configuration file\n"
" -1 equivalent to '-o ssh_protocol=1'\n"
" -o reconnect reconnect to server\n"
" -o delay_connect delay connection to server\n"
" -o sshfs_sync synchronous writes\n"
" -o no_readahead synchronous reads (no speculative readahead)\n"
" -o sshfs_debug print some debugging information\n"
" -o cache=YESNO enable caching {yes,no} (default: yes)\n"
" -o cache=BOOL enable caching {yes,no} (default: yes)\n"
" -o cache_timeout=N sets timeout for caches in seconds (default: 20)\n"
" -o cache_X_timeout=N sets timeout for {stat,dir,link} cache\n"
" -o workaround=LIST colon separated list of workarounds\n"
@@ -2913,6 +2979,12 @@ static int sshfs_opt_proc(void *data, const char *arg, int key,
ssh_add_arg("-oCompression=yes");
return 0;
case KEY_CONFIGFILE:
tmp = g_strdup_printf("-F%s", arg + 2);
ssh_add_arg(tmp);
g_free(tmp);
return 0;
case KEY_HELP:
usage(outargs->argv[0]);
fuse_opt_add_arg(outargs, "-ho");
@@ -2920,7 +2992,7 @@ static int sshfs_opt_proc(void *data, const char *arg, int key,
exit(1);
case KEY_VERSION:
fprintf(stderr, "SSHFS version %s\n", PACKAGE_VERSION);
printf("SSHFS version %s\n", PACKAGE_VERSION);
#if FUSE_VERSION >= 25
fuse_opt_add_arg(outargs, "--version");
sshfs_fuse_main(outargs);
@@ -3069,13 +3141,98 @@ static void set_ssh_command(void)
}
}
static char *find_base_path(void)
{
char *s = sshfs.host;
char *d = s;
for (; *s && *s != ':'; s++) {
if (*s == '[') {
/*
* Handle IPv6 numerical address enclosed in square
* brackets
*/
s++;
for (; *s != ']'; s++) {
if (!*s) {
fprintf(stderr, "missing ']' in hostname\n");
exit(1);
}
*d++ = *s;
}
} else {
*d++ = *s;
}
}
*d++ = '\0';
s++;
return s;
}
/*
* Remove commas from fsname, as it confuses the fuse option parser.
*/
static void fsname_remove_commas(char *fsname)
{
if (strchr(fsname, ',') != NULL) {
char *s = fsname;
char *d = s;
for (; *s; s++) {
if (*s != ',')
*d++ = *s;
}
*d = *s;
}
}
#if FUSE_VERSION >= 27
static char *fsname_escape_commas(char *fsnameold)
{
char *fsname = g_malloc(strlen(fsnameold) * 2 + 1);
char *d = fsname;
char *s;
for (s = fsnameold; *s; s++) {
if (*s == '\\' || *s == ',')
*d++ = '\\';
*d++ = *s;
}
*d = '\0';
g_free(fsnameold);
return fsname;
}
#endif
static int ssh_connect(void)
{
int res;
res = processing_init();
if (res == -1)
return -1;
if (!sshfs.delay_connect) {
if (connect_remote() == -1)
return -1;
if (!sshfs.no_check_root &&
sftp_check_root(sshfs.base_path) == -1)
return -1;
}
return 0;
}
int main(int argc, char *argv[])
{
int res;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
char *tmp;
char *fsname;
char *base_path;
const char *sftp_server;
int libver;
@@ -3094,6 +3251,7 @@ int main(int argc, char *argv[])
sshfs.fd = -1;
sshfs.ptyfd = -1;
sshfs.ptyslavefd = -1;
sshfs.delay_connect = 0;
ssh_add_arg("ssh");
ssh_add_arg("-x");
ssh_add_arg("-a");
@@ -3126,12 +3284,7 @@ int main(int argc, char *argv[])
}
fsname = g_strdup(sshfs.host);
base_path = strchr(sshfs.host, ':');
*base_path++ = '\0';
if (base_path[0] && base_path[strlen(base_path)-1] != '/')
sshfs.base_path = g_strdup_printf("%s/", base_path);
else
sshfs.base_path = g_strdup(base_path);
sshfs.base_path = g_strdup(find_base_path());
if (sshfs.ssh_command)
set_ssh_command();
@@ -3153,20 +3306,6 @@ int main(int argc, char *argv[])
ssh_add_arg(sftp_server);
free(sshfs.sftp_server);
res = processing_init();
if (res == -1)
exit(1);
if (connect_remote() == -1)
exit(1);
#ifndef SSHFS_USE_INIT
if (sshfs.detect_uid)
sftp_detect_uid();
#endif
if (!sshfs.no_check_root && sftp_check_root(base_path) == -1)
exit(1);
res = cache_parse_options(&args);
if (res == -1)
@@ -3183,21 +3322,102 @@ int main(int argc, char *argv[])
fuse_opt_insert_arg(&args, 1, "-oauto_cache,ac_attr_timeout=0");
tmp = g_strdup_printf("-omax_read=%u", sshfs.max_read);
fuse_opt_insert_arg(&args, 1, tmp);
g_free(tmp);
tmp = g_strdup_printf("-omax_write=%u", sshfs.max_write);
fuse_opt_insert_arg(&args, 1, tmp);
g_free(tmp);
#if FUSE_VERSION >= 27
libver = fuse_version();
assert(libver >= 27);
if (libver >= 28)
fsname = fsname_escape_commas(fsname);
else
fsname_remove_commas(fsname);
tmp = g_strdup_printf("-osubtype=sshfs,fsname=%s", fsname);
#else
fsname_remove_commas(fsname);
tmp = g_strdup_printf("-ofsname=sshfs#%s", fsname);
#endif
fuse_opt_insert_arg(&args, 1, tmp);
g_free(tmp);
g_free(fsname);
check_large_read(&args);
#if FUSE_VERSION >= 26
{
struct fuse *fuse;
struct fuse_chan *ch;
char *mountpoint;
int multithreaded;
int foreground;
struct stat st;
res = fuse_parse_cmdline(&args, &mountpoint, &multithreaded,
&foreground);
if (res == -1)
exit(1);
res = stat(mountpoint, &st);
if (res == -1) {
perror(mountpoint);
exit(1);
}
sshfs.mnt_mode = st.st_mode;
ch = fuse_mount(mountpoint, &args);
if (!ch)
exit(1);
res = fcntl(fuse_chan_fd(ch), F_SETFD, FD_CLOEXEC);
if (res == -1)
perror("WARNING: failed to set FD_CLOESEC on fuse device");
fuse = fuse_new(ch, &args, cache_init(&sshfs_oper),
sizeof(struct fuse_operations), NULL);
if (fuse == NULL) {
fuse_unmount(mountpoint, ch);
exit(1);
}
res = ssh_connect();
if (res == -1) {
fuse_unmount(mountpoint, ch);
fuse_destroy(fuse);
exit(1);
}
res = fuse_daemonize(foreground);
if (res != -1)
res = fuse_set_signal_handlers(fuse_get_session(fuse));
if (res == -1) {
fuse_unmount(mountpoint, ch);
fuse_destroy(fuse);
exit(1);
}
if (multithreaded)
res = fuse_loop_mt(fuse);
else
res = fuse_loop(fuse);
if (res == -1)
res = 1;
else
res = 0;
fuse_remove_signal_handlers(fuse_get_session(fuse));
fuse_unmount(mountpoint, ch);
fuse_destroy(fuse);
free(mountpoint);
}
#else
res = ssh_connect();
if (res == -1)
exit(1);
res = sshfs_fuse_main(&args);
#endif
if (sshfs.debug) {
unsigned int avg_rtt = 0;