Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
- Loading branch information
Showing
21 changed files
with
2,238 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#ifndef _IPXE_MOUNT_H | ||
#define _IPXE_MOUNT_H | ||
|
||
#include <ipxe/nfs.h> | ||
|
||
/** @file | ||
* | ||
* NFS MOUNT protocol. | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
/** NFS MOUNT protocol number */ | ||
#define ONCRPC_MOUNT 100005 | ||
/** NFS MOUNT protocol version */ | ||
#define MOUNT_VERS 3 | ||
|
||
|
||
/** No error */ | ||
#define MNT3_OK 0 | ||
/** Not owner */ | ||
#define MNT3ERR_PERM 1 | ||
/** No such file or directory */ | ||
#define MNT3ERR_NOENT 2 | ||
/** I/O error */ | ||
#define MNT3ERR_IO 5 | ||
/** Permission denied */ | ||
#define MNT3ERR_ACCES 13 | ||
/** Not a directory */ | ||
#define MNT3ERR_NOTDIR 20 | ||
/** Invalid argument */ | ||
#define MNT3ERR_INVAL 22 | ||
/** Filename too long */ | ||
#define MNT3ERR_NAMETOOLONG 63 | ||
/** Operation not supported */ | ||
#define MNT3ERR_NOTSUPP 10004 | ||
/** A failure on the server */ | ||
#define MNT3ERR_SERVERFAULT 10006 | ||
|
||
|
||
/** | ||
* A MOUNT MNT reply | ||
* | ||
*/ | ||
struct mount_mnt_reply { | ||
/** Reply status */ | ||
uint32_t status; | ||
/** Root file handle */ | ||
struct nfs_fh fh; | ||
}; | ||
|
||
/** | ||
* Prepare an ONC RPC session to be used as a MOUNT session | ||
* | ||
* @v session ONC RPC session | ||
* @v credential ONC RPC credential | ||
* | ||
* The credential parameter must not be NULL, use 'oncrpc_auth_none' if you | ||
* don't want a particular scheme to be used. | ||
*/ | ||
static inline void mount_init_session ( struct oncrpc_session *session, | ||
struct oncrpc_cred *credential ) { | ||
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 ); | ||
int mount_umnt ( struct interface *intf, struct oncrpc_session *session, | ||
const char *mountpoint ); | ||
|
||
int mount_get_mnt_reply ( struct mount_mnt_reply *mnt_reply, | ||
struct oncrpc_reply *reply ); | ||
|
||
#endif /* _IPXE_MOUNT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
#ifndef _IPXE_NFS_H | ||
#define _IPXE_NFS_H | ||
|
||
#include <stdint.h> | ||
#include <ipxe/oncrpc.h> | ||
|
||
/** @file | ||
* | ||
* Network File System protocol. | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
/** NFS protocol number */ | ||
#define ONCRPC_NFS 100003 | ||
|
||
/** NFS protocol version */ | ||
#define NFS_VERS 3 | ||
|
||
/** No error*/ | ||
#define NFS3_OK 0 | ||
/** Not owner */ | ||
#define NFS3ERR_PERM 1 | ||
/** No such file or directory */ | ||
#define NFS3ERR_NOENT 2 | ||
/** I/O error */ | ||
#define NFS3ERR_IO 5 | ||
/** No such device or address */ | ||
#define NFS3ERR_NXIO 6 | ||
/** Permission denied */ | ||
#define NFS3ERR_ACCES 13 | ||
/** The file specified already exists */ | ||
#define NFS3ERR_EXIST 17 | ||
/** Attempt to do a cross-device hard link */ | ||
#define NFS3ERR_XDEV 18 | ||
/** No such device */ | ||
#define NFS3ERR_NODEV 19 | ||
/** Not a directory */ | ||
#define NFS3ERR_NOTDIR 20 | ||
/**Is a directory */ | ||
#define NFS3ERR_ISDIR 21 | ||
/** Invalid argument */ | ||
#define NFS3ERR_INVAL 22 | ||
/** Filename too long */ | ||
#define NFS3ERR_NAMETOOLONG 63 | ||
/** Invalid file handle */ | ||
#define NFS3ERR_STALE 70 | ||
/** Too many levels of remote in path */ | ||
#define NFS3ERR_REMOTE 71 | ||
/** Illegal NFS file handle */ | ||
#define NFS3ERR_BADHANDLE 10001 | ||
/** READDIR or READDIRPLUS cookie is stale */ | ||
#define NFS3ERR_BAD_COOKIE 10003 | ||
/** Operation not supported */ | ||
#define NFS3ERR_NOTSUPP 10004 | ||
/** Buffer or request is too small */ | ||
#define NFS3ERR_TOOSMALL 10005 | ||
/** An error occurred on the server which does not map to any of the legal NFS | ||
* version 3 protocol error values */ | ||
#define NFS3ERR_SERVERFAULT 10006 | ||
/** The server initiated the request, but was not able to complete it in a | ||
* timely fashion */ | ||
#define NFS3ERR_JUKEBOX 10008 | ||
|
||
enum nfs_attr_type { | ||
NFS_ATTR_SYMLINK = 5, | ||
}; | ||
|
||
/** | ||
* A NFS file handle | ||
* | ||
*/ | ||
struct nfs_fh { | ||
uint8_t fh[64]; | ||
size_t size; | ||
}; | ||
|
||
/** | ||
* A NFS LOOKUP reply | ||
* | ||
*/ | ||
struct nfs_lookup_reply { | ||
/** Reply status */ | ||
uint32_t status; | ||
/** Entity type */ | ||
enum nfs_attr_type ent_type; | ||
/** File handle */ | ||
struct nfs_fh fh; | ||
}; | ||
|
||
/** | ||
* A NFS READLINK reply | ||
* | ||
*/ | ||
struct nfs_readlink_reply { | ||
/** Reply status */ | ||
uint32_t status; | ||
/** File path length */ | ||
uint32_t path_len; | ||
/** File path */ | ||
char *path; | ||
}; | ||
|
||
|
||
/** | ||
* A NFS READ reply | ||
* | ||
*/ | ||
struct nfs_read_reply { | ||
/** Reply status */ | ||
uint32_t status; | ||
/** File size */ | ||
uint64_t filesize; | ||
/** Bytes read */ | ||
uint32_t count; | ||
/** End-of-File indicator */ | ||
uint32_t eof; | ||
/** Data length */ | ||
uint32_t data_len; | ||
/** Data read */ | ||
void *data; | ||
}; | ||
|
||
size_t nfs_iob_get_fh ( struct io_buffer *io_buf, struct nfs_fh *fh ); | ||
size_t nfs_iob_add_fh ( struct io_buffer *io_buf, const struct nfs_fh *fh ); | ||
|
||
/** | ||
* Prepare an ONC RPC session to be used as a NFS session | ||
* | ||
* @v session ONC RPC session | ||
* @v credential ONC RPC credential | ||
* | ||
* The credential parameter must not be NULL, use 'oncrpc_auth_none' if you | ||
* don't want a particular scheme to be used. | ||
*/ | ||
static inline void nfs_init_session ( struct oncrpc_session *session, | ||
struct oncrpc_cred *credential ) { | ||
oncrpc_init_session ( session, credential, &oncrpc_auth_none, | ||
ONCRPC_NFS, NFS_VERS ); | ||
} | ||
|
||
int nfs_lookup ( struct interface *intf, struct oncrpc_session *session, | ||
const struct nfs_fh *fh, const char *filename ); | ||
int nfs_readlink ( struct interface *intf, struct oncrpc_session *session, | ||
const struct nfs_fh *fh ); | ||
int nfs_read ( struct interface *intf, struct oncrpc_session *session, | ||
const struct nfs_fh *fh, uint64_t offset, uint32_t count ); | ||
|
||
int nfs_get_lookup_reply ( struct nfs_lookup_reply *lookup_reply, | ||
struct oncrpc_reply *reply ); | ||
int nfs_get_readlink_reply ( struct nfs_readlink_reply *readlink_reply, | ||
struct oncrpc_reply *reply ); | ||
int nfs_get_read_reply ( struct nfs_read_reply *read_reply, | ||
struct oncrpc_reply *reply ); | ||
|
||
#endif /* _IPXE_NFS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _IPXE_NFS_OPEN_H | ||
#define _IPXE_NFS_OPEN_H | ||
|
||
/** @file | ||
* | ||
* Network File System protocol. | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#endif /* _IPXE_NFS_OPEN_H */ |
Oops, something went wrong.