Commit Graph

493 Commits (aec45c6274bffc92fc1595a95d043e8aae292451)

Author SHA1 Message Date
Ronnie Sahlberg 215228a23d handle the case where we try a multi-read that is completely beyond the end of file.
when a multi-read was completely beyond the end of file, this caused us to invoke the callback with a 'read-count' of <0  which the callback would treat as a failure.
This would then cause the callback to treat the data pointer as an error string and try to use it for nfs_set_error().
Since the data pointer was actually a real binary databuffer and not an error string this would cause the NFS error string to look like it contained garbage data.

In this case, where the multi-read fails to read any data at all since it if fully beyond end of file,  make sure to invoke the callback with a read-count of 0
2011-06-25 12:13:11 +10:00
Ronnie Sahlberg 739df145d6 fix crash in mount/export
need to check that status is OK before we start dereferencing the 'export' pointers or else we will segv.
this could happen if trying to pull the list of exports from a host that does not have mountd running, or if we can not connect at all to the host.
2011-06-25 11:06:53 +10:00
Ronnie Sahlberg 1e8994af0f Add a very subtle bug in nfs_set_error()
when nfs_set_error is called with error_string being the result of a lower layer
problem so it is passed as "rpc_get_error()"

This meant that since free that nfs->rpc->error_string before we reference it a few lines further down in the vasprintf(..., error_string,
adn memory corruption triggers.

Valgrind found this, Valgrind rules!
2011-06-21 18:33:50 +10:00
Ronnie Sahlberg e4a5ba42b8 When doping chunked multi-reads of a blob bigger than the max readsize,
a read can sometimes span beyond the end of file.

In which case individual smal read chunks beyond the end of file will return OK, 0 bytes of data and EOF==1

For this case, trap when len==0 and ignore these chunks.
Do not update the read-count if / when len is 0.
2011-06-21 06:07:29 +10:00
Ronnie Sahlberg e8cab72a79 From Paul van der Zwan
Set the directory bit in st_mode properly.
2011-06-20 01:02:48 +10:00
Ronnie Sahlberg cdb19ec164 Redo the buffer handling for input buffers and make sure we only read one PDU at a time 2011-06-20 00:56:47 +10:00
Ronnie Sahlberg e210bd2af8 remove the need for an explicit rpc context for the highlevel function mount_getexports() 2011-06-19 23:20:35 +10:00
Ronnie Sahlberg df5af25fd2 add a sync function to get the export list from a server and add an example of how to use this functio n to nfsclient-sync 2011-06-19 22:31:34 +10:00
Ronnie Sahlberg 7f0242ca9a Add a high-level async function to read the export list 2011-06-19 14:54:17 +10:00
Ronnie Sahlberg 440a7dfced Add example for how to call MOUNT/EXPORT and get the exports list using the raw lowlevel api. 2011-06-19 10:28:25 +10:00
Ronnie Sahlberg 1896d37bfa get rid of all remaining printfs from the library
add a helper function nfs_set_error() to use instead of the printfs
2011-06-19 09:38:20 +10:00
Ronnie Sahlberg 5f9d02f839 get rid of compiler warning 2011-06-19 09:05:20 +10:00
Ronnie Sahlberg cbbf9d3e81 remove all printf's and replace them with rpc_set_error()
also change all error return codes to always return -1
2011-06-19 09:03:04 +10:00
Ronnie Sahlberg 921f877be4 Add support in read/pread to be aware of the Maximum Read size that the server
suggested.

When a read/pread operation that is 'oversize' is issued, the read/pread command will internally chop this up into smaller chunsk and send then concurrently to the server.
As replies come back from the server we add the data to a reassembly buffer
and as soon as all replies have been received we invoke the callback and pass the reassembly buffer back to the application.
2011-06-19 08:43:28 +10:00
Ronnie Sahlberg e2ba5764d4 Remove the _sync postfix for the synchronous functions 2011-06-18 15:07:53 +10:00
Ronnie Sahlberg bc11f4c3f1 Merge pull request #5 from OpenELEC/libnfs-destdir
(Re)Adding DESTDIR support, adding support to set --includedir at configure time, disable ldconfig for crosscompiling
2011-06-11 16:10:09 -07:00
Ronnie Sahlberg 3d1fec08f7 Merge pull request #4 from Memphiz/readme
- adapted README with tested plattforms
2011-06-11 16:07:09 -07:00
Stephan Raue 310bb382d4 add DESTDIR support, needed for crosscompiling; dont hardcode /usr/include - use --includedir= instead on configure time
Signed-off-by: Stephan Raue <stephan@openelec.tv>
2011-06-11 23:25:07 +02:00
Stephan Raue d20a6d6bcd Disable run of ldconfig if crosscompiling too
Signed-off-by: Stephan Raue <stephan@openelec.tv>
2011-06-11 23:22:19 +02:00
Memphiz 2461e2117e - adapted README with tested plattforms 2011-06-11 19:37:28 +02:00
Ronnie Sahlberg 81132c6dcb Merge pull request #3 from Memphiz/originalnfs2
"Last" pull ...
2011-06-10 15:04:51 -07:00
Memphis e644e70061 - add configure option for disabling the call to ldconfig on make install
- this is needed because we use a prefix which is writable by the user - calling ldconfig
would need root rights which we have to avoid...
2011-06-08 17:22:46 +02:00
Memphiz 2060155945 - make unsigned hyper overridable by cmdline by specifying -DU_INT64_PLATTFORM_TYPE to rpcgen 2011-06-08 00:23:59 +02:00
Memphiz fb109a12e1 - honor @cc@,@CLFAGS@ and @LDFLAGS@ which is important for cross compilation
- use a more generic regexp for renaming the generated rpc header includes - because the include is without subpath on darwin/ios
- make linkerstuff and so names dynamic according to @is_darwin@
- create install directorys if they don't exist
- use $(prefix) instead of $(DESTDIR) for installation
- build examples only if @ENABLE_EXAMPLES@ is set (default is on)
- rm -rf bin on clean because darwin adds directories here on compilation
- use u_int64_t for rpcgen on darwin instead of unsigned hyper (it is not known to the darwin rpcgen...)
2011-06-08 00:23:04 +02:00
Memphiz 23701e4246 - no ldconfig for darwin
- add variable is_darwin - used in Makefile.in for building the proper dynamic lib
- add option --without-examples for disable build of examples
2011-06-08 00:22:37 +02:00
Memphiz 2e4fb8e647 - fixed library path for mac osx (there is no lib64 path here...) 2011-06-07 15:32:01 +10:00
Ronnie Sahlberg 77c23b46c0 Add support for version 2 of the rquota protocol 2011-06-02 22:16:42 +10:00
Ronnie Sahlberg 19e74f5a32 Add RQUOTA1/GETACTIVEQUOTA call to the raw low level API 2011-06-02 22:06:25 +10:00
Ronnie Sahlberg 734ab63acd Merge pull request #1 from Memphiz/originalnfs
First pullrequests for beeing some more plattform compatible :)
2011-06-02 00:48:03 -07:00
Memphiz c353ec247e - missing rpc/rpc.h for new rquota too 2011-06-01 19:10:23 +02:00
Memphis 98f5fee87d - linux, osx, and ios need rpc/rpc.h includede before rpc/xdr.h
- fixed some missing includes for bzero, malloc and free
2011-06-01 18:06:15 +02:00
Memphis a62cb4b707 - include string.h for memcpy 2011-06-01 18:05:50 +02:00
Memphis d6ced294d8 - refactored parametername from reserved keyword "export" to "exportname" 2011-06-01 18:05:18 +02:00
Memphis 684c77edb0 - removed unneeded dependency to libpopt 2011-06-01 18:04:53 +02:00
Ronnie Sahlberg ea214e4566 Use HAVE_SOCK_SIN_LEN and set ->sin_len
for legacy unixens (AIX)
so that we will compile and run on those systems with a "weird"
sockaddr_in definition.
2011-06-01 21:31:40 +10:00
Ronnie Sahlberg 05a777d98a Initial support for RQUOTA protocol 2011-06-01 20:55:27 +10:00
Ronnie Sahlberg 7d0397cf0f get rid of some compiler warnings 2011-06-01 00:12:55 +10:00
Ronnie Sahlberg 17ef62fad7 Read the max read/write sizes supported when connecting to NFS
and store in the nfs context.
Privide accessor functions to read the max sizes.
2011-06-01 00:08:29 +10:00
Ronnie Sahlberg f4b9cb0e0f Add example of NFS/FSINFO async call 2011-05-31 23:50:44 +10:00
Ronnie Sahlberg 1058201ef0 Add support for async version of NFS/FSINFO3 call 2011-05-31 23:50:18 +10:00
Ronnie Sahlberg 912f7ad5b0 Use getsockopt to extract better failure condition when tcp layer receives a failure 2011-02-07 22:11:12 +11:00
Ronnie Sahlberg f7b81274cb README: mention that you need "insecure" to use libnfs as non-root user 2011-02-06 16:39:37 +11:00
Ronnie Sahlberg 84004dbf9b initial libnfs checkin 2011-02-06 15:45:09 +11:00