Commit Graph

944 Commits (e27453b4a96dcad4b18e04fd62d639c67b55cad0)

Author SHA1 Message Date
Ronnie Sahlberg b5f961c076 Dir cache: compare also mtime.nseconds when validating the cache
Compare BOTH the seconds field and the nanoseconds field when checking if
the cached directory structure is valid or not.
Linux knfsd and other modern servers actually do set the nanosecond field
so why not check it.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-06 16:04:03 -08:00
Ronnie Sahlberg 4476f11b9d Try to avoid allocating memory during zdr string decoding
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:16:35 -08:00
Ronnie Sahlberg 62daa224d9 Remove the zdr_malloc call when decoding a BYTES blob
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:15:20 -08:00
Ronnie Sahlberg e3cf674856 Use a single allocation for zdr_mem and the payload
Lets use a single allocation instead of two in the zdr_mem handler.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:13:47 -08:00
Ronnie Sahlberg 8c391edb17 Use a single allocation for both rpc_pdu and zde_decode_buf
We can save one malloc by storing both the rpc_pdu and decoding buffer
in the same memory block.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:12:36 -08:00
Ronnie Sahlberg 04363a9274 New version 1.10.0
The biggest changes in this release are:
 - Fix a leak where we leaked one rdpe_cb_data structure on each open_dir()
 - Make building the utils optional
 - Android: the correct define is __ANDROID__ not ANDROID
 - Win32: Use _U_ instead of ATTRIBURE((unused))
 - Win32: Fix nfs_stat declaration for Win32
 - Various fixes for mingw builds
 - Make rpc->connect_cb a one shot callback and improve documentation
 - Remove the FUSE module. It now lives in its own repo
 - Fix POLLERR/POLLHUP handling to properly handle session failures and to
   try to auto-reconnect

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:06:44 -08:00
Ronnie Sahlberg 49eaca0c42 Includes: Don't install win32/win32_compat.h
This header should only be used for building libnfs and should
not be installed.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-31 16:06:44 -08:00
Ronnie Sahlberg d827447242 Don't leak a rpde_cb_data structure on each opendir()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-01-16 18:37:07 -08:00
Ronnie Sahlberg ae236110d1 Merge pull request #134 from jbkempf/readme_update
Readme update
2016-01-16 11:56:46 -08:00
Jean-Baptiste Kempf f29382d03c README: mention Android 2016-01-16 19:16:35 +01:00
Jean-Baptiste Kempf 4324dcb846 README: mention MingW to cross-compile 2016-01-16 19:14:03 +01:00
Jean-Baptiste Kempf ab0b9b1f88 README: remove tabs and trailing spaces 2016-01-16 19:11:27 +01:00
Ronnie Sahlberg 66876e2879 Merge pull request #131 from jbkempf/win32_mingw
Support Win32 compilation with Mingw
2016-01-16 08:51:31 -08:00
Ronnie Sahlberg 9472c8a593 Merge pull request #133 from fkuehne/noutils-featurebranch
Add a configure option to disable the utils compilation
2016-01-16 08:48:12 -08:00
Felix Paul Kühne 0dc008ab93 Add a configure option to disable the utils compilation
For some targets like iOS, utils are not useable, so it should be possible to disable their compilation
2016-01-14 17:02:53 +01:00
Ronnie Sahlberg d337e4634e Merge pull request #132 from jbkempf/android_ndk
The correct NDK define for Android is __ANDROID__
2016-01-09 13:31:04 -08:00
Jean-Baptiste Kempf d02d5d0f5e The correct NDK define for Android is __ANDROID__
The ANDROID macro is not recommended
2016-01-09 13:35:11 +01:00
Diego Elio Pettenò 215b6eab13 win32: instead of ATTRIBUTE(unused) use _U_ to mark dummy as unused. 2016-01-08 23:43:07 +01:00
Diego Elio Pettenò 7744df2c76 build: enable subdir-objects option to make sure that source files are built where expected. 2016-01-08 23:43:06 +01:00
Diego Elio Pettenò 6b5b09dbc1 build: avoid abusing AM_LDFLAGS.
This fixes build with options such as --as-needed that require correct positional argument passing. They also ensure that the right dependency library is used.
2016-01-08 23:43:06 +01:00
Jean-Baptiste Kempf 4f0d26258e Win32: Fix nfs_stat declaration for Win32
So that the definition and declaration match.

There might be another way, with stat64i32 but I'm not confident it will
work with MSVC
2016-01-08 23:41:56 +01:00
Jean-Baptiste Kempf 3c37d03f4b Win32: do not compile nfs-cp in utils
It depends on stat features that are not available
2016-01-08 23:23:00 +01:00
Jean-Baptiste Kempf cd53647f53 Win32: link utils with winsock2 2016-01-08 23:23:00 +01:00
Jean-Baptiste Kempf 3ca22dcfdd Win32: Add win32_compat.h include 2016-01-08 23:23:00 +01:00
Jean-Baptiste Kempf 6adcfdcd56 Win32: Mingw has utimbuf 2016-01-08 23:08:11 +01:00
Jean-Baptiste Kempf 76daf49d2d Win32: Mingw has timezone and mingw_gettimeofday 2016-01-08 23:08:06 +01:00
Jean-Baptiste Kempf 6d30222b04 Win32: use lower-case for Windows headers
This does not change a thing for MSVC, but This is needed for
Cross-Compiling with Mingw/Mingw-w64
2016-01-08 22:29:50 +01:00
Ronnie Sahlberg 6f4ff8621f Handle POLLERR/POLLHUP properly and try to reconnect on failure
POLLERR and POLLHUP handling in rpc_service() could not deal with
session failures or auto reconnect.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-28 08:02:15 -08:00
Ronnie Sahlberg 034c277c71 Make rpc->connect_cb a one-shot callback
It makes no sense to have socket.c keep invoking this callback over and over.
Just change it to become one-shot.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 18:01:19 -08:00
Ronnie Sahlberg aea2810c1e Do not use ioctl(FIONREAD) for UDP sockets
The linux kernel does not check the UDP checksum until the application tries
to read if from the socket.

This means that the socket might be readable, but when we try to read
the data, or inspect how much data is available, the packets will be discarded
by the kernel.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 12:21:33 -08:00
Ronnie Sahlberg 1ec2d0c5b7 Add check that we have the full RM before starting to read the PDU data
If we are trying to read (part of?) the RM, we can not assume that as long
as recv() returned non-error that we have the full RM.
We must check before we proceed to try to read the actual PDU data.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-12-24 12:06:45 -08:00
Ronnie Sahlberg f681a2c167 Revert some commits that cause subtle API issues
We can not have a static rpc->inbuf buffer since that will no longer guarantee
that the received buffer is valid for the duration of callbacks.

One of the problems is that if we issue new (sync) RPCs from within a
callback, that will overwrite and invalidate the receive buffer that
we passed to the callback.

Revert "init: do not leak rpc->inbuf"
This reverts commit f7bc4c8bb1.

Revert "socket: we have to use memmove in rpc_read_from_socket"
This reverts commit 24429e95b8.

Revert "socket: make rpc->inbuf static and simplify receive logic"
This reverts commit 7000a0aa04.
2015-12-24 12:06:22 -08:00
Ronnie Sahlberg dc8d86628d Remove FUSE NFS filesystem
Remove the fuse module from the examples subdirectory.
This module is now a standalone repo :
https://github.com/sahlberg/fuse-nfs

And it comes with proper build rules, documentation etc etc.
It is a useful module and it has now graduated to become its own
repo.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-10-19 18:59:38 -07:00
Ronnie Sahlberg 4d102bd24d Improve the documentation for *_get_fd/*_which_events/*_service
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-10-19 18:57:30 -07:00
Ronnie Sahlberg d73d4f3305 rpc_reconnect_requeue: return -1 if autoreconnect is not enabled
This funciton is called from rpc_service when it has detected that
a socket has errored out during reading/writing.
However, since this fucntion returns 0 (==success) for the case where
autoreconnect is not enabled, this means that for an errored socket we
will return 0 (==success) from rpc_service() back to the application.

Change rpc_reconnect_requeue to return -1 when invoked and autoreconnect
is disabled so that applications will receive an error back from rpc_service.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-10-19 18:57:17 -07:00
Ronnie Sahlberg 82d2a22807 Merge pull request #130 from plieven/fix_fd
fix some reconnect issues
2015-09-28 19:25:17 -07:00
Peter Lieven ddd9e2f7e9 socket: keep fd the same across reconnects
There is no guarantee that we get the same fd again when
reestablishing a session. But if the fd changes during a
reconnect we might up with a client application busy polling
on the old fd.

Qemu registers a read handler on the current fd, but is
not realizing fd changes. So we busy poll on the old fd for good.
Things are working (except for the busy polling) until
a drain all is issued. At this point Qemu deadlocks.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-09-22 14:54:48 +02:00
Peter Lieven 7b7aef6b6d socket: keep reconnecting if a reconnect fails
otherwise we end up eating up all socket errors in rpc_service and then
believe we are connected, but the next call to rpc_read_from_socket
fails because the socket is closed. we then reconnect anyway.

Signed-off-by: Peter Lieven <pl@kamp.de>
2015-09-22 14:40:59 +02:00
Ronnie Sahlberg e453431d00 Merge pull request #129 from agraf/fuse-commands
Fuse commands
2015-09-11 05:01:04 -07:00
Alexander Graf 883f660430 fuse_nfs: Add fsync
Libnfs already has exports for fsync, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:24:47 +02:00
Alexander Graf 9439361243 fuse_nfs: Add truncate
Libnfs already has exports for truncate, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:24:09 +02:00
Alexander Graf b66121610d fuse_nfs: Add chown
Libnfs already has exports for chown, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:23:35 +02:00
Alexander Graf 315112b923 fuse_nfs: Add chmod
Libnfs already has exports for chmod, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:23:03 +02:00
Alexander Graf d1709ab573 fuse_nfs: Add link
Libnfs already has exports for link, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:22:29 +02:00
Alexander Graf 37fd16ee08 fuse_nfs: Add rename
Libnfs already has exports for rename, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:21:31 +02:00
Alexander Graf 50aabd0729 fuse_nfs: Add symlink
Libnfs already has exports for symlink, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:20:49 +02:00
Alexander Graf 618b6ea030 fuse_nfs: Add mknod
Libnfs already has exports for mknod, hook them up to the fuse example.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 11:19:52 +02:00
Ronnie Sahlberg c7204781b1 Merge pull request #128 from agraf/fuse-symlinks
Fuse symlinks
2015-09-10 17:34:29 -07:00
Alexander Graf 39d1f3693c fuse_nfs: Add symlink support
The fuse framework allows us to directly expose symlinks from NFS to the user,
just like a real NFS mount would. All we need to do is call lstat rather
than stat and implement a readlink function.

With this patch I can successfully chroot into a rootfs mounted using
fuse_nfs.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 00:23:48 +02:00
Alexander Graf e81f9e23ab fuse_nfs: Consider st_.tim as struct timespec
At least in my version of glibc the members st_mtim, st_ctim and st_atim
are defined as struct timespec rather than struct timeval, thus
containing a tv_nsec field rather than tv_usec.

Use the proper struct fields instead, fixing compilation on Linux.

Signed-off-by: Alexander Graf <agraf@suse.de>
2015-09-11 00:22:09 +02:00