53 #define NFS_RSIZE 100000 126 DBGC ( nfs,
"NFS_OPEN %p freed\n", nfs );
145 DBGC ( nfs,
"NFS_OPEN %p completed (%s)\n", nfs,
strerror (
rc ) );
158 if ( ! intf || ! hostname || !
port )
162 memset ( &local, 0,
sizeof ( local ) );
181 DBGC ( nfs,
"NFS_OPEN %p GETPORT call (mount)\n", nfs );
194 DBGC ( nfs,
"NFS_OPEN %p GETPORT call (nfs)\n", nfs );
225 DBGC ( nfs,
"NFS_OPEN %p got GETPORT reply (mount)\n", nfs );
243 DBGC ( nfs,
"NFS_OPEN %p got GETPORT reply (nfs)\n", nfs );
275 DBGC ( nfs,
"NFS_OPEN %p MNT call (%s)\n", nfs,
288 DBGC ( nfs,
"NFS_OPEN %p UMNT call\n", nfs );
316 DBGC ( nfs,
"NFS_OPEN %p got MNT reply\n", nfs );
319 switch ( mnt_reply.
status ) {
336 DBGC ( nfs,
"NFS_OPEN %p MNT failed retrying with " \
353 DBGC ( nfs,
"NFS_OPEN %p got UMNT reply\n", nfs );
369 char *path_component;
377 DBGC ( nfs,
"NFS_OPEN %p LOOKUP call (%s)\n", nfs,
391 DBGC ( nfs,
"NFS_OPEN %p READLINK call\n", nfs );
403 DBGC ( nfs,
"NFS_OPEN %p READ call\n", nfs );
437 DBGC ( nfs,
"NFS_OPEN %p got LOOKUP reply\n", nfs );
463 DBGC ( nfs,
"NFS_OPEN %p got READLINK reply\n", nfs );
485 DBGC ( nfs,
"NFS_OPEN %p new path: %s\n", nfs,
495 DBGC ( nfs,
"NFS_OPEN %p got READ reply\n", nfs );
504 DBGC2 ( nfs,
"NFS_OPEN %p size: %llu bytes\n",
513 nfs->
eof = read_reply.
eof;
522 DBGC ( nfs,
"NFS_OPEN %p got %zd bytes\n", nfs,
613 DBGC ( nfs,
"NFS_OPEN %p URI parsed: (mountpoint=%s, path=%s)\n",
634 nfs =
zalloc (
sizeof ( *nfs ) );
656 DBGC ( nfs,
"NFS_OPEN %p connecting to port mapper (%s:%d)...\n", nfs,
void nfs_uri_free(struct nfs_uri *uri)
struct interface nfs_intf
#define EINVAL
Invalid argument.
An object interface operation.
#define ECONNRESET
Connection reset.
struct arbelprm_rc_send_wqe rc
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
void intf_close(struct interface *intf, int rc)
Close an object interface.
int mount_get_mnt_reply(struct mount_mnt_reply *mnt_reply, struct oncrpc_reply *reply)
Parse an MNT reply.
enum nfs_pm_state pm_state
struct oncrpc_session mount_session
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
static void nfs_done(struct nfs_request *nfs, int rc)
Mark NFS operation as complete.
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
FEATURE(FEATURE_PROTOCOL, "NFS", DHCP_EB_FEATURE_NFS, 1)
#define ONCRPC_NFS
NFS protocol number.
uint32_t count
Bytes read.
#define FEATURE_PROTOCOL
Network protocols.
int nfs_get_read_reply(struct nfs_read_reply *read_reply, struct oncrpc_reply *reply)
Parse a READ reply.
int nfs_get_lookup_reply(struct nfs_lookup_reply *lookup_reply, struct oncrpc_reply *reply)
Parse a LOOKUP reply.
#define ref_init(refcnt, free)
Initialise a reference counter.
struct interface xfer
Data transfer interface.
static void nfs_init_session(struct oncrpc_session *session, struct oncrpc_cred *credential)
Prepare an ONC RPC session to be used as a NFS session.
static int nfs_mount_deliver(struct nfs_request *nfs, struct io_buffer *io_buf, struct xfer_metadata *meta __unused)
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
static struct interface_operation nfs_operations[]
static void nfs_free(struct refcnt *refcnt)
Free NFS request.
struct nfs_fh fh
File handle.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
unsigned long long uint64_t
static struct interface_operation nfs_pm_operations[]
static struct interface_descriptor nfs_xfer_desc
NFS data transfer interface descriptor.
enum nfs_mount_state mount_state
#define NFS_VERS
NFS protocol version.
Bind to a privileged port (less than 1024)
Uniform Resource Identifiers.
static int nfs_connect(struct interface *intf, uint16_t port, const char *hostname)
#define ONCRPC_MOUNT
NFS MOUNT protocol number.
uint32_t eof
End-of-File indicator.
#define PORTMAP_PROTO_TCP
TCP protocol number.
size_t xfer_window(struct interface *intf)
Check flow control window.
struct uri_opener nfs_uri_opener __uri_opener
NFS URI opener.
int nfs_lookup(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh, const char *filename)
Send a LOOKUP request.
struct oncrpc_cred_sys auth_sys
int nfs_read(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh, uint64_t offset, uint32_t count)
Send a READ request.
Data transfer interfaces.
static void portmap_init_session(struct oncrpc_session *session, struct oncrpc_cred *credential)
Prepare an ONC RPC session to be used as a PORTMAP session.
static struct interface_descriptor nfs_desc
#define ENOMEM
Not enough space.
#define iob_disown(iobuf)
Disown an I/O buffer.
enum nfs_attr_type ent_type
Entity type.
struct nfs_fh fh
Root file handle.
static int nfs_open(struct interface *xfer, struct uri *uri)
Initiate a NFS connection.
#define container_of(ptr, type, field)
Get containing structure.
struct nfs_fh readlink_fh
int portmap_get_getport_reply(struct portmap_getport_reply *getport_reply, struct oncrpc_reply *reply)
Parse a GETPORT reply.
#define __unused
Declare a variable or data structure as unused.
int oncrpc_init_cred_sys(struct oncrpc_cred_sys *auth_sys)
Initialize an ONC RPC AUTH SYS credential structure.
const char * path
Path (after URI decoding)
static struct interface_descriptor nfs_pm_desc
const char * scheme
URI protocol name.
Transport-network layer interface.
static struct interface_operation nfs_xfer_operations[]
#define MOUNT_VERS
NFS MOUNT protocol version.
int oncrpc_get_reply(struct oncrpc_session *session __unused, struct oncrpc_reply *reply, struct io_buffer *io_buf)
Parse an I/O buffer to extract a ONC RPC REPLY.
#define EPROTO
Protocol error.
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
Generalized socket address structure.
An object interface descriptor.
#define iob_unput(iobuf, len)
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
#define MNT3ERR_NOENT
No such file or directory.
void * zalloc(size_t size)
Allocate cleared memory.
int nfs_uri_init(struct nfs_uri *nfs_uri, const struct uri *uri)
#define PORTMAP_PORT
PORTMAP default port.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
char * strdup(const char *src)
Duplicate string.
uint32_t status
Reply status.
struct interface mount_intf
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
struct oncrpc_session pm_session
Data transfer interface opening.
char * nfs_uri_mountpoint(const struct nfs_uri *uri)
const char * host
Host name.
static int nfs_parse_uri(struct nfs_request *nfs, const struct uri *uri)
static void nfs_pm_step(struct nfs_request *nfs)
int portmap_getport(struct interface *intf, struct oncrpc_session *session, uint32_t prog, uint32_t vers, uint32_t proto)
Send a GETPORT request.
int mount_mnt(struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
Send a MNT request.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
int nfs_readlink(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh)
Send a READLINK request.
Network File System protocol URI handling functions.
int strcmp(const char *first, const char *second)
Compare strings.
Network File System protocol.
static void mount_init_session(struct oncrpc_session *session, struct oncrpc_cred *credential)
Prepare an ONC RPC session to be used as a MOUNT session.
Network File System protocol.
struct oncrpc_session nfs_session
static struct interface_descriptor nfs_mount_desc
char * strndup(const char *src, size_t max)
Duplicate string.
A Uniform Resource Identifier.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
struct mschapv2_challenge peer
Peer challenge.
static void nfs_step(struct nfs_request *nfs)
static void nfs_mount_step(struct nfs_request *nfs)
struct refcnt refcnt
Reference counter.
#define DHCP_EB_FEATURE_NFS
NFS protocol.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
int nfs_get_readlink_reply(struct nfs_readlink_reply *readlink_reply, struct oncrpc_reply *reply)
Parse a READLINK reply.
int nfs_uri_symlink(struct nfs_uri *uri, const char *symlink)
int mount_umnt(struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
Send a UMNT request.
int nfs_uri_next_mountpoint(struct nfs_uri *uri)
struct oncrpc_cred credential
uint32_t port
Port returned.
char * nfs_uri_next_path_component(struct nfs_uri *uri)
struct bofm_section_header done
uint64_t filesize
File size.
static int nfs_deliver(struct nfs_request *nfs, struct io_buffer *io_buf, struct xfer_metadata *meta __unused)
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
#define MNT3ERR_ACCES
Permission denied.
#define ref_put(refcnt)
Drop reference to object.
static int nfs_pm_deliver(struct nfs_request *nfs, struct io_buffer *io_buf, struct xfer_metadata *meta __unused)
static struct interface_operation nfs_mount_operations[]
void * memset(void *dest, int character, size_t len) __nonnull
#define MNT3ERR_NOTDIR
Not a directory.
uint32_t path_len
File path length.