Commit Graph

679 Commits (master)

Author SHA1 Message Date
Vitaliy Filippov 5a991e1fcb Do not try to ZDR_DECODE bytes into a preallocated buffer (it also segfaults) 2022-02-12 14:09:40 +03:00
Vitaliy Filippov 338e176320 Fix rpc_read_from_socket (no idea how it worked before) 2022-02-12 13:57:31 +03:00
Vitaliy Filippov 45430b3c38 Add an opaque pointer argument to service_proc
Without this argument it's impossible to pass an object instance to procedure
callbacks which basically forces users to either use global variables or to
write additional boilerplate code and find object instances from rpc_context
pointer values.
2022-02-06 02:29:39 +03:00
Ronnie Sahlberg 4785ab7eae multithreading/ptread: gettid() is not available in all versions
gettid() is not guaranteed to be universally available
so replace this with calling the syscall directly for
building on Linux with Multithreading enabled.

Windows already use a native call for this so it should be unaffected
but other unix-like systems with pthread support will need to have
a replacement function here as well.
This is todo for later for non-linux pthread platforms.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2022-02-03 17:26:26 +10:00
heitbaum 680ceb8d2c nfsv4: fix nfs4_op_release_lockowner defined but not used 2022-01-28 23:33:07 +00:00
heitbaum 7b7648e0d8 nfsv3: fix multithreading mutex 2022-01-28 23:28:54 +00:00
heitbaum 26133258fd nfsv4: fix multithreading mutex 2022-01-28 23:21:34 +00:00
Ronnie Sahlberg a48f019e05 New version 5.0.0
Multithread support for Linux and Windows
Fix NFS4 behavior of chmod/chown/utimes
Add marshalling / unmarshalling of various NFSv4.1 structures (but not 4.1 support)
PS3 support
PS2 EE support
Support escaped characters in the URL
Fix MINGW build

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2022-01-28 10:50:38 +10:00
Ronnie Sahlberg 29b4cea00f multithreading: make nfs_get_error() work for multithreaded applications
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>
2022-01-28 10:38:32 +10:00
Ronnie Sahlberg f85c21755e nfs4: Use RELEASE_LOCKOWNER when we close a file
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>
2022-01-05 16:41:34 +10:00
Ronnie Sahlberg 0550a5c83f nfs4 multithreading: create a new lock_owner for every single open()
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>
2022-01-05 16:18:11 +10:00
Ronnie Sahlberg 61e5863e46 nfsv4: fix multithreading for nfsv4
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>
2022-01-05 13:10:16 +10:00
Ronnie Sahlberg 1716b14104 Write PDUs straight to the wire when the queue is empty
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2022-01-05 13:10:00 +10:00
Ronnie Sahlberg 630a80c056 WIN32: add multithreading support for windows 2022-01-02 13:02:31 +10:00
Ronnie Sahlberg 1648cd8393 remove strndup call
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-12-31 11:53:33 +10:00
Ronnie Sahlberg efa9085cfa add support for nfsv3 getacl
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-12-31 11:42:48 +10:00
Ronnie Sahlberg c851f458a0 multithreading: fix race for waking blocked worker threads
We must make sure that we prepare and process all the returned data
before we wake the thread that is waiting for the i/o to complete
or else we will have a race between waking the thread and copying
the returned data in the service thread.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-12-31 08:28:20 +10:00
Ronnie Sahlberg 20b39fd251 PS2_EE: update to compile on latest ps2 sdk
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-10-15 18:14:18 +10:00
Ronnie Sahlberg 52c7bd7bc5 multithreading: return default error string when multithreading is
enabled

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-10-14 16:31:42 +10:00
Ronnie Sahlberg f55637619e initial pthread support
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-10-14 16:31:26 +10:00
Vitaliy Filippov d1999dc956 Don't try to ZDR_DECODE strings into a pre-existing pointer
Otherwise it segfaults inside any string decoding inside rpc_process_call()
as it doesn't zero the allocated memory, so libnfs_zdr_string() may receive
non-zero *strp which is very easy to reproduce by writing a simple NFS server
example using libnfs :-)
2021-10-11 00:55:14 +03:00
Ronnie Sahlberg f965ec74cf ps2ee: PS2 EE support
Initial support for building a library for PS2 EmotionEngine

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-09-17 07:27:44 +10:00
Ronnie Sahlberg f88cca547d nfsv4: fix inode in readdir and nulltermination of readlink
Reported-by: Hemambara Kurma <hemambara.kurma@rubrik.com>
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-09-08 10:27:57 +10:00
Ronnie Sahlberg fca28fe112 url: add support for using escaped characters in the url.
We need to allow users to specify escaped characters as part of the 'path'
field of a URL.
For example, '?' is used to separate the part and the optional list of
arguments.
IF 'path' contains a '?' character then that must be escaped as %3F.
So that libnfs will be able to tell it apart from the '?' separator.

I.e.
nfs://127.0.0.1/my?path/?version=4
must be escaped as
nfs://127.0.0.1/my%3Fpath/?version=4
before passed to any of the URL parsing functions.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-09-01 08:17:23 +10:00
Ronnie Sahlberg 820dc73e32 nfsv3: fix crash when performing very large reads
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-08-11 06:12:06 +10:00
Ronnie Sahlberg 965b1914ef Allow setting max read/write size from the api
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-08-10 16:29:42 +10:00
Ronnie Sahlberg 752cb4134d url: add support for server:port syntax in the url
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-07-18 07:46:09 +10:00
Ronnie Sahlberg cdb377532a acl: add support and helpers to read nfsv4 acls
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2021-07-17 20:11:56 +10:00
Damian c14a5acb51 Porting to PS3 2020-08-14 19:30:00 -03:00
Damian c7ad0762d8 Porting library to PS3 (psl1ght) 2020-08-14 11:47:39 -03:00
Adam Yi dfa85d4c36 Fix seekdir
The previous implementation doesn't actually update dir->current but
resets dir->current to dir->entries
2020-06-23 02:11:33 +10:00
Ronnie Sahlberg edce6654a3 fix return value for mount_getexports
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-06-05 06:58:42 +10:00
peak3d 74ac9b5e11 Implement mount_getexports_timeout 2020-06-04 16:42:48 +02:00
Ronnie Sahlberg 3fbec953e6 mount: add a 2 second timeout for getting the export list.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-06-03 19:02:36 +10:00
Ronnie Sahlberg f79745d281
Merge pull request #319 from dmeister/large_write
Allocate larger buffer for write operations in NFS4
2020-05-20 07:32:57 +10:00
Ronnie Sahlberg 4dd823b4a1
Merge pull request #318 from dmeister/chown
Fix NFS4 behavior of chmod/chown/utimes
2020-05-20 07:29:19 +10:00
Dirk Meister 483be177fe Allocate larger buffer for write operations in NFS4
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.
2020-05-18 20:57:06 -07:00
Dirk Meister 1336b5280e Fix NFS4 behavior of chmod/chown/utimes
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.
2020-05-18 20:50:01 -07:00
DetlefGolze b9c85afc4f
Update libnfs-zdr.c
libnfs_zdr_array() needs to determine element count before calculating size to allocate.
2020-05-06 10:51:39 +02:00
Ronnie Sahlberg 394b185486 Try to invoke the connect callback if we shutdown while connect is in progress
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-12-17 08:50:23 +10:00
Ronnie Sahlberg 548fa961a8 Return "" instead of NULL for empty errors in nfs_get_error()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-12-16 13:21:27 +10:00
Volker Lendecke 338837f6de Simplify range check in libnfs_zdr_array
Signed-off-by: Volker Lendecke <vl@samba.org>
2019-11-19 14:15:33 +10:00
Ronnie Sahlberg a7b9994971
Merge pull request #300 from crusader-mike/master
fix for find_package from downstream clients
2019-10-22 23:10:56 +10:00
crusader-mike 70801203e2 fixed cmake files to support package export 2019-10-11 13:12:02 -05:00
Ronnie Sahlberg ac60feabf0
Merge pull request #297 from crusader-mike/master
fixing cmake build on windows
2019-10-10 08:27:55 +10:00
crusader-mike 9d5427bbd4 fixed few MSVC warnings; fixed missing exports 2019-10-09 17:08:10 -05:00
Ronnie Sahlberg e4fa3b5bcb make LGTM.com happy and squash a false warning
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-27 20:48:58 -07:00
Ronnie Sahlberg c635cae6f6 remove obsolete FIXME comment
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2019-09-27 20:48:49 -07:00
crusader-mike 4da7bb4fec Windows: dll (built with cmake) will contain proper file version info 2019-09-13 12:46:19 -05:00
crusader-mike 6564abaa1f fixed CMake build on windows, few trivial fixes 2019-09-12 15:07:35 -05:00