Commit Graph

555 Commits (65de83140aa6264b75a8cb5eda9e0ba1b1f56b9b)

Author SHA1 Message Date
Ronnie Sahlberg 65de83140a NFSv4: Add support (and tests) for open(O_APPEND)
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-08-03 20:25:59 +10:00
Ronnie Sahlberg 2ce8890458 NFSv4: Add open(O_SYNC) support
Also update close() so we only send a COMMIT if there is still
unstaged data written.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-30 09:44:31 +10:00
Ronnie Sahlberg 42d14779b7 NFSv4: Add support for open(O_TRUNC)
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-30 08:36:18 +10:00
Ronnie Sahlberg 61e071d448 NFSv4: Add support for nfs_[p]write()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-29 19:52:41 +10:00
Ronnie Sahlberg 5c73d788b1 NFSv4: Populate functions should return how many operations they did append.
The populate functions will soon start appending varying number of operations.
For examle the case of open(O_TRUNC) where we would append an extra
SETATTR(size=0) at the end of the compound chain.

Thus use the number of ops that the populate function retured for when
we compute the length of the compound chain instead of assuming it is always
a constant.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-29 09:27:35 +10:00
Ronnie Sahlberg 5a78bd5a7a NFSv4: Update nfs_open() to support symlinks
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-28 19:39:27 +10:00
Ronnie Sahlberg 9f44b157f0 NFSv4: fix compiler warnings
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-27 07:28:23 +10:00
Ronnie Sahlberg 4fa3b4b258 NFSv4: Always send a GETATTR as part of the path lookup
Send a GETATTR for the final component in the path lookup so that
we can detect and act on it being a symlink.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-27 07:16:18 +10:00
Ronnie Sahlberg 5c2d989887 NFSv4: Add support for readlink()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-26 14:26:29 +10:00
Ronnie Sahlberg f3211e9be5 NFSv4 Add support for symlink()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-26 14:26:29 +10:00
Ronnie Sahlberg dce044ab53 NFSv4: Add support for read() and pread()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-26 14:26:29 +10:00
Ronnie Sahlberg 0d9dd0ee44 NFSv4 Add support for nfs_open() nfs_fstat64() nfs_close()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-26 14:26:29 +10:00
Ronnie Sahlberg 93fbecd7c1 NFSv4 Add support for nfs_rmdir()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-14 07:04:28 +10:00
Ronnie Sahlberg 8a9fceb725 NFSv4: Add support for nfs_mkdir2()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-13 23:04:35 +10:00
Ronnie Sahlberg 3ced39f567 Rework the NFSv4 path lookup framework so it handles symlinks properly.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-13 18:22:27 +10:00
Ronnie Sahlberg dc9669abd5 Fix compiler warnings about cast from char* -> uint32_t*
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 16:33:55 +10:00
Ronnie Sahlberg 5159b76e00 NFSv4: add support for nfs_lstat64()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 13:46:28 +10:00
Ronnie Sahlberg 546c9455c7 Don't use random()/srandom()
We can create a initial verifier that is good enough by just using
the current time and the pid.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 12:58:31 +10:00
Ronnie Sahlberg 4cb34e2c9a Merge branch 'nfsv4' 2017-07-08 09:58:11 +10:00
Ronnie Sahlberg fc677be6a3 Bump the pdu timeout by 1000ms when we do not have clock_gettime()
If we fallback to time() we have 1 second granularity of our timestamps.
Thus we need to bump the pdu timestamp we set by this granularity or
the timeout will trigger too early.

For a 1s timeout, this means that we now will trigger the timeout between
1.0 - 2.0 seconds instead of the previous  0.0 - 1.0 seconds.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 09:55:14 +10:00
Chris Richards fb1efbe51c Increased resolution of PDU timeout from seconds to milliseconds 2017-07-08 09:47:51 +10:00
Ronnie Sahlberg e27453b4a9 Make valgrind happy for libnfs_zdr_bytes
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 07:56:23 +10:00
Ronnie Sahlberg 2b764fa926 NFSv4: Add support for nfs_stat64()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-08 07:41:11 +10:00
Ronnie Sahlberg 56194deeee NFS4: Add support to nfs_mount()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-06 10:04:17 +10:00
Ronnie Sahlberg 4ed461ffee TESTS Add tests for nfs_open()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-04 08:18:13 +10:00
Ronnie Sahlberg 2762897585 Typos
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-04 07:00:30 +10:00
Ronnie Sahlberg 673860b1bf Reformat socket.c
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-03 11:31:29 +10:00
Ronnie Sahlberg 6ea6002e08 Fix nfs_creat() so it works with local directories and add tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-03 07:01:07 +10:00
Ronnie Sahlberg 9fdc774bf3 TESTS: add tests for mknod
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-02 12:28:06 +10:00
Ronnie Sahlberg aff3099f00 TEST: add tests for nfs_link
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-02 10:42:19 +10:00
Ronnie Sahlberg c6ac1b5a14 Make nfs_unlink work for local paths and add tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-02 09:31:17 +10:00
Ronnie Sahlberg e1a2f9f5e7 Allow mkdir/rmdir to work for the local directory and add tests
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-07-02 08:52:36 +10:00
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 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 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