iPXE
Macros | Functions
mount.c File Reference

NFS MOUNT protocol. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <libgen.h>
#include <byteswap.h>
#include <ipxe/time.h>
#include <ipxe/iobuf.h>
#include <ipxe/open.h>
#include <ipxe/features.h>
#include <ipxe/oncrpc.h>
#include <ipxe/oncrpc_iob.h>
#include <ipxe/nfs.h>
#include <ipxe/mount.h>

Go to the source code of this file.

Macros

#define MOUNT_MNT   1
 MNT procedure number. More...
 
#define MOUNT_UMNT   3
 UMNT procedure number. More...
 

Functions

int mount_mnt (struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
 Send a MNT request. More...
 
int mount_umnt (struct interface *intf, struct oncrpc_session *session, const char *mountpoint)
 Send a UMNT request. More...
 
int mount_get_mnt_reply (struct mount_mnt_reply *mnt_reply, struct oncrpc_reply *reply)
 Parse an MNT reply. More...
 

Detailed Description

NFS MOUNT protocol.

Definition in file mount.c.

Macro Definition Documentation

◆ MOUNT_MNT

#define MOUNT_MNT   1

MNT procedure number.

Definition at line 44 of file mount.c.

◆ MOUNT_UMNT

#define MOUNT_UMNT   3

UMNT procedure number.

Definition at line 46 of file mount.c.

Function Documentation

◆ 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 56 of file mount.c.

57  {
58  struct oncrpc_field fields[] = {
59  ONCRPC_FIELD ( str, mountpoint ),
61  };
62 
63  return oncrpc_call ( intf, session, MOUNT_MNT, fields );
64 }
#define ONCRPC_FIELD(type, value)
Definition: oncrpc.h:28
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
struct ntlm_data session
Session key.
Definition: ntlm.h:24
#define MOUNT_MNT
MNT procedure number.
Definition: mount.c:44
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32

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

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 74 of file mount.c.

75  {
76  struct oncrpc_field fields[] = {
77  ONCRPC_FIELD ( str, mountpoint ),
79  };
80 
81  return oncrpc_call ( intf, session, MOUNT_UMNT, fields );
82 }
#define ONCRPC_FIELD(type, value)
Definition: oncrpc.h:28
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
#define MOUNT_UMNT
UMNT procedure number.
Definition: mount.c:46
struct ntlm_data session
Session key.
Definition: ntlm.h:24
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32

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

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 91 of file mount.c.

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

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().