iPXE
mount.h File Reference

NFS MOUNT protocol. More...

#include <ipxe/nfs.h>

Go to the source code of this file.

Data Structures

struct  mount_mnt_reply
 A MOUNT MNT reply. More...

Macros

#define ONCRPC_MOUNT   100005
 NFS MOUNT protocol number.
#define MOUNT_VERS   3
 NFS MOUNT protocol version.
#define MNT3_OK   0
 No error.
#define MNT3ERR_PERM   1
 Not owner.
#define MNT3ERR_NOENT   2
 No such file or directory.
#define MNT3ERR_IO   5
 I/O error.
#define MNT3ERR_ACCES   13
 Permission denied.
#define MNT3ERR_NOTDIR   20
 Not a directory.
#define MNT3ERR_INVAL   22
 Invalid argument.
#define MNT3ERR_NAMETOOLONG   63
 Filename too long.
#define MNT3ERR_NOTSUPP   10004
 Operation not supported.
#define MNT3ERR_SERVERFAULT   10006
 A failure on the server.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
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.
int mount_mnt (struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
 Send a MNT request.
int mount_umnt (struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
 Send a UMNT request.
int mount_get_mnt_reply (struct mount_mnt_reply *mnt_reply, struct oncrpc_reply *reply)
 Parse an MNT reply.

Detailed Description

NFS MOUNT protocol.

Definition in file mount.h.

Macro Definition Documentation

◆ ONCRPC_MOUNT

#define ONCRPC_MOUNT   100005

NFS MOUNT protocol number.

Definition at line 15 of file mount.h.

Referenced by mount_init_session(), and nfs_pm_step().

◆ MOUNT_VERS

#define MOUNT_VERS   3

NFS MOUNT protocol version.

Definition at line 17 of file mount.h.

Referenced by mount_init_session(), and nfs_pm_step().

◆ MNT3_OK

#define MNT3_OK   0

No error.

Definition at line 21 of file mount.h.

Referenced by mount_get_mnt_reply().

◆ MNT3ERR_PERM

#define MNT3ERR_PERM   1

Not owner.

Definition at line 23 of file mount.h.

◆ MNT3ERR_NOENT

#define MNT3ERR_NOENT   2

No such file or directory.

Definition at line 25 of file mount.h.

Referenced by mount_get_mnt_reply(), and nfs_mount_deliver().

◆ MNT3ERR_IO

#define MNT3ERR_IO   5

I/O error.

Definition at line 27 of file mount.h.

Referenced by mount_get_mnt_reply().

◆ MNT3ERR_ACCES

#define MNT3ERR_ACCES   13

Permission denied.

Definition at line 29 of file mount.h.

Referenced by mount_get_mnt_reply(), and nfs_mount_deliver().

◆ MNT3ERR_NOTDIR

#define MNT3ERR_NOTDIR   20

Not a directory.

Definition at line 31 of file mount.h.

Referenced by mount_get_mnt_reply(), and nfs_mount_deliver().

◆ MNT3ERR_INVAL

#define MNT3ERR_INVAL   22

Invalid argument.

Definition at line 33 of file mount.h.

◆ MNT3ERR_NAMETOOLONG

#define MNT3ERR_NAMETOOLONG   63

Filename too long.

Definition at line 35 of file mount.h.

Referenced by mount_get_mnt_reply().

◆ MNT3ERR_NOTSUPP

#define MNT3ERR_NOTSUPP   10004

Operation not supported.

Definition at line 37 of file mount.h.

◆ MNT3ERR_SERVERFAULT

#define MNT3ERR_SERVERFAULT   10006

A failure on the server.

Definition at line 39 of file mount.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ mount_init_session()

void mount_init_session ( struct oncrpc_session * session,
struct oncrpc_cred * credential )
inlinestatic

Prepare an ONC RPC session to be used as a MOUNT session.

Parameters
sessionONC RPC session
credentialONC RPC credential

The credential parameter must not be NULL, use 'oncrpc_auth_none' if you don't want a particular scheme to be used.

Definition at line 62 of file mount.h.

63 {
64 oncrpc_init_session ( session, credential, &oncrpc_auth_none,
66}
#define MOUNT_VERS
NFS MOUNT protocol version.
Definition mount.h:17
#define ONCRPC_MOUNT
NFS MOUNT protocol number.
Definition mount.h:15
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition oncrpc.c:56
void oncrpc_init_session(struct oncrpc_session *session, struct oncrpc_cred *credential, struct oncrpc_cred *verifier, uint32_t prog_name, uint32_t prog_vers)
Prepare an ONC RPC session structure to be used by the ONC RPC layer.
Definition oncrpc.c:115

References MOUNT_VERS, oncrpc_auth_none, oncrpc_init_session(), and ONCRPC_MOUNT.

Referenced by nfs_open().

◆ mount_mnt()

int mount_mnt ( struct interface * intf,
struct oncrpc_session * session,
const char * mountpoint )

Send a MNT request.

Parameters
intfInterface to send the request on
sessionONC RPC session
mountpoinrtThe path of the directory to mount.
Return values
rcReturn status code

Definition at line 58 of file mount.c.

59 {
60 struct oncrpc_field fields[] = {
61 ONCRPC_FIELD ( str, mountpoint ),
63 };
64
65 return oncrpc_call ( intf, session, MOUNT_MNT, fields );
66}
#define MOUNT_MNT
MNT procedure number.
Definition mount.c:46
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition oncrpc.c:129
#define ONCRPC_FIELD_END
Definition oncrpc.h:32
#define ONCRPC_FIELD(type, value)
Definition oncrpc.h:28

References MOUNT_MNT, oncrpc_call(), ONCRPC_FIELD, and ONCRPC_FIELD_END.

Referenced by nfs_mount_step().

◆ mount_umnt()

int mount_umnt ( struct interface * intf,
struct oncrpc_session * session,
const char * mountpoint )

Send a UMNT request.

Parameters
intfInterface to send the request on
sessionONC RPC session
mountpoinrtThe path of the directory to unmount.
Return values
rcReturn status code

Definition at line 76 of file mount.c.

77 {
78 struct oncrpc_field fields[] = {
79 ONCRPC_FIELD ( str, mountpoint ),
81 };
82
83 return oncrpc_call ( intf, session, MOUNT_UMNT, fields );
84}
#define MOUNT_UMNT
UMNT procedure number.
Definition mount.c:48

References MOUNT_UMNT, oncrpc_call(), ONCRPC_FIELD, and ONCRPC_FIELD_END.

Referenced by nfs_mount_step().

◆ mount_get_mnt_reply()

int mount_get_mnt_reply ( struct mount_mnt_reply * mnt_reply,
struct oncrpc_reply * reply )

Parse an MNT reply.

Parameters
mnt_replyA structure where the data will be saved
replyThe ONC RPC reply to get data from
Return values
rcReturn status code

Definition at line 93 of file mount.c.

94 {
95 if ( ! mnt_reply || ! reply )
96 return -EINVAL;
97
98 mnt_reply->status = oncrpc_iob_get_int ( reply->data );
99
100 switch ( mnt_reply->status )
101 {
102 case MNT3_OK:
103 break;
104 case MNT3ERR_NOENT:
105 return -ENOENT;
106 case MNT3ERR_IO:
107 return -EIO;
108 case MNT3ERR_ACCES:
109 return -EACCES;
110 case MNT3ERR_NOTDIR:
111 return -ENOTDIR;
113 return -ENAMETOOLONG;
114 default:
115 return -EPROTO;
116 }
117
118 nfs_iob_get_fh ( reply->data, &mnt_reply->fh );
119
120 return 0;
121}
#define ENOENT
No such file or directory.
Definition errno.h:515
#define EINVAL
Invalid argument.
Definition errno.h:429
#define ENAMETOOLONG
Filename too long.
Definition errno.h:474
#define EPROTO
Protocol error.
Definition errno.h:625
#define EIO
Input/output error.
Definition errno.h:434
#define ENOTDIR
Not a directory.
Definition errno.h:575
#define EACCES
Permission denied.
Definition errno.h:299
#define MNT3ERR_NOENT
No such file or directory.
Definition mount.h:25
#define MNT3ERR_IO
I/O error.
Definition mount.h:27
#define MNT3ERR_NAMETOOLONG
Filename too long.
Definition mount.h:35
#define MNT3ERR_NOTDIR
Not a directory.
Definition mount.h:31
#define MNT3ERR_ACCES
Permission denied.
Definition mount.h:29
#define MNT3_OK
No error.
Definition mount.h:21
size_t nfs_iob_get_fh(struct io_buffer *io_buf, struct nfs_fh *fh)
Extract a file handle from the beginning of an I/O buffer.
Definition nfs.c:61
#define oncrpc_iob_get_int(buf)
Get a 32 bits integer from the beginning of an I/O buffer.
Definition oncrpc_iob.h:38
uint32_t status
Reply status.
Definition mount.h:48
struct nfs_fh fh
Root file handle.
Definition mount.h:50
struct io_buffer * data
Definition oncrpc.h:68

References oncrpc_reply::data, EACCES, EINVAL, EIO, ENAMETOOLONG, ENOENT, ENOTDIR, EPROTO, mount_mnt_reply::fh, MNT3_OK, MNT3ERR_ACCES, MNT3ERR_IO, MNT3ERR_NAMETOOLONG, MNT3ERR_NOENT, MNT3ERR_NOTDIR, nfs_iob_get_fh(), oncrpc_iob_get_int, and mount_mnt_reply::status.

Referenced by nfs_mount_deliver().