Commit Graph

688 Commits (49eaca0c42a15e1053355af4c96a4bee11cd4be3)

Author SHA1 Message Date
Alon Bar-Lev 8338c7e27f build: add m4 directory to source tree
m4 directory is required for autotools generation, the use of bootstrap
script is nice helper, however, the autoreconf -ivf should be usable
for autotools based checkout without any other action.

these days the bootstrap script is kinda useless, in the old days it was
a very complex set of autoconf/automake/libtool/gettext commands.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2015-08-24 01:05:00 +03:00
Ronnie Sahlberg cc69b9c189 Merge pull request #123 from plieven/fix_rpc_error
init: do not write to stderr in rpc_set_error
2015-08-06 05:40:42 -07:00
Peter Lieven 29ab169d2b init: do not write to stderr in rpc_set_error
only log error if debug >= 1.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-06 10:12:04 +02:00
Peter Lieven aacee393ca socket: also reconnect on write errors
This also return -1 for rpc_service if rpc_reconnect_requeue fails.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-06 09:53:49 +02:00
Ronnie Sahlberg e466dc6b03 Merge pull request #121 from plieven/fix_recv
socket: handle count == 0 in rpc_read_from_socket
2015-08-04 16:12:43 -07:00
Peter Lieven b319b976dc socket: handle count == 0 in rpc_read_from_socket
An EOF is signalled through a POLLIN event and subsequen recvs return
always 0. Handle this condition and reconnect. Otherwise we might
deadlock here.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-08-04 14:55:28 +02:00
Ronnie Sahlberg 2288339ed4 Merge pull request #120 from plieven/m4_fix
bootstrap: create m4 directory
2015-08-02 11:04:27 -07:00
Ronnie Sahlberg 8f06fc9d92 New version 1.9.8
- Disable multithreading in fuse_nfs
- Add -Wall and -Werror compiler flags (and fix issues found by it)
- Add nfs-cat utility
- Switch to using nfs_[f]stat64 instead of the deprecated nfs_[f]stat call
  in all examples
- If the server does not return any atttributes for entries in READDIRPLUS
  then try to fetch them using lookup instead.
- Reconnection fixes
- Enforce the max pdu size and add sanity checks when reading PDUs from
  the socket.
- Stop using ioctl(FIONREAD) to find out how many bytes to read, and treat
  0 as an indication of a problem. Some applications call their POLLIN handlers
  spuriosly even when there is no data to read, which breaks this check in
  libnfs.
- Add basic support to do logging.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 10:18:25 -07:00
Peter Lieven b09a55f3d3 bootstrap: create m4 directory
newer versions of autotools fail if the directory is not there.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-07-14 14:20:48 +02:00
Ronnie Sahlberg 68941809a8 Merge pull request #118 from plieven/for_upstream
For upstream
2015-06-23 14:17:35 -07:00
Peter Lieven 9bff07490f add basic support for setting a log level
only logging to stderr is supported at the moment. Per default
there is no output. Its possible to set the log level via
debug url parameter.

Example:
 nfs-ls nfs://127.0.0.1/export?debug=2

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-23 08:55:11 +02:00
Peter Lieven f7bc4c8bb1 init: do not leak rpc->inbuf
additionally free(NULL) is a NOP. So simplify the code

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 16:22:20 +02:00
Peter Lieven 24429e95b8 socket: we have to use memmove in rpc_read_from_socket
I was errornously believing that the areas could not overlap.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 15:54:54 +02:00
Peter Lieven beaa838637 fix some compiler warnings
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:49:17 +02:00
Peter Lieven 7000a0aa04 socket: make rpc->inbuf static and simplify receive logic
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:26 +02:00
Peter Lieven 82aec93f12 socket: limit memory allocation when reading from socket
the write limit of libnfs has been 1M since a long time.
Restrict rtmax and wrmax to 1M and error out otherwise.

Limit the PDU size when reading from socket to rule out
malicious servers forcing us to allocate a lot of memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:20 +02:00
Peter Lieven dc70b92dc6 socket: reset written bytes for head outqueue element
We could be in the middle of writing a PDU while we start reconnecting.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:45:15 +02:00
Peter Lieven cf420d32d0 socket: use FIONREAD ioctl only for UDP
under Linux poll might return POLLIN even if there are no bytes available for read.
See select(2) manpage for surious readiness under BUGS.

As a consequence we start dropping TCP connections which are still alive.

Signed-off-by: Peter Lieven <pl@kamp.de>

Conflicts:
	lib/socket.c
2015-06-19 13:45:03 +02:00
Peter Lieven 99ae3c01c4 add some debug output
Signed-off-by: Peter Lieven <pl@kamp.de>
2015-06-19 13:43:55 +02:00
Ronnie Sahlberg 68b0298102 Add missing NULLing of data->continue_data for READDIR
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-26 19:50:00 -07:00
Ronnie Sahlberg d8ba04d9c6 READDIRPLUS: use lookup on entries where the server did not return any attr
Some servers sometimes do not return attrivbutes for files in the RDP
replies. So we need to fallback to using LOOKUPs for these entries
just like we always have to do in the READDIR case.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-25 16:53:56 -07:00
Ronnie Sahlberg 7121bc3b89 Merge branch 'master' of github.com:sahlberg/libnfs 2015-05-24 07:51:00 -07:00
Ronnie Sahlberg 08ea9a3138 UTILS: move nfs-cp from examples to utils
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:50:43 -07:00
Ronnie Sahlberg eadef4f724 UTILS: move nfs-cp from examples to utils
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:49:09 -07:00
Ronnie Sahlberg ec3a3afeae EXAMPLES: convert remaining nfs_[f]stat to nfs_[f]stat64
The old nfs_[f]stat calls are deprecated. Convert to the newer
nfs_[f]stat64 call that takes struct nfs_stat_64

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:38:17 -07:00
Ronnie Sahlberg 6f2727468d FUSE: use nfs_stat64() not nfs_stat()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:19:01 -07:00
Ronnie Sahlberg 32633fc3af Merge branch 'master' of github.com:sahlberg/libnfs 2015-05-24 07:05:38 -07:00
Ronnie Sahlberg 4b1de15bb5 UTILS: add nfs-cat utility
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-05-24 07:05:20 -07:00
Ronnie Sahlberg 77e3d80f26 Merge pull request #114 from rosslagerwall/licenses
Include the BSD license text in a separate file
2015-03-30 09:48:33 -07:00
Ross Lagerwall 6741cd7b55 Include the BSD license text in a separate file
The BSD license requires that it is included with binary distributions.
Including the text in a separate file makes it easier for distros to do
this.

Also include the license files in the source tarball.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2015-03-29 15:02:10 +01:00
Ronnie Sahlberg 63d40b1737 Revert "Remove unused variable from socket.c"
This reverts commit d74a938775.
2015-03-12 20:52:52 -07:00
Ronnie Sahlberg 471aa1b1af Merge pull request #113 from MilhouseVH/unused-variables
[Cosmetic]: Remove unused variables and eliminate  [-Wunused-variable] warnings
2015-03-12 20:51:22 -07:00
MilhouseVH d74a938775 Remove unused variable from socket.c 2015-03-12 05:29:56 +00:00
MilhouseVH 221df2245e Removed unused variables from nfs-ls.c 2015-03-12 05:20:18 +00:00
MilhouseVH 7b853063c9 Remove unused variables from raw (generated) files 2015-03-12 05:15:55 +00:00
Ronnie Sahlberg 617cfba5b5 configure is hard. now it looks like --enable-werror works
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-11 21:22:43 -07:00
Ronnie Sahlberg d01e75de8a configure: only add -Werror id --enable-werror is used
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-11 20:32:04 -07:00
Ronnie Sahlberg 4d318527ea Merge branch 'master' of github.com:sahlberg/libnfs 2015-03-10 21:09:00 -07:00
Ronnie Sahlberg 84607f4821 Add -Wall -Werror and friends
Update the configure to add some sanity -W arguments.
A good start is probably :
  -Wall -Werror -Wshadow -Wno-write-strings -Wstrict-prototypes
  -Wpointer-arith -Wcast-align -Wno-strict-aliasing

Fixup the paces in the code that triggers.
(one of which is readahead code which is perhaps broken?)

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-10 21:06:38 -07:00
Ronnie Sahlberg 6da5bc1cc7 Merge pull request #109 from agraf/master
fuse_nfs: Disable multithreading
2015-02-16 15:29:48 -08:00
Alexander Graf a5042b9857 fuse_nfs: Disable multithreading
If we blindly spawn new threads based on existing open NFS shares, all
threads will concurrently still run on the same file descriptors for NFS
traffic, colliding sooner or later.

This is what happens with the fuse-nfs example program. To steer us back
into safety, we can just tell fuse to not do multi-threading which this
patch does.

This patch fixes random connection aborts with fuse_nfs for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-02-15 01:49:23 +01:00
Ronnie Sahlberg e775160243 new version 1.9.7
- Auto-traverse mounts. With this option (default to on) libnfs will
   autodiscover and handle any nested submounts.
 - Remove nfs_get_current_offset. Applications should use seek instead of this function.
 - Add umask() support.
 - Change set_tcp_sockopt() to be static.
 - Android fix for nfs-ls
 - Make S_IFLNK available on windows.
 - Fix a use after free.
 - Fix a bug where truncate() treated offset as 32bit.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-09 19:16:56 -08:00
Ronnie Sahlberg 732a297884 Merge pull request #107 from rosslagerwall/invalid-free
libnfs: Fix use after free
2015-02-02 20:32:08 -08:00
Ross Lagerwall bf52e348ad libnfs: Fix use after free
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2015-02-02 23:32:32 +00:00
Ronnie Sahlberg f6e7505baa libnfs: make continue_int 64 bit to avoid sign extension bug for truncate()
Make the continue_int field we use through the internal callbacks a uint64_t
instead of an int.
This fixes a bug for the truncate function where we pass the offset to truncate
to via this field.

The bug is that otherwise we first truncate the field to an int and then
in the callback we cast this int back to a uint64_t again.

If the user called truncate with an offset that is >= 2^31
then :
IF the 1<<31 bit is cleared then we would truncate to (offset & 0xffffffff)
IF the 1<<31 bit is set, we would instead truncate to (offset | 0xffffffff00000000)

Reported-by: doktorstick at github
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-26 17:11:10 -08:00
Ronnie Sahlberg 8e991ffbdd Merge pull request #105 from rosslagerwall/submount-opendir
opendir_cb: Retrieve attributes for a top-level submount correctly
2015-01-18 14:43:32 -08:00
Ross Lagerwall 368ee352a6 opendir_cb: Retrieve attributes for a top-level submount correctly
Fix retrieving the attributes for a submount in nfs_opendir when
the submount is an entry of '/'.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2015-01-18 22:18:18 +00:00
Ronnie Sahlberg d1c2c47ff0 Add auto-traverse-mount URL argument and default it to TRUE
Add a URL argument to enable/disable the use of automatic traversal of nested
mounts for a libnfs context. Default it to enabled.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:49:08 -08:00
Ronnie Sahlberg 1eea1c4647 opendir_cb: use attributes from the nested mount in opendir
When opendir_cb encounters an entry that refers to a nested mount, then
replace the attributes with those attributes we collected for this export
during the mount and return those instead.

This makes traversing a director that crosses into a different filesystem
on the server transparent to the client.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:32:31 -08:00
Ronnie Sahlberg 27348486f6 nfs_lookuppath_async: replace path components with nested mount filehandles
Durng nfs_lookuppath_async, check if the requested path traverses into
a nested mountpoint and if so, skip resolving that part of thre path and just
use the filehandle for the nested mount.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:29:14 -08:00