Ronnie Sahlberg
d8143ff7d7
Win32: the stat structure on win32 does not have blocks or blocksize
2011-08-28 19:29:08 +10:00
Ronnie Sahlberg
93e9306f80
replace index/rindex with modern equivalents
2011-08-28 19:27:57 +10:00
Ronnie Sahlberg
a671a46510
replace index/rindex with modern equivalents
2011-08-28 19:27:23 +10:00
Ronnie Sahlberg
9896c7155c
nfs_set_auth() is a void and does not return anything
2011-08-28 19:26:07 +10:00
Ronnie Sahlberg
be337389bf
nfs_set_auth() is a void and does not return anything
2011-08-28 19:25:20 +10:00
Ronnie Sahlberg
eecdc4f3cd
Win32 changes, include files we need when compiling under win32
...
and some socket ops are slightly different
2011-08-28 19:24:18 +10:00
Ronnie Sahlberg
11ef53a2e6
callit_cb() : dont return a value from avoid function
2011-08-28 19:00:04 +10:00
Ronnie Sahlberg
b3740e09de
callit_cb() : dont return a value from avoid function
2011-08-28 18:59:13 +10:00
Ronnie Sahlberg
963c2f83be
Initialize the rootfh handle when creating the nfs context or else
...
we will try to free a wild pointer if the mount failed
and we proceed to call nfs_destroy_context();
2011-07-31 10:59:46 +10:00
Ronnie Sahlberg
b077fdeb65
Add automatic reconnect after TCP session failure for the sync interface.
...
Once a NFS TCP connection has been idle for a very long time, say
10-15 minutes, it is common that NFS servers will tear down the TCP connection.
So add code to re-connect to the NFS server and re-issue any i/o that might have been in flight (unlikely unless the server has hung)
While it is sufficient to just reconnect to tcp port 2049, it was much simplet to just utilize the nfs_mount() function.
This means that instead of just reconnecting TCP port 2049, we do a full blown
nfs mount via portmapper and mountd protocols.
2011-07-31 10:49:47 +10:00
Ronnie Sahlberg
8c27363e21
since UDP is unreliable, send the CALLIT broadcasts 3 times, one second apart when probing for local NFS servers
2011-07-16 17:30:44 +10:00
Ronnie Sahlberg
e5964ef905
break out the loop for sending a NFSd probe bcast on every interface into a separate function
2011-07-16 17:27:12 +10:00
Memphiz
41a6209bef
[fix] - fix allocation of if list for osx
...
- removed one unneeded header in examples/nfsclient-bcast.c which was breaking build under osx
2011-07-11 19:16:13 +02:00
Ronnie Sahlberg
9a96dd46d2
We have to include config.h when testing for precense of sockaddr sa_len
2011-07-10 08:50:36 +10:00
Ronnie Sahlberg
1be803ce7f
On OSX and other systems where we have sockaddr_in, SIOCGIFCONF returns a packed list of ifreq structures, so we can not just index them as (struct ifreq *)[i]
...
Instead we have to compute the offset into the buffer for where the next record starts (this offset might or might not be sizeof(struct ifreq)
2011-07-10 08:39:54 +10:00
Trent Nelson
56320c681f
Fix out-of-tree (VPATH) builds
2011-07-06 16:38:38 -04:00
Ronnie Sahlberg
1ad6f93185
when ioctl() for getting the broadcast address fails, continue the loop to the next entry instead of exiting out
2011-07-04 08:46:19 +10:00
Memphiz
b989ca9c36
- fixed missing include for osx
2011-07-03 15:25:48 +02:00
Ronnie Sahlberg
f7f931c7e3
add back a check for sa_len in sockaddr structure.
2011-07-03 07:41:15 +10:00
Ronnie Sahlberg
1b9917b886
With broadcast PDUs we can receive multiple replies so must make sure we
...
delete the previuous unmarshalling buffer when we start over and
process the second pdu to the initial call.
Or else we will leak memory very slowly when processing broadcast RPC replies
2011-07-02 12:16:37 +10:00
Ronnie Sahlberg
2e4db0d145
Merge remote branch 't-nelson/automake'
2011-07-02 11:10:36 +10:00
Ronnie Sahlberg
552c766578
add example for sync interface to probe for all local servers
2011-07-02 10:30:16 +10:00
Trent Nelson
fc01d2a961
Fix compile error on solaris.
...
Include sys/filio.h explicitly as solaris doesn't define BSD_COMP and
thus doesn't pull this header via sys/ioctl.h. Needed for FIONREAD.
2011-06-29 14:15:23 -04:00
Trent Nelson
2842ff15c8
Handle versioning the libtool way.
2011-06-29 14:15:22 -04:00
Trent Nelson
6c437065d3
Rewrite build system using automake
...
Initial commit, only linux tested so far.
2011-06-29 14:15:16 -04:00
Ronnie Sahlberg
7ff2f3a01d
when destroying a udp rpc context, free any udp_dest data we may have
2011-06-26 18:58:54 +10:00
Ronnie Sahlberg
c481da67f2
add function to extract the sockaddr from which we received the current rpc pdu
...
(useful when parsing replies from broadcast rpc calls)
2011-06-26 18:45:38 +10:00
Ronnie Sahlberg
5bf60dc601
add function to set the target for UDP rpc calls.
...
including doing broadcast calls
2011-06-26 18:42:53 +10:00
Ronnie Sahlberg
485bc9b9a7
add function to bind a udp rpc context to a local port/address
2011-06-26 18:40:00 +10:00
Ronnie Sahlberg
070287e516
Dont allow a tcp _connect to a UDP context
2011-06-26 18:32:06 +10:00
Ronnie Sahlberg
0268794fe3
add capability to read UDP datagrams from the socket and pass them to the parser
2011-06-26 18:30:26 +10:00
Ronnie Sahlberg
5911f3e8ab
for UDP sockets, we ONLY wait for pollin events
...
since upd sockets are always writeable.
they just silently drop packets when congested
2011-06-26 18:26:34 +10:00
Ronnie Sahlberg
a669857d0d
add support for sending and receiving udp pdu
2011-06-26 18:24:24 +10:00
Ronnie Sahlberg
a19924120d
in allocate pdu, if context is udp, dont allocate space for a record marker
2011-06-26 17:30:00 +10:00
Ronnie Sahlberg
9e00b8c663
add function to request a UDP context
...
(private use only since we dont want applications to use UDP)
2011-06-26 17:27:40 +10:00
Ronnie Sahlberg
7ed9d87a5b
redo the previous patch to instead initialize max_offset correctly before we invoke the chunks.
...
this is the correct way to fix this bug.
2011-06-25 12:23:52 +10:00
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
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
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
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
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
912f7ad5b0
Use getsockopt to extract better failure condition when tcp layer receives a failure
2011-02-07 22:11:12 +11:00
Ronnie Sahlberg
84004dbf9b
initial libnfs checkin
2011-02-06 15:45:09 +11:00