iPXE
Data Structures | Defines | Functions
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...

Defines

#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.


Define Documentation

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

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

#define MNT3_OK   0

No error.

Definition at line 21 of file mount.h.

Referenced by mount_get_mnt_reply().

#define MNT3ERR_PERM   1

Not owner.

Definition at line 23 of file mount.h.

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

#define MNT3ERR_IO   5

I/O error.

Definition at line 27 of file mount.h.

Referenced by mount_get_mnt_reply().

#define MNT3ERR_ACCES   13

Permission denied.

Definition at line 29 of file mount.h.

Referenced by mount_get_mnt_reply(), and nfs_mount_deliver().

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

#define MNT3ERR_INVAL   22

Invalid argument.

Definition at line 33 of file mount.h.

#define MNT3ERR_NAMETOOLONG   63

Filename too long.

Definition at line 35 of file mount.h.

Referenced by mount_get_mnt_reply().

#define MNT3ERR_NOTSUPP   10004

Operation not supported.

Definition at line 37 of file mount.h.

#define MNT3ERR_SERVERFAULT   10006

A failure on the server.

Definition at line 39 of file mount.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void mount_init_session ( struct oncrpc_session session,
struct oncrpc_cred credential 
) [inline, static]

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.

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

Referenced by nfs_open().

                                                                         {
        oncrpc_init_session ( session, credential, &oncrpc_auth_none,
                              ONCRPC_MOUNT, MOUNT_VERS );
}
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.

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

Referenced by nfs_mount_step().

                                         {
        struct oncrpc_field fields[] = {
                ONCRPC_FIELD ( str, mountpoint ),
                ONCRPC_FIELD_END,
        };

        return oncrpc_call ( intf, session, MOUNT_MNT, fields );
}
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.

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

Referenced by nfs_mount_step().

                                          {
        struct oncrpc_field fields[] = {
                ONCRPC_FIELD ( str, mountpoint ),
                ONCRPC_FIELD_END,
        };

        return oncrpc_call ( intf, session, MOUNT_UMNT, fields );
}
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.

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

                                                       {
        if (  ! mnt_reply || ! reply )
                return -EINVAL;

        mnt_reply->status = oncrpc_iob_get_int ( reply->data );

        switch ( mnt_reply->status )
        {
        case MNT3_OK:
                break;
        case MNT3ERR_NOENT:
                return -ENOENT;
        case MNT3ERR_IO:
                return -EIO;
        case MNT3ERR_ACCES:
                return -EACCES;
        case MNT3ERR_NOTDIR:
                return -ENOTDIR;
        case MNT3ERR_NAMETOOLONG:
                return -ENAMETOOLONG;
        default:
                return -EPROTO;
        }

        nfs_iob_get_fh ( reply->data, &mnt_reply->fh );

        return 0;
}