This mostly consists of creating one slave nfs_context for each nfs
thread to track the error-string.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
We create a new lock_owner for every open(), to reduce pressure on the
servers lock_owner cache we can tell it that this lock_owner will not
be used again and it can drop it from the cache.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This allows us to perform unlimited concurrent opens as we are longer
bound by rfc3530 8.1.5 which limits to only one active OPEN command
per lock_owner
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Some multi-stage operations in nfs v4 can not be interleaved
so add mutex to prevent them from running concurrently.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
The NFS4 pwrite operations contains a memory corruption if a write
is large than 4KB. The reason is that the buffer allocated within
nfs4_compund_async has a size of 4K and it does not account
for the size of the write buffer. To fix this the patch
padds a rpc_allocate_ndu2 function which an additional parameter
as an extra hint for the allocation.
This patch fixes various issues around chmod/chown/utimes:
- The chmod/chown/utimes approach uses open_async_internal, which only works
for files. This patch uses lookup_path so that chmod/chown is also
possible on directories.
- Implements SET_TO_SERVER for utimes
I never succeeded in getting all tests passing even without
these changes. Nor did I succeed in getting the CMake compilation to
work. Sorry. The patch includes extra unit tests for these calls.
We use the libary as part of a test harness to test an NFS server
implementation, so I am reasonably confident that the changes work.
They are also manually tested against the Linux Kernel NFS Server.
Add a new function nfs_statvfs64() that returns a struct nfs_statvfs_64
where all fields are uint64_t.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Default to use port 2049. If server runs on a different port then
we must manually override this with the nfsport flag.
NFSv4 servers can run without any portmapper daemon at all and we
must be prepared for that.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Add two arguments to set which port to use for MOUNT (only used in NFSv3)
as well as for the NFS protocols.
When set to non-zero libnfs will connect directly to that port and bypass
the use of portmapper completely.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
It didn't fail if pwd.h is missing because #includes must be seperated with a newline, a comma won't work.
The compile works anyway because the "struct passwd *pwd" implicitly declares an anonymus struct type "passwd"
and using an undeclared function is an implicit function declaration. Here's the output of configure in that case:
configure:13381: checking whether getpwnam() is available
configure:13396: i686-w64-mingw32-gcc -c -I/home/daniel/fsetmp/dokany/src/dokan_fuse/include/ -I/home/daniel/fsetmp/dokany/src/dokan_fuse/include/ conftest.c >&5
conftest.c:23:23: warning: extra tokens at end of #include directive
#include <sys/types.h>, #include <pwd.h>
^
conftest.c: In function 'main':
conftest.c:28:30: warning: implicit declaration of function 'getpwnam' [-Wimplicit-function-declaration]
struct passwd *pwd = getpwnam("nobody");
^~~~~~~~
conftest.c:28:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
configure:13396: $? = 0
configure:13403: result: yes
we already convert this into "65534" anyway so there is no point in
also logging an error if we failed the name to uid/gid mapping.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Some nfsv4 servers return a user/group name in the attributes instead
of a uid/gid number. At least for the "nobody" user.
For those, try to use getpwnam() where available to map the string back
to a uid/gid or return uid/gid==65534 (common value for nobody)
if not available or failing.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Rework the open() flow so we can append a extra callback to be invoked
once the open has completed.
Use this new feature to implement both nfs_truncate() as well as simplify
open(O_TRUNC) support.
Later this can be used for other commands too that need to open a path
and do something.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Split path lookups is where we have a path '/this/is/the/path'
and we split it up into doing a lookup on '/this/is/the'
and append a different operation on 'path'.
Create a dedicated function that performs this initialization
and remove a lot of code duplication.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
The two functions are identical but in this case it is the fh we are
interested in and not the attributes.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This function is identical to nfs_rmdir() so create a common
function that we call from both unlink and rmdir.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>