Commit Graph

555 Commits (65de83140aa6264b75a8cb5eda9e0ba1b1f56b9b)

Author SHA1 Message Date
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 63d40b1737 Revert "Remove unused variable from socket.c"
This reverts commit d74a938775.
2015-03-12 20:52:52 -07:00
MilhouseVH d74a938775 Remove unused variable from socket.c 2015-03-12 05:29:56 +00: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 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
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
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
Ronnie Sahlberg c7190d3078 nested_mounts: collect fattr3 data for all nested mounts
During the mount process, once we have connected to NFSd we need to collect
the file attributes for all the filehandles that are associated with
nested mounts.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:24:17 -08:00
Ronnie Sahlberg 08ad1b80c0 nested_mounts: collect filehandles for all nested mounts during nfs_mount()
During the mount process, call MOUNT3 EXPORT and collect a list of all
exports on the server. For any export that is a nested mount to the current
directory we are trying to mount call out to MOUNT3 MNT and collect the
filehandle for those mounts.

Track all nested mounts and their filehandles in a list from the nfs_context.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:19:13 -08:00
Ronnie Sahlberg 7378a13fa6 nfs_mount: rename nfs_mount_10/9/8_cb to nfs_mount_11/10/9_cb
Rename these callback functions to make space for two new functions
nfs_mount_7/8_cb which we will be using to collect information about
nested mounts in a later patch.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:09:37 -08:00
Ronnie Sahlberg 63d893575c opendir_cb: use a fattr3 pointer instead of dereferencing every time
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-17 11:00:48 -08:00
Ronnie Sahlberg 7b46c2bc3e READDIR: Bake the file type into the mode we return
NFS reports type in a separate to mode, where mode only contains
the protection bits. This makes it inconvenient to use when porting programs
since under posix the type is supposed to be part of the mode bits (S_IFMT)

When unmarshalling the directory entries into a nfsdirent structure, bake
the S_IF* file type into where the S_IFMT bits would be.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-01-12 20:32:29 -08:00
Ronnie Sahlberg d18b335622 Merge branch 'master' of github.com:sahlberg/libnfs 2015-01-08 07:29:35 -08:00
Mike Cui ac76768170 set_tcp_sockopt should be static, otherwise it prevents linking with libiscsi
which has function of the same name, also not static.

Same fix needs to go in to libiscsi.
2015-01-05 09:25:27 -08:00
Ronnie Sahlberg 0c1a5c464c libnfs.c: add support for nfs_umask
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-09 14:00:15 -08:00
Ronnie Sahlberg b53cd4d76c libnfs.c: remove function nfs_get_current_offset
Remove this function (that no one uses) since this is what
lseek(SEEK_CUR, 0) does.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-09 13:41:28 -08:00
Ronnie Sahlberg 5f6442d1b2 libnfs.c: fix typo, it is readahead not readahaed
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-05 08:44:15 -08:00
Ronnie Sahlberg 080d231129 New version 1.9.6
- Add O_TRUNC support for nfs_create
 - Handle OOM during create
 - Return more stats fields as part of readdir since we get these for "free"
   when we use READDIRPLUS
 - Follow symlinks during path resolution
 - Add lchown, lstat and lutimes
 - Replace all [u_]quad types with [u]int types in our RPC layer
 - Solaris build fixes

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-11-25 06:47:55 -08:00
Ross Lagerwall 23b10e1f18 libnfs: Add access2()
Add nfs_access2(), like nfs_access() but it returns the individual
statuses of R_OK, W_OK and X_OK rather than a single success or failure
status.  This saves the latency and overhead of multiple lookups if an
application tries to determine the status of each of R_OK, W_OK and
X_OK.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-09-14 15:41:04 +01:00
Ross Lagerwall c50173cf0d libnfs: Give correct access() results for directories
Map ACCESS3_{MODIFY,EXTEND,DELETE} to W_OK and ACCESS3_{LOOKUP,EXECUTE}
to X_OK so that nfs_access() gives sensible results for directories.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-09-14 15:38:57 +01:00
Ronnie Sahlberg bce63d849c types: remove the [u_]quad type and replace with [u]int64
All current platforms have a quad type that maps to a 64bit scalar.
But there are platforms where quad maps to a 64bit non-scalar.

Replace quad with int64 in the protocol definitions and the ZDR layer
so that these fields will map to a 64 bit scalar also on those platforms
where quad can not be used.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-16 14:51:53 -07:00
Ronnie Sahlberg cc3e372de4 socket.c: we need netinet/in.h on some platforms 2014-08-14 18:56:39 -07:00
Ronnie Sahlberg a8c840e834 Merge pull request #97 from rosslagerwall/read-close-crash
libnfs: Don't perform operations on nfsfh after user callback
2014-08-11 06:15:16 -07:00
Mike Frysinger e48cfe9622 fix implicit decls of rpc_{g,s}et_error
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-08-11 06:08:33 -07:00
Mike Frysinger 8d4559dc14 fix typo in chmod funcs
These were accidentally calling chown instead of chmod.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2014-08-11 06:08:33 -07:00
Mike Frysinger 10a1a78115 fix implicit decl warnings
Include the proper headers to fix warnings like:
libnfs-sync.c:1529:3: warning: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
libnfs-zdr.c:506:2: warning: implicit declaration of function 'getuid' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

sys/time.h needs to be protected with an ifdef

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-08-11 06:08:05 -07:00
Ross Lagerwall 9cac8a6340 libnfs: Don't perform operations on nfsfh after user callback
Since the user callback may perform operations on the nfsfh (e.g. it
might close it), all updates should be done before the user callback is
called.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-08-10 12:18:56 +01:00
Ross Lagerwall 408cd870b8 libnfs: Fix segfault if O_TRUNC fails when creating
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-08-07 20:45:42 +01:00
Ross Lagerwall 8d59066720 libnfs: Add lchmod
Add lchmod which is like chmod but operates on the symbolic link itself
if the destination is a symbolic link.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:26:54 +01:00
Ross Lagerwall 6505b53967 libnfs: Add lutimes
Add lutimes which is like utimes but operates on the symbolic link
itself if the destination is a symbolic link.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:26:54 +01:00
Ross Lagerwall bf769f960d libnfs: Add lstat
Add lstat which is like stat but operates on the symbolic link itself if
the destination is a symbolic link.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:26:54 +01:00
Ross Lagerwall 5935a28a0e libnfs: Add lchown
Add lchown which is like chown but operates on the symbolic link itself
if the destination is a symbolic link.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:26:54 +01:00
Ross Lagerwall 1d15199152 libnfs.c: Follow symlinks during path resolution
Follow symlinks during path resolution.  If the symlink points outside
the mount, -ENOENT is returned.  This is slightly different behavior
from the in-kernel NFS client where symlinks pointing outside the mount
get resolved to local paths.

The algorithm for symlink resolution is simple and stupid.  If a symlink
is encountered, the path is rewritten and path resolution begins again
from the root filehandle.  A count is kept to prevent loops.  This is
not particularly efficient but it is good enough for now.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:24:17 +01:00
Ross Lagerwall c4d5f5b874 libnfs.c: Fix a warning
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-27 21:22:34 +01:00
Ronnie Sahlberg 42f916635d Merge pull request #90 from rosslagerwall/stat-improvements
Stat improvements
2014-07-23 17:30:13 -07:00
Ross Lagerwall 3e020c15fd libnfs: Add fstat64, analagous to stat64
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-20 23:13:16 +01:00
Ross Lagerwall fc08ac459c libnfs: Set as much stat information as possible
Set as much stat information as possible for stat, stat64, fstat and
readdir.

Fill in dev to the given fsid.
Fill in rdev to the given major and minor numbers.
Set the file type bits in the mode from the type returned by the server.
Set the number of blocks used based on the number of bytes used in
blocks of size 512 (which is what stat(2) uses), rounded up.
Fill in the nanosecond timestamps.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-20 22:06:34 +01:00
Ross Lagerwall ece11036ff libnfs.c: Handle OOM condition
Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-20 08:13:45 +01:00
Ross Lagerwall 370c59e351 libnfs.c: Support use of O_TRUNC with nfs_create
Simplify usage for application programmers by supporting the use of
O_TRUNC with nfs_create.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-20 08:08:39 +01:00
Ronnie Sahlberg 8dea7c3e2d Merge pull request #88 from rosslagerwall/76-no-autoreconnect
libnfs.c: Fix autoreconnect
2014-07-19 16:01:13 -07:00
Ronnie Sahlberg fda800dc02 Merge pull request #86 from rosslagerwall/75-create
libnfs.c: add nfs_create
2014-07-19 15:58:30 -07:00
Ronnie Sahlberg e591967437 Merge pull request #87 from rbalint/master
Use sockaddr_in6 on FreeBSD
2014-07-19 15:56:59 -07:00
Ronnie Sahlberg b9e5039f49 New version 1.9.5
This version removes old ONC-RPC symbols and automatically includes the
RPC/ZDR layer include from the raw low level headers.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-07-19 15:47:35 -07:00
Petr Salinger 18c94b4633 Use sockaddr_in6 instead of sockaddr6_in 2014-07-19 18:07:13 +02:00
Ross Lagerwall 28ee9de2e4 libnfs.c: Fix autoreconnect
Since rpc_connect_async sets autoreconnect to 0, turn autoreconnect on
after the connection has completed, not before.

This fixes #76.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2014-07-19 11:35:23 +01:00
Ross Lagerwall 037a1061dd libnfs.c: add nfs_create
Add a new family of functions, nfs_create, like nfs_creat but takes an
additional flags argument which allows extra flags like O_SYNC, O_EXCL
and O_APPEND to be specified.
2014-07-17 22:32:09 +01:00
Ronnie Sahlberg 3c769bb1bd New version 1.9.4
New version of libnfs:

- IPv6 support
- Support for Portmapper version 3 and an example portmap client.
- Directory caching top make repeated opendir() calls faster
- Readahead support
- Build manpages for the utilities (==nfs-ls)
- Support for O_APPEND
- Rename the list macros to avoid collission on *BSD

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-29 14:57:45 -07:00
Ronnie Sahlberg 07d06b250c libnfs.c: Change the directory cache to a smaller more reasonable value
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-29 14:42:28 -07:00
Ronnie Sahlberg be243cfa9b Merge pull request #82 from plieven/readahead
add readahead support
2014-06-29 14:41:28 -07:00
Peter Lieven 3ca2aac9a4 add readahead support
This patch add support for an internal readahead machanism. The maximum readahead
size can be specified via URL parameter readahead. This should significantly
speed up small sequential reads.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-23 16:31:32 +02:00
Ronnie Sahlberg 390ff38ad1 libnfs.c: add nlink to nfsdirent so we can get it for 'free'
update the nfs-ls utility to just use nfsdirent as is instead of having to
stat the files.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-08 11:40:35 -07:00
Ronnie Sahlberg 56e96539ef libnfs.c: add a simple dircache to libnfs
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-08 11:24:18 -07:00
Ronnie Sahlberg 20379f03fc libnfs.c: always pass the attributes to the callback for recursive lookups
Always pass a fattr3 structure to the callbacks for the internal function
to perform recursive lookups : nfs_lookuppath_async().
This will allow us to access for example the mtime for an object before we
start performing any expensive functions.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-08 11:24:09 -07:00
Ronnie Sahlberg f0888d12d9 init.c: fixup the mangled lgplv2.1 boilerplate
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-08 07:34:54 -07:00
Ronnie Sahlberg 1a6ec3ee76 init.c: use list macro when removing pdus from the wait list
Use the macro when removing the pdus in the wait list from the queues.
Also make sure to remove them from the right queue, from waitqueue and not
the outqueue for PDUs we have already sent out.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-06-08 07:21:43 -07:00
Peter Lieven 7a750aea1c socket: fix broken connect for non broadcast traffic
commit 1c1e09a completely broke connects for non broadcast
traffic since it forgot to copy the server address into
the socket_storage struct.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-06-08 14:20:12 +02:00
Ronnie Sahlberg 8a52596b74 slist.h: Change SLIST_* to LIBNFS_LIST_* to avoid name clash on *BSD
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-05-14 19:11:03 -07:00
Ronnie Sahlberg 548e2bea4b nfs_open: add support for O_APPEND 2014-04-18 09:32:01 -07:00
Ronnie Sahlberg a87bb233a8 Merge branch 'xid-hash' 2014-04-10 19:59:28 -07:00
Ronnie Sahlberg 0275da678b Merge pull request #71 from Memphiz/nolinger
[socket] - disable linger by setting SO_LINGER to 0 seconds
2014-04-10 18:21:13 -07:00
Memphiz bd2f43c8a6 [osx] - fix compile 2014-04-10 20:35:44 +02:00
Memphiz 74b037ec46 [socket] - disable linger by setting SO_LINGER to 0 seconds 2014-04-10 20:34:11 +02:00
Arne Redlich 567a94d937 Fix the file position handling of the read and write calls
Since the interface is modelled after the libc calls we should try to match
their behaviour to avoid unpleasant surprises:
* read / write (sync and async flavours) update the file position
* pread / pwrite (sync and async flavours) do not update the file position
.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-04-03 18:05:32 -07:00
Arne Redlich 9e6ac3d4ee libnfs-sync: nfs_{read,write}: use their _async counterparts internally
Previously nfs_read and nfs_write used to use nfs_pread and nfs_pwrite respectively.
In preparation of getting the file position handling right this has to be detangled.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-04-03 18:04:41 -07:00
Arne Redlich 1f1b6cb0a7 nfs_lseek{,_async}: allow negative offsets and guard against file positions < 0
Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-04-03 18:03:21 -07:00
Mark Hills 63f36a0923 Track waiting requests in a hash table, by xid
NFS servers can respond to requests in any order, and they do. In our
tests there is also some clustering to the responses; it could be
because eg. requests are served synchronously if the data is in the cache.

Introduce a hash table so that we are able to find the pdu quickly in
all cases, assuming random distribution of the responses.
2014-04-03 17:52:21 -07:00
Mark Hills d46c3d622b Ensure the next pointer is correct
Fixes a bug where the next pointer was not being explicitly set. We
were ok much of the time due to zero-filled memory, and also we need
this if the same pdu is re-queued.
2014-04-03 17:51:56 -07:00
Mark Hills aec45c6274 Optimisations to the pdu queues
When making many concurrent requests (as is likely in any performance
criticial application), the use of SLIST_REMOVE and SLIST_ADD_END are
a severe bottleneck because of their linear search.

I considered using a double-linked list but it was unnecessary to
allocate the additional memory for each list entry.

Instead, continue to use a single-linked list but retain:

* a pointer to the end of the list; and
* a pointer to the previous entry during a linear search.

The former would makes append operations O(1) time, and the latter
does the same for removal. We can do this because removal only happens
within the linear search, and there is no random access to the queue.
2014-04-03 17:51:04 -07:00
Arne Redlich d5f7880641 nfs_normalize_path: don't strip trailing slash from "/"
Otherwise end up with a null string which is not permitted (RFC 1813, 3.2;
the code checks for it right after the now fixed nullification of "/").

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-03-20 16:58:32 -07:00
Arne Redlich b644665077 nfs_opendir2_cb: plug potential memory leak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-03-20 16:52:53 -07:00
Ronnie Sahlberg 24f45c5452 PORTMAP: Rename pmap3_getaddr_result to pmap3_string_result 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 29258a73c0 PORTMAP: Add support for v3 TADDR2UADDR 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 729266a796 PORTMAP: Add PMAP v3 UADDR2TADDR support 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg b71f7e8291 PORTMAP: Add support for PORTMAP v3 CALLIT 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 5245608a65 PORTMAP: Add v3 GETTIME support 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 6c60e2822f IPv6: If we use IPv6 then we need to use PMAP v3 GETADDR 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 7fbedfdefd PORTMAP: Add support for PORTMAP v3 GETADDR 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 2a32a899ca GETEXPORT: Use rpc_connect_program_async() flow during list exports
and get rid of several now redundant callbacks.
2014-03-19 18:25:50 -07:00
Ronnie Sahlberg f694a287ae RPC_CONNECT: Use the rpc_connect_program_async() flow during nfs_mount() 2014-03-19 18:25:50 -07:00
Ronnie Sahlberg 0f0e352f49 PORTMAP: Rename the functions in PMAP to PMAP2 to desribe the version of PMAP we use.
Future patches will add PMAP3 which we will need for IPv6 support.
2014-03-19 18:25:49 -07:00
Ronnie Sahlberg 1c1e09ad51 IPV6: Add basic IPv6 support
This adds basic IPv6 support to libnfs.
Since libnfs currently only support PORTMAPPER protocol up to version 2
the IPv6 support only works if the server runs Both MOUNT and NFS protocols
on the same ports for IPv6 as for IPv4.

To get full IPv6 support we need to add support for PORTMAPPER version 3
and use it for discovery when using IPv6
2014-03-19 18:25:49 -07:00
Ronnie Sahlberg 7058971155 New version: 1.9.3
Wed Mar 19 2014: Version 1.9.3
 - Add O_TRUNC support to nfs_open()
 - Add a simple but incomplete LD_PRELOAD tool
 - Fixes for some memory leaks and C++ compile support
 - Make ANDROID default uid/gid to 65534
 - Allow the READDIRPLUS emulation to still work if some objects
   in the direcotry can not be lookedup (NFSv4 ACL denying READ-ATTRIBUTES)
 - Have libnfs retry any read/write operations where the server responds
   with a short read/write. Some servers do this when they are overloaded?
2014-03-19 18:12:45 -07:00
Ronnie Sahlberg c44c3ff364 Merge pull request #69 from plieven/for-1.9.3
nfs_{pread,pwrite}_async: fix oom handling and comments
2014-03-18 12:30:40 -07:00
Peter Lieven 40a4373ab8 nfs_{pread,pwrite}_async: fix oom handling and comments
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-18 20:08:33 +01:00
Ronnie Sahlberg 8ae943f608 PORTMAP: Add support for V3 DUMP command
This implements the missing procedure from Issue #65
2014-03-16 14:17:06 -07:00
Peter Lieven ae8168b3eb {pread,pwrite}_async: fix potential segfault in out of memory condition
if there are already requests in flight we cannot return with an error immediately
from the functions since the caller will likely tidy up his data structures directly
and later on we call his callback with private_data that has likely already
been freed.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:16:07 +01:00
Peter Lieven 1eb4be3150 nfs_pread_async: handle short reads
the RFC allows the server to read less bytes than requested even
if not at the EOF.
this patch implements a reissue logic for the reminder of the
read request(s).

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:15:48 +01:00
Peter Lieven 027a767eca nfs_pwrite_async: handle short writes
the RFC allows the server to write less bytes than requested.
this patch implements a reissue logic for the reminder of the
write request(s).

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:07:59 +01:00
Peter Lieven d485997ad3 fix possible wrong cast to 32-bit unsigned
when calculation the max_offset the (unsigned) leads to a cast
to a 32-bit unsigned integer depending on the platform. as a result
we update the max_offset everytime when it grows beyond 2^32.
this leads to a wrong return max_offset value if the callbacks
are received out of order.

Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:07:52 +01:00
Peter Lieven 2449d3f787 introduce nfs_fill_{READ,WRITE}3args
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:07:44 +01:00
Peter Lieven 4d2f9f1132 fix potential overflow in nfs_pread_mcb
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-03-16 20:07:39 +01:00
Ronnie Sahlberg 9a9566a3ee Improve error messages when READDIRPLUS emulation fails.
This addresses issue #62
2014-03-13 06:30:31 -07:00
Ronnie Sahlberg f66ff9931d Dont check for NFS errors in the LOOKUP during READDIRPLUS emulation
On servers with extended attributes, a server copuld be set up to
deny READ-ATTRIBUTES for the libnfs user.
This means that READDIRPLUS will no longer work since it will need to
stat() and thus READ-ATTRIBUTE in order to prepare the response.

Libnfs has READDIRPLUS emulation for the cases where this command fails
by switching to old READDIR to scan all the file names and then a LOOKUP loop for getting the file attributes.

Most of the time the purpose for this emulation is to handle the case where the server simply does not support READDIRPLUS at all, which sometimes is the case for embedded systems with userspace nfs servers.
In this case, where files just have READ-ATTRIBUTE deny for the libnfs user,
this will also fail and trigger the fallback to READDIR + LOOKUP-loop.

If the LOOKUP fails for this loop, then just ignore trying to update the attributes we have for this object, but do not fail the actual READDIRPLUS emulation.

This addresses a permissions issue reported by a XBMC user in issue #60
2014-03-12 21:00:08 -07:00
Ronnie Sahlberg 3af0c02237 Set default uid/gid to 65534/nobody for ANDROID 2014-03-12 19:31:20 -07:00
Ronnie Sahlberg b25c3aedde We only need to spend CPU computing a new error string IFF there was an error
when unmarshalling the reply.
2014-03-12 05:54:38 -07:00
Ronnie Sahlberg f0cb804219 Improve error reporting when unmarshalling of message headers fail. 2014-03-11 18:52:48 -07:00
Ronnie Sahlberg 479302f729 Add a new nfs_stat64() function that operates on a always-64-bit stat structure 2014-03-04 19:40:05 -08:00
Arne Redlich c8f0bac1bb nfs_pread_async: plug potential memleaks
Spotted by clang analyzer.

This also introduces asserts to help clang analyzer avoid reporting
false positives.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 19:00:47 -08:00
Arne Redlich 63d4a0583d nfs_write_async: plug potential memory leaks
Spotted by clang analyzer.

This also introduces asserts to help clang analyzer avoid
reporting false positives.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 19:00:19 -08:00
Arne Redlich 60af7e19d1 rpc_read_from_socket: fix use-after-free due to missing return
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:59:44 -08:00
Arne Redlich 8907aea9eb socket.c: fix format string issues (too few arguments)
These were uncovered by the previously added __attribute__((format(printf))).

Emacs also removed trailing whitespace while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:59:17 -08:00
Arne Redlich 766bb4af75 nfs_rename_continue_1_internal: fix use-after-free
Spotted by clang analyzer.
This introduces another allocation to create a copy of the target path
of a rename in case it needs to be reported via rpc_set_error - it might
be a better idea to avoid the allocation and have a slightly less informative
error message?

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:58:02 -08:00
Arne Redlich bcbb21cdbb nfs_unlink_async: plug potential memory leak
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:57:28 -08:00
Arne Redlich 2257433dd4 nfs_rmdir_async: fix potential memory leak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:55:42 -08:00
Arne Redlich b1a197f5b2 nfs_mkdir_async: fix potential memory leak
Pointed out by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:55:22 -08:00
Arne Redlich ecc656491a nfs_mknod_async: fix use-after-free
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:54:58 -08:00
Arne Redlich b41762c0d8 nfs_fchown_async: fix use-after-free
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:54:37 -08:00
Arne Redlich faa15589f1 nfs_fchmod_async: fix use-after-free
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:53:22 -08:00
Arne Redlich a26bebefce nfs_opendir2_cb: plug potential memleaks
Spotted by clang analyzer

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:52:34 -08:00
Arne Redlich 2fa14f9b97 free_nfs_cb_data: make static and drop superfluous nullptr checks / assignments
free() can cope with nullptrs and there's no point in null-ing free'd members
as the containing struct is free'd as well.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:52:05 -08:00
Arne Redlich 206a2ff644 free_nfs_cb_data: add assert(data->free_continue_data)
Non-debug builds will trip over the nullptr too - do we rather
want to leak the memory there?

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:50:09 -08:00
Arne Redlich 6b1f14ca01 nfs_fchown_async: fix nullptr dereference
nfs_chown_data is hooked up under nfs_cb_data->continue_data but
no ->free_continue_data is configured, so once free_nfs_cb_data is
invoked it will trip over a nullptr.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:49:03 -08:00
Arne Redlich b6619d88e6 nfs_fchown_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:50 -08:00
Arne Redlich a128749648 nfs_creat_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:27 -08:00
Arne Redlich feb2fc2f92 nfs_mknod_async: plug potential memory leak
Pointed out by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:47:02 -08:00
Arne Redlich e59193c9f9 nfs_lookuppath_async: plug potential memleak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:46:09 -08:00
Arne Redlich b2fc5c54d9 nfs_opendir_cb: plug potential memory leak
Spotted by clang analyzer.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:45:33 -08:00
Arne Redlich 4b1ae88abb nfs_normalize_path: fix using the results of assignments in while loops
Spotted by clang:
 ../../libnfs.git/lib/libnfs.c:1002:13: warning: using the result of an assignment as a condition without parentheses
       [-Wparentheses]
         while (str = strstr(path, "//")) {
                ~~~~^~~~~~~~~~~~~~~~~~~~
 ../../libnfs.git/lib/libnfs.c:1002:13: note: place parentheses around the assignment to silence this warning
         while (str = strstr(path, "//")) {
                    ^
                (                       )
 ../../libnfs.git/lib/libnfs.c:1002:13: note: use '==' to turn this assignment into an equality comparison
         while (str = strstr(path, "//")) {
                    ^
                    ==

Make the intent clear by adding extra parentheses, and also
remove trailing whitespace from libnfs.c while at it.

Signed-off-by: Arne Redlich <arne.redlich@googlemail.com>
2014-02-19 18:41:34 -08:00
Ronnie Sahlberg be7b4360ac We need to pass a filehandle back for open(O_TRUNC) or else the app will
be unhappy
2014-02-02 17:39:04 -08:00
Ronnie Sahlberg 22a0f15bee Add support for O_TRUNC with nfs_open()
O_TRUNC will attempt to truncate the file when opened with O_RDWR
or O_WRONLY.

Normal posix open(O_RDONLY|O_TRUNC) is undefined.

libnfs nfs_open() only uses the O_TRUNC flag when used in combination with either O_RDWR or O_WRONLY.
When O_TRUNC is used together with O_RDONLY libnfs will silently ignore the O_TRUNC flag.

Libnfs nfs_open(O_RDONLY|O_TRUNC) is thus the same as nfs_open(O_RDONLY)
2014-02-02 12:16:07 -08:00
Ronnie Sahlberg 3cea44dc54 Rename the nfs_open() argument from mode to flags 2014-02-02 11:41:22 -08:00
Ronnie Sahlberg 6ec481d3fa Add a rpc_set_fd() fucntion which can be used to swap the underlying socket file descriptor
This is mainly needed when having to track and control the file descriptors that are used by libnfs, for example when trying to emulate dup2() ontop
of libnfs.
2014-02-02 08:45:21 -08:00
Ronnie Sahlberg 34edf264dc Empty paths are no longer an error. Translate it to '.' instead. 2014-02-01 08:03:12 -08:00
Ronnie Sahlberg f893b680f2 Add support for chdir and getcwd
Add chdir and getcwd and store cwd in the nfs_context.
Add functions to process the paths specified and normalize them
by performing the transforms :
    // -> /
    /./ -> /
    ^/../ -> error
    ^[^/] -> error
    /string/../ -> /
    /$ -> \0
    /.$ -> \0
    ^/..$ -> error
    /string/..$ -> /

Update the path lookup function to allow specifying relative paths based on
cwd for all functions.
2014-01-30 20:06:57 -08:00
Ronnie Sahlberg 0a63cc7258 Remove chdir changes for now. Needs more testing. 2014-01-30 18:30:25 -08:00
Ronnie Sahlberg 0df47959c4 Revert "Add support for chdir and getcwd"
This reverts commit fb6f315257.
2014-01-30 18:26:39 -08:00
Ronnie Sahlberg 1d95217b2f New version 1.9.1
Add back the libnfs-raw-*.h headers to make install
2014-01-28 06:41:31 -08:00
Ronnie Sahlberg fb6f315257 Add support for chdir and getcwd
Add chdir and getcwd and store cwd in the nfs_context.
Add functions to process the paths specified and normalize them
by performing the transforms :
    // -> /
    /./ -> /
    ^/../ -> error
    ^[^/] -> error
    /string/../ -> /
    /$ -> \0
    /.$ -> \0
    ^/..$ -> error
    /string/..$ -> /

Update the path lookup function to allow specifying relative paths based on
cwd for all functions.
2014-01-27 20:54:59 -08:00
Ronnie Sahlberg 5392b1cfbc New version : 1.9.0
- Use _stat64 on windows so file sizes become 64bit always.
 - Increase default marshalling buffer so we can marshall large PDUs.
 - RPC layer support for NFSv2
 - Win32 updates and fixes
 - Add URL parsing functions and URL argument support.
 - New utility: nfs-io
 - nfs-ls enhancements
 - RPC layer support for NSM
 - Add example FUSE filesystem.
 - Minor fixes.
2014-01-27 20:47:24 -08:00
Ronnie Sahlberg ecbd14a153 Make sure cookie is initialized before we use it. 2014-01-13 06:36:38 -08:00
Ronnie Sahlberg 9180287b27 Export the three new nfs_set_* functions from the windows library/dll 2014-01-13 06:30:43 -08:00
Peter Lieven d43a8953f5 make adjustments for v6 of the qemu NFS driver
Signed-off-by: Peter Lieven <pl@kamp.de>
2014-01-13 11:22:21 +01:00
Ronnie Sahlberg c9cc77a538 Merge pull request #47 from Memphiz/win32fix3
[win32] - fixed bad number casting when using libnfs on 64bit win8 syste...
2014-01-12 15:18:59 -08:00
Memphiz be184101ca [win32] - fixed bad number casting when using libnfs on 64bit win8 systems - force the usage of struct __stat64 as its done on other platforms implicitly 2014-01-12 14:42:56 +01:00
Maxim Koltsov 5581436f5f Adjust Makefile.am's to support out-of-source builds 2014-01-08 12:36:09 +04:00
Ronnie Sahlberg 7bda8bad00 Add uid/gid to the stat data returned in the readdir directoryentry
We also get uid/gid for free when using READDIRPLU3 (and READDIRPLUS3 emulation)
so store these too so applications that needs to look at the uid/gid can avoid
the extra call to nfs_stat()
2013-12-31 16:25:01 -08:00
Ronnie Sahlberg 2452c57f9b Assign the whole nfs_fh3 structure instead of element by element when possible 2013-12-31 16:11:11 -08:00
Ronnie Sahlberg 1a5b83c98c Change rpc_nfs_readdirplus to rpc_nfs3_readdirplus 2013-12-31 15:58:59 -08:00
Ronnie Sahlberg a64a16a2e9 Change rpc_nfs_readdir to rpc_nfs3_readir 2013-12-31 15:53:40 -08:00
Ronnie Sahlberg 7cd23ccc67 Change rpc_nfs_readlink to rpc_nfs3_readlink 2013-12-31 15:46:32 -08:00
Ronnie Sahlberg 87f81c853a Change rpc_nfs_symlink to rpc_nfs3_symlink 2013-12-31 15:44:15 -08:00
Ronnie Sahlberg 560f94344d Chane rpc_nfs_link to rpc_nfs3_link 2013-12-31 15:43:00 -08:00
Ronnie Sahlberg 5940c705a6 Change rpc_nfs_rename to rpc_nfs3_rename 2013-12-31 15:37:40 -08:00
Ronnie Sahlberg b17cb0a255 Change rpc_nfs_mknod to rpc_nfs3_mknod 2013-12-31 15:33:36 -08:00
Ronnie Sahlberg a0a5aa26f1 Change rpc_nfs_remove to rpc_nfs3_remove 2013-12-31 15:23:44 -08:00
Ronnie Sahlberg 789c3f1205 Change rpc_nfs_create to rpc_nfs3_create 2013-12-31 15:21:20 -08:00
Ronnie Sahlberg bf817ee694 Change rpc_nfs_rmdir to rpc_nfs3_rmdir 2013-12-31 15:20:28 -08:00
Ronnie Sahlberg acabd6bf14 Change rpc_nfs_mkdir to rpc_nfs3_mkdir 2013-12-31 15:17:16 -08:00
Ronnie Sahlberg 1a5636ffa7 Change rpc_nfs_commit to rpc_nfs3_commit 2013-12-31 15:16:02 -08:00
Ronnie Sahlberg b701254d40 Change rpc_nfs_setattr to rpc_nfs3_setattr 2013-12-31 15:12:32 -08:00
Ronnie Sahlberg 0249c17be0 Change all calls to rpc_nfs_fsstat to rpc_nfs3_fsstat 2013-12-31 15:08:11 -08:00
Ronnie Sahlberg c4ba61c51c Change all calls to rpc_nfs_fsinfo to rpc_nfs3_fsinfo 2013-12-31 15:06:25 -08:00
Ronnie Sahlberg 8aab33e33c Merge pull request #44 from plieven/master
fix 3 flaws detected by valgrind and bump version to intermediate version
2013-12-26 11:00:04 -08:00
Ronnie Sahlberg 3f30ac7800 Create SOCURRENT/SOREVISION/SOAGE in lib/Makefile.am 2013-12-26 10:52:43 -08:00
Ronnie Sahlberg dc3ed8c3ab Fix some compiler warnings and bugs
Add missing %s to two example programs and fix incorrect argument to
rpc_nfs3_fsinfo_async()
2013-12-26 10:40:37 -08:00
Ronnie Sahlberg eda77ec3f3 Change rpc_mount_* to rpc_mount3_* and make it explicit which version of
the protocol we are using.
2013-12-26 09:11:05 -08:00
Ronnie Sahlberg 20d6926ed6 Change rpc_set_context_args to nfs_set_context_args and make it static
It only makes sense to pass url arguments to an nfs URL and thus a nfs context.
While some arguments may apply to the underlying raw rpc context (uid, gid,
tcp settings etc) some future arguments may need to apply to the nfs context
instead, such as selecting nfs version, whether or not to force sync writes
etc.
2013-12-26 09:08:26 -08:00
Peter Lieven b70567b62c nfs_parse_url: initialize memory
the urls struct was accidently left unitialized.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-26 12:48:21 +01:00
Peter Lieven 1f1b1c5c93 nfs_parse_url_incomplete: fix use after free in param parsing
if no server is specified flagsp points into urls->server.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-26 10:43:15 +01:00
Ronnie Sahlberg 36f488dc7a Create a new function rpc_set_context_args where we parse and set the context
arguments.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-12-25 16:57:52 -08:00
Ronnie Sahlberg b2a4b99ee9 Add the url parsing functions to libnfs-win32.def 2013-12-25 16:29:00 -08:00
Ronnie Sahlberg 6d89ace041 Merge pull request #43 from plieven/master
URL parsing functions and minor fixes + enhancements
2013-12-25 16:11:29 -08:00
Ronnie Sahlberg 35280fd7a4 Grow the marshalling buffer from 64k to 1M so we can marshall really large WRITE3s 2013-12-24 13:03:50 -08:00
Ronnie Sahlberg 04e9034165 MOUNT: Add RPC support for MOUNTv1 2013-12-24 12:20:41 -08:00
Ronnie Sahlberg f38aacf8c9 Add NFSv2 RPC support 2013-12-24 11:28:56 -08:00
Ronnie Sahlberg 463d59bf8e NFS: Add new function signatures for rpc_nfs3_ that takes *3args arguments
to match the XDR.

Leave the existing ad-hoc rpc_nfs_* functions for backward compatibility.
2013-12-24 11:16:21 -08:00
Ronnie Sahlberg 21668dcef4 Add missing symbols to libnfs-win32.def and make them EXTERN 2013-12-24 08:54:28 -08:00
Peter Lieven 6bdcd5b676 examples: add nfs-io example
this simple example tool allows to
- creat and unlink files
- mkdir and rmdir directories
- stat

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 14:50:09 +01:00
Peter Lieven 9126c9c036 add uid and gid URL param to specify alternate uid and/or gid
This allows to connect with an alternate uid or gid than that
of the current user.

Example:
 examples/nfs-ls nfs://10.0.0.1/export?uid=1000&gid=33

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 14:03:26 +01:00
Peter Lieven 1c8b4547ce add tcp-syncnt URL param to adjust TCP_SYNCNT sockopt
This allows indirect support for a configurable connect timeout.

Linux uses a exponential backoff for SYN retries starting
with 1 second.

This means for a value n for TCP_SYNCNT, the connect will
effectively timeout after 2^(n+1)-1 seconds.

Example:
 examples/nfs-ls nfs://10.0.0.1/export?tcp-syncnt=1

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 14:03:18 +01:00
Peter Lieven d2ec73c75a add URL parsing functions
this adds the following 4 functions. see libnfs.h for details.

struct nfs_url *nfs_parse_url_full(struct nfs_context *nfs, char *url);
struct nfs_url *nfs_parse_url_dir(struct nfs_context *nfs, char *url);
struct nfs_url *nfs_parse_url_incomplete(struct nfs_context *nfs, char *url);
void nfs_destroy_url(struct nfs_url *url);

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 14:03:00 +01:00
Peter Lieven 1f3f0d5853 libnfs_zdr_opaque: make valgrind happy
valgrind complains about unitialized memory

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-23 12:46:31 +01:00
Peter Lieven fadbf8cf56 nfs_creat1_cb: fix memleak
data is not freed in case of a failure.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-17 11:50:00 +01:00
Peter Lieven b554c8e8d2 libnfs_authunix_create: make valgrind happy
valgrind complains about uninitialized memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
2013-12-17 11:47:59 +01:00
Ronnie Sahlberg ed09b5676f Initial support for NSM 2013-11-05 17:37:16 -08:00
Ronnie Sahlberg 558aefc736 New version 1.8
Fix nasty memory leak
2013-10-30 18:17:49 -07:00
Ronnie Sahlberg 751770fd43 Dont leak every single buffer we read from the socket. 2013-10-30 18:15:03 -07:00
Ronnie Sahlberg 8733f38d23 Add an async helper function to connect an rpc context to a program/version 2013-10-26 13:16:09 -07:00
Ronnie Sahlberg 3b943d2f68 Add a mechanism to control what the next XID value on a session will be.
This makes it possible for multiple processes/contexts to use the same
target and (with some synchronization) avoid XID collissions across processes/contexts.
2013-10-26 07:44:29 -07:00
Ronnie Sahlberg 6fda9871a0 Mix in the pid in the top 16 bits for the initial xid.
This helps for users which rapidly fork a lot of processes that then
immediately create a new context (I am looking at you dbench)
to awoid having lots of processes starting and using overlapping xid values.
2013-10-25 16:16:43 -07:00
Ronnie Sahlberg e7f3a78172 Don't clamp write3 max to 32k
We use our own XDR and RPC layer nowadays and do not have
any external dependencies to XDR or RPC.

As such we no longer need to clamp the write size to max 32kb
since we never link to the system rpc/xdr libraries.
(and thus dont have to clamp in case the system library is broken for
pdu's > 32k)

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-10-23 19:18:41 -07:00
Volker Lendecke cd67ec7d6b Fix typos 2013-10-23 19:13:00 -07:00
Ronnie Sahlberg b93082da2b Make xid be a uint32_t and not either unsigned long or unsigned int 2013-10-21 19:15:11 -07:00
Ronnie Sahlberg 31820d2727 New version 1.7
- Allow nested eventloops so that a sync function can be called from a callback.
 - Fix a bug in unmarshalling a uint64.
 - Add PATHCONF support.
 - WIN32/64 updates
 - AROS updates
2013-10-20 16:31:32 -07:00
Ronnie Sahlberg dd97d43aad Reset the receive buffer processing the received PDU.
This allows us to have recursive eventloops and do synchronous
rpc calls from a callback.
2013-10-20 13:16:45 -07:00
Ronnie Sahlberg c81e7d8921 Make sure the the value is unsigned before we OR it into the uint64_t
or else the sign might be extended.
2013-10-20 12:41:56 -07:00
Ronnie Sahlberg 7e66b28947 Merge branch 'master' of github.com:sahlberg/libnfs 2013-05-30 17:59:24 -07:00
Ronnie Sahlberg 4e019b25b5 On Windows, use 65534/65534 instead of 65535/65535 for the default uid/gid 2013-05-30 17:58:29 -07:00
Memphiz 292e2d9097 [win32] - add projects for examples to the solution and make them compile (all compile but nfsclient-bcast) 2013-05-29 18:41:31 +02:00
Ronnie Sahlberg c5e346e15c More AROS fixes. AROS compiles and works again. 2013-05-28 22:49:19 -07:00
Ronnie Sahlberg 0556ee05e1 Aros fixes 2013-05-28 22:41:54 -07:00
Ronnie Sahlberg 265276038a AROS fixes 2013-05-28 22:13:08 -07:00
Ronnie Sahlberg c022471e52 Add configure test for arpa/inet.h 2013-05-28 21:25:08 -07:00
Ronnie Sahlberg 833d5b9da1 Include ifdef cleanup 2013-05-28 21:20:00 -07:00
Ronnie Sahlberg bff8fe460d Some more configure checks for headers 2013-05-28 17:54:12 -07:00
Ronnie Sahlberg 7057e733c1 Add configure checks for sys/socket.h 2013-05-28 17:43:47 -07:00
Ronnie Sahlberg 728970051c Add configure checks for whether netinet/in.h is available or not 2013-05-28 17:38:37 -07:00
Ronnie Sahlberg cb5b8be2eb Try making the initial port used a little more random 2013-05-28 17:22:28 -07:00
Ronnie Sahlberg 67a9f57e67 WIN32 fixes 2013-05-28 16:15:16 -07:00
Ronnie Sahlberg a60caa0945 New version 1.6
Add AROS/Amiga support
Chose initial XID value better to reduce probability for collissions
Fix bug in the initial default credentials and use getgid() instead of -1
2013-05-27 21:35:26 -07:00
Ronnie Sahlberg 43e0e7a7e6 On unix systems, when creating the default authentication token
use getgid() as the group instead of -1.
Recent linux knfsd do not allow grp==-1

On windows there are no uid/gids in the traditional sense so there I still specify a default credential of uid==gid==-1 :
	rpc->auth = authunix_create("LibNFS", 65535, 65535, 0, NULL);

This is I think the sanest/safest thing to do since most servers will have
special handing of -1 meaning 'nobody' or similar.
This should work on many/most servers and give the user the minimum available
access allowed for 'nobody'.

I think on windows (or AROS for that matter) applications will probably have
to invoke and set the credentials themself explicitely.
Those apps probably, unfortunately, also need to have a configuration
setting to select which uid/gid to use when talking to the server.
(or they could hardcode it)

rpc_set_auth(rpc, libnfs_authunix_create("hostname", uid, gid, 0, NULL))
should do the trick if they call immediately after creating the rpc/nfs context.

But dont set it to 0,0 root/root for uid/gid.
First of all, most servers have root-squash so they will re-map this uid/gid
to 'nobody' internally.
But, if the user uses a server that does not do root-squash, then setting this to 0,0 would mean that your app now access the nfs share as root   which is probably not what you want.
2013-05-25 06:24:15 -07:00
Ronnie Sahlberg 0c1a9d7a6b Fix a bug when returning the filehandle in creat() and return the filehandle
of the object we created and not the filehandle of the parent directory
2013-04-15 21:37:03 -07:00
Ronnie Sahlberg 73f4ae7cca Allow nfs_lookuppath_async to have path[0]=='\0' this happens when we
want to create an object straight under the root directory of what we
mounted.
As always, the actual object to create is then a string starting after the \0 byte
2013-04-15 20:42:44 -07:00
Ronnie Sahlberg 4945f30750 we can always include netinet/in.h all platforms have it 2013-04-14 10:34:33 -07:00
Ronnie Sahlberg 108c622a95 more include cleanups it starts to look almost decent now 2013-04-14 10:32:01 -07:00
Ronnie Sahlberg 00748f36c5 more header include cleanups 2013-04-14 10:11:48 -07:00
Ronnie Sahlberg 2142af5d47 WIN32: More ifdef cleanups 2013-04-14 09:02:23 -07:00
Ronnie Sahlberg 622489d36e WIN32: get rid of some ifdefs 2013-04-14 08:50:38 -07:00
Ronnie Sahlberg 099be710b6 SOCKET: Use recv/send for all socket io on all platforms
instead of only on windows and aros  and read/write on the others
2013-04-14 08:43:59 -07:00
Ronnie Sahlberg 9a9126c3d9 AROS: add inet_pton emulation and make sure we use recv/send and not read/write 2013-04-13 07:40:46 -07:00
Ronnie Sahlberg 2cdf4fcb07 AROS: it is called IoctlSocket/CloseSocket and WaitSelect on AROS.
Additionally add a aros_init_socket() function to open the bsd socket library and set up networking
2013-04-12 06:12:58 -07:00
Ronnie Sahlberg e77d093c37 AROS: getting closer to link. only a handful of missing symbols now 2013-04-11 18:37:05 -07:00
Ronnie Sahlberg d7c6e9aaa9 Initial AROS support.
The test app doesnt link yet since we are missing a bunch of symbols

but it is a start
2013-04-10 20:28:40 -07:00
Steve Cai a27561934c randomize the initial rpc xid to avoid reply cache collision 2013-02-25 16:40:29 -08:00
Ronnie Sahlberg 8afcdc959f New version 1.5
- Switch to our own builtin RPC/XDR replacement
- Android support
2012-12-03 06:38:18 -08:00
Ronnie Sahlberg e803ae5760 Rearrange the header files.
Move the headers we install to ./include/nfsc
and start including nfsc/libnfs-zdr.h  from all the other header files.
2012-11-28 20:21:53 -08:00
Cory Fields 252aa90dc8 [droid] Support building for android
These are the changes necessary to build for android. Working status is yet
untested.
2012-11-28 12:04:10 -05:00
Ronnie Sahlberg f816bf4c76 Merge branch 'zdr'
Manually fixyp some merge conflicts in :
	lib/init.c
	lib/pdu.c
	lib/socket.c
	nfs/Makefile.am
	nfs/nfs.x
	nlm/Makefile.am
2012-11-27 18:22:27 -08:00
Ronnie Sahlberg aab6538bbd Implement 'rejected_reply' and switch to RFC5531 definitions
Switch to using fields and names from RFC5531. that is the standard
for RPC.
2012-11-26 19:42:10 -08:00
Ronnie Sahlberg dedc4675ba New version 1.4
- Add trackig of freed context and assert on using a context after it has been
  freed.
- Windows x64 support and fixes.
- Switch to using our own version of xdr_int64() since the one in libtirpc
  crashes on some platforms.
- Fix memory leak in an error path for addrinfo.
- Fix bug dereferencing a null pointer in the mount callback on error.
2012-11-25 07:57:40 -08:00
Ronnie Sahlberg 5f08d03e16 ZDR_ARRAYS: The sub-unmarshaller returns TRUE FALSE if there was an error, not TRUE 2012-11-24 09:01:00 -08:00
Ronnie Sahlberg f3a7507806 Add an assert to track if we try to use an rpc_context after it has been destroyed 2012-11-24 08:18:54 -08:00
Ronnie Sahlberg 2811861b96 Dont leak addrinfo in error path 2012-11-24 08:14:12 -08:00
Ronnie Sahlberg 9b6d106414 MOUNT: when processing the mount response, check status before dereferencing data pointer
If status is non-zero in the mount callback, then the datapointer might be NULL
so we should not dereference it into an exports pointer before we have checked the status.

This would otherwise cause crashes.
2012-11-24 08:13:46 -08:00
Rudi Ihle 456c0b147a Fixed errno processing for connect() on Windows. 2012-11-24 08:12:45 -08:00
Rudi Ihle 2521374f70 Modified mechanism to assign privileged ports and enable it for Windows as well 2012-11-24 08:12:31 -08:00
Ronnie Sahlberg 4a2b08768a Add an assert to track if we try to use an rpc_context after it has been destroyed 2012-11-21 17:10:05 -08:00
Ronnie Sahlberg be7f59339e Dont leak addrinfo in error path 2012-11-17 10:14:19 -08:00
Ronnie Sahlberg 5ac848e908 MOUNT: when processing the mount response, check status before dereferencing data pointer
If status is non-zero in the mount callback, then the datapointer might be NULL
so we should not dereference it into an exports pointer before we have checked the status.

This would otherwise cause crashes.
2012-11-04 15:55:05 -08:00
Rudi Ihle f96b24fada Fixed errno processing for connect() on Windows. 2012-09-18 08:33:41 +02:00
Rudi Ihle ac559609a3 Modified mechanism to assign privileged ports and enable it for Windows as well 2012-09-18 08:32:40 +02:00
Ronnie Sahlberg b14062764e ZDR: we need to include both arpa/inet.h and time.h 2012-07-05 21:17:45 +10:00
Ronnie Sahlberg 442b829a05 Dont just cast *enum_t to *uint32_t
go via a temporary variable in case these scalars are different size
2012-07-05 21:13:04 +10:00
Ronnie Sahlberg 67ba2239cb Get rid of AUTH completely and replace all uses with 'struct AUTH' 2012-07-05 10:23:19 +10:00
Ronnie Sahlberg 45670bd0d6 fix compiler warnings 2012-07-05 07:37:37 +10:00
Ronnie Sahlberg 020f172895 fix compiler warning 2012-07-05 07:35:04 +10:00
Ronnie Sahlberg d14e28387f squelch compiler warnings in socket.c about integer sizes 2012-07-05 07:21:48 +10:00
Ronnie Sahlberg 574095b960 Change a size variable from uint64 to uint32 to squelch a warning 2012-07-05 07:12:11 +10:00
Ronnie Sahlberg 10a0ceaaa3 librpc_rpc_call_body() should return TRUE is successful 2012-07-05 07:09:00 +10:00
Ronnie Sahlberg 242b81cfbf setpos returns a boolean, set it to always return TRUE 2012-07-05 07:06:33 +10:00
Ronnie Sahlberg 763cd6e3e2 ZDR: New builtin replacement for RPC/XDR called ZDR
This patch switches libnfs over to use precompiled rpcgen files
and using ZDR.  ZDR is a trivial reimplementation of XDR that is built in
into libnfs.

This removes the dependencies of rpc/xdr completely and allow us to build on any
system, even systems where rpcgen and librpc/libxdr are not generally available.
2012-07-04 16:53:12 +10:00
Ronnie Sahlberg 6916a66546 NLM: initial support for NLM 2012-03-10 20:46:03 +11:00
Ronnie Sahlberg fa3c25beee NFSACL: Add support for SETACL3 2012-03-08 21:25:21 +11:00
Ronnie Sahlberg 47e5a2c740 new version 1.3 2012-03-03 19:04:58 +11:00