Commit Graph

978 Commits (352325169ce93187c205d1ebfb7b2c2ce605b78f)

Author SHA1 Message Date
Ronnie Sahlberg 0c5732eb26 Fix SEGV in rename error paths and add tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-02 07:48:56 +10:00
Ronnie Sahlberg 903021ed59 TESTS: Tests and fixes for nfs_rename
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 17:10:23 +10:00
Ronnie Sahlberg ea94d4e3a6 nfs_symlink: Fix it so we can create symlinks in the current directory
Fix a bug in hte symlink code that required that linkname contained at least one
path component and thus prevented us from creating symlinks in the current
directory.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 10:19:00 +10:00
Ronnie Sahlberg 8fa13b3a90 TESTS: improve softlink tests and validate the links are visible locally
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 09:21:57 +10:00
Ronnie Sahlberg ad6f95d9f9 More reformatting of libnfs-raw.h
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 09:07:28 +10:00
Ronnie Sahlberg e1f01238d5 README: clarify status of nfsv4 support. I.e. not yet functional.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 08:44:25 +10:00
Ronnie Sahlberg 9776ca3a95 Merge branch 'nfsv4' 2017-07-01 08:43:23 +10:00
Ronnie Sahlberg db6d0836f4 TESTS: add tests for symlink/readlink
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 08:40:59 +10:00
Ronnie Sahlberg 36a1e0662c Perform the timeout scan at the start of the service routine instead of the end.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-01 07:59:26 +10:00
Ronnie Sahlberg 1e01500007 Clear revents before calling poll in the event loops for the sync API.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-30 13:55:31 +10:00
Ronnie Sahlberg 0e0bb3fb34 NFSv4: Move all v3 specific code into its own nfsv3.c file
Split out the nfsv3 code from libnfs.c into its own file.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-30 13:48:59 +10:00
Ronnie Sahlberg 0160cbfa39 NFSv4: Rename all V3 specific internal functions from nfs_ to nfs3_
Change all public posix like functions to switch on the protocol version
and call out to the existing functions when NFS v3 is selected.

Rename all internal functions that are v3 specific to have a nfs3_ prefix.

We do not yet have any v4 support but we now have the framework to start plugging it in.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-30 13:48:59 +10:00
Ronnie Sahlberg 4a6012ea74 NFSv4: Add support for selecting version via url argument or nfs_set_version
This only allow selecting the version for the context.
There is still no real v4 support and all I/O is still using v3.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-30 13:48:59 +10:00
Ronnie Sahlberg de9e123099 Clear revents before calling poll in the event loops for the sync API.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-30 13:48:16 +10:00
Ronnie Sahlberg a0f187d9c9 Remove the leading emacs-comment in nfs4.x as rpcgen does not like it.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-29 19:23:20 +10:00
Ronnie Sahlberg 55144f237b libnfs-raw.h: Reformat the file and remove EXTERN
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-29 15:57:05 +10:00
Ronnie Sahlberg 659874b1ce TESTS: Verify we do not leak memory on timeouts
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-29 09:02:49 +10:00
Ronnie Sahlberg 04cdb72bb1 TESTS: Verify we fail on RPC timeouts
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-29 08:34:44 +10:00
Ronnie Sahlberg c030d82d99 Fix compiler warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-29 07:10:47 +10:00
Ronnie Sahlberg 12a27fd888 TEST: Add tests using valgrind to check for memory leaks
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-18 10:28:18 -07:00
Ronnie Sahlberg 98218ec226 TEST: Add simple test for read/write
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-18 09:58:22 -07:00
Ronnie Sahlberg e4608007e7 TEST: Add basic test for create and unlink
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-17 15:21:21 -07:00
Ronnie Sahlberg 141581d9d5 TEST: Add a simple test for mkdir/rmdir
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-17 15:14:24 -07:00
Ronnie Sahlberg fa710176f2 TEST: Add test for fstat
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-17 13:45:42 -07:00
Ronnie Sahlberg b215830532 TEST: Add a test that building RPMs work
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-17 12:35:19 -07:00
Ronnie Sahlberg d991f4dcfe TEST: Add basic test for nfs_stat64()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-17 10:20:41 -07:00
Ronnie Sahlberg 46b035a51e RPM: minor fixes to the RPM build
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-16 21:19:39 -07:00
Ronnie Sahlberg 2179bb6720 TESTS: remove obsolete define in functions.sh
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-16 15:04:31 -07:00
Ronnie Sahlberg 1a3c8c23ef TESTS: Add tests for server discovery and share enumeration
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-16 15:03:58 -07:00
Ronnie Sahlberg bbf38735d8 TESTS: Initial test directory.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-16 13:14:31 -07:00
Ronnie Sahlberg d3af23322a New version : 2.0.0
The main changes since 1.11.0:

BUGS
====
Fix NULL pointer crash in nfs_link().

Clamp read/write size for servers (Ganesha) that offer very large io sizes
instead of failing to connect to the export.

Tell the server to commit all data to stable storage when we close files.

Double free fix: don't call rpc_free_pdu() after rpc_queue_pdu() failure.

Fix for memory leak in rpc_allocate_*().

Fixes to build nfs-ls and nfs-cp on win32.

Abort the mount process correctly if MOUNT/MNT returns error or is cancelled.

Fix memory leak in error path in nfs_create_2_cb().

Fix leak of rpc->inbuf if we destroy the context while we still have PDUs
in flight.

FEATURES
========
Add O_NOFOLLOW support for nfs_open()

Add a new mkdir2 command that also takes a mode argument.

Add a new readlink2 command that avoids having to preallocate the buffer.

Add support for RPC timeouts for both the sync and async interfaces.

Build fixes for Mingw and Cygwin

Update README to document two new Windows builds

Use SOCK_CLOEXEC for the sockets

Make rpc_set{g|u}id() public

Performance optimization: socket: Batch pdu read in rpc_read_from_socket

Low level support for NFSv4 and some examples

Support for building RPC servers

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-16 12:48:10 -07:00
Ronnie Sahlberg a17f6aefdf Zero mout the nfs cb data struct after alloc in async lseet
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-15 17:01:38 -07:00
Ronnie Sahlberg 004672a855 Change async lseek to use nfs_cb_data as all other async nfs functions do
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-15 14:45:29 -07:00
Ronnie Sahlberg 2bbd3bfd38 Change NFS layer error checking to handle TIMEOUTs in libnfs.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-15 14:45:12 -07:00
Ronnie Sahlberg 53f87ada10 Handle TIMEOUT errors for the rpc layer errors in libnfs.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-15 14:44:26 -07:00
Ronnie Sahlberg 3ba14aabc2 Add timeout support in wait_for_nfs_reply
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-06-15 13:16:23 -07:00
Ronnie Sahlberg 128ac2f725 Update the event-loop for sync NFS commands to handle timeouts better.
Change the loop so poll will timeout after 100ms so that we get 100ms
granularity on the timer that drives the timeouts.

Secondly, stop treating poll returning 0 as an error as this will be normal
if an application use sync NOF commands set to >>100ms for the timeout.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-31 21:23:03 -07:00
Ronnie Sahlberg b7fd060bc6 Do not fail the session just because the reply we got can not be matched to a pdu
The command might have simply timed out and this will not match anything in our
wait queue.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-31 21:06:36 -07:00
Ronnie Sahlberg 173ad2b1f3 Change how auto-reconnect works
For NFS sessions, change the autoreconnect options to be :
-1:  (default) retry connectiong back to the server forever. Just like
normal NFS clients do.
0: Do not attempt reconnecting at all. Immediately fail and return an
error back to the application on session loss.
>=1: Retry connecting to the server this many times before giving up.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-31 19:46:18 -07:00
MilhouseVH eee1b4f7f2 use-after-free: quick hack 2017-05-14 16:18:05 -07:00
Ronnie Sahlberg 165e51a81b Merge pull request #217 from earlchew/issues-215
Only process pdus once when propagating cancellations or errors
2017-05-11 18:51:21 -07:00
Ronnie Sahlberg 6afd405587 Merge branch 'master' into issues-215 2017-05-11 18:51:13 -07:00
Ronnie Sahlberg a25e050172 Merge pull request #219 from earlchew/issues-216
Deliver poll(2) errors to callbacks when running the sync event loop
2017-05-11 18:32:22 -07:00
Ronnie Sahlberg f8ce80d454 Merge branch 'master' into issues-216 2017-05-11 18:30:30 -07:00
Ronnie Sahlberg f6895705c4 Merge pull request #220 from kevin-vigor/master
Fix crash on timed out mount-nfs calls.
2017-05-11 18:26:01 -07:00
Kevin Vigor 4cd723fb7a Fix crash on timed out mount-nfs calls.
If wait_for_nfs_reply() times out, nfs_mount can return with RPCs
still pending. In that case when the RPCs complete (perhaps because
someone calls destroy_context()), the callbacks run, and private_data
is pointing at what was the stack-allocated cb_data structure. Stack
smashing and segfaulty fun ensue.

Fix by ensuring no RPCs are pending before returning from nfs_mount()
by disconnecting on errors.
2017-05-11 15:19:01 -06:00
Earl Chew 5a2afb8872 Deliver poll(2) errors to callbacks when running the sync event loop
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-11 07:00:49 -07:00
Ronnie Sahlberg 79d1dc5ad7 Merge branch 'issues-212' of https://github.com/earlchew/libnfs into earlchew-issues-212
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-10 21:26:57 -07:00
Earl Chew ef8c67e81e Provide documentation for autoreconnect option
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-10 20:29:00 -07:00
Earl Chew f986a53835 Only process pdus once when propagating cancellations or errors
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-10 19:20:34 -07:00