iPXE
nfs.h
Go to the documentation of this file.
1#ifndef _IPXE_NFS_H
2#define _IPXE_NFS_H
3
4#include <stdint.h>
5#include <ipxe/oncrpc.h>
6
7/** @file
8 *
9 * Network File System protocol.
10 *
11 */
12
13FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14
15/** NFS protocol number */
16#define ONCRPC_NFS 100003
17
18/** NFS protocol version */
19#define NFS_VERS 3
20
21/** No error*/
22#define NFS3_OK 0
23/** Not owner */
24#define NFS3ERR_PERM 1
25/** No such file or directory */
26#define NFS3ERR_NOENT 2
27/** I/O error */
28#define NFS3ERR_IO 5
29/** No such device or address */
30#define NFS3ERR_NXIO 6
31/** Permission denied */
32#define NFS3ERR_ACCES 13
33/** The file specified already exists */
34#define NFS3ERR_EXIST 17
35/** Attempt to do a cross-device hard link */
36#define NFS3ERR_XDEV 18
37/** No such device */
38#define NFS3ERR_NODEV 19
39/** Not a directory */
40#define NFS3ERR_NOTDIR 20
41 /**Is a directory */
42#define NFS3ERR_ISDIR 21
43/** Invalid argument */
44#define NFS3ERR_INVAL 22
45/** Filename too long */
46#define NFS3ERR_NAMETOOLONG 63
47/** Invalid file handle */
48#define NFS3ERR_STALE 70
49/** Too many levels of remote in path */
50#define NFS3ERR_REMOTE 71
51/** Illegal NFS file handle */
52#define NFS3ERR_BADHANDLE 10001
53/** READDIR or READDIRPLUS cookie is stale */
54#define NFS3ERR_BAD_COOKIE 10003
55/** Operation not supported */
56#define NFS3ERR_NOTSUPP 10004
57/** Buffer or request is too small */
58#define NFS3ERR_TOOSMALL 10005
59/** An error occurred on the server which does not map to any of the legal NFS
60 * version 3 protocol error values */
61#define NFS3ERR_SERVERFAULT 10006
62/** The server initiated the request, but was not able to complete it in a
63 * timely fashion */
64#define NFS3ERR_JUKEBOX 10008
65
69
70/**
71 * A NFS file handle
72 *
73 */
74struct nfs_fh {
76 size_t size;
77};
78
79/**
80 * A NFS LOOKUP reply
81 *
82 */
84 /** Reply status */
86 /** Entity type */
88 /** File handle */
89 struct nfs_fh fh;
90};
91
92/**
93 * A NFS READLINK reply
94 *
95 */
97 /** Reply status */
99 /** File path length */
101 /** File path */
102 char *path;
103};
104
105
106/**
107 * A NFS READ reply
108 *
109 */
111 /** Reply status */
113 /** File size */
115 /** Bytes read */
117 /** End-of-File indicator */
119 /** Data length */
121 /** Data read */
122 void *data;
123};
124
125size_t nfs_iob_get_fh ( struct io_buffer *io_buf, struct nfs_fh *fh );
126size_t nfs_iob_add_fh ( struct io_buffer *io_buf, const struct nfs_fh *fh );
127
128/**
129 * Prepare an ONC RPC session to be used as a NFS session
130 *
131 * @v session ONC RPC session
132 * @v credential ONC RPC credential
133 *
134 * The credential parameter must not be NULL, use 'oncrpc_auth_none' if you
135 * don't want a particular scheme to be used.
136 */
137static inline void nfs_init_session ( struct oncrpc_session *session,
138 struct oncrpc_cred *credential ) {
139 oncrpc_init_session ( session, credential, &oncrpc_auth_none,
141}
142
143int nfs_lookup ( struct interface *intf, struct oncrpc_session *session,
144 const struct nfs_fh *fh, const char *filename );
145int nfs_readlink ( struct interface *intf, struct oncrpc_session *session,
146 const struct nfs_fh *fh );
147int nfs_read ( struct interface *intf, struct oncrpc_session *session,
148 const struct nfs_fh *fh, uint64_t offset, uint32_t count );
149
150int nfs_get_lookup_reply ( struct nfs_lookup_reply *lookup_reply,
151 struct oncrpc_reply *reply );
152int nfs_get_readlink_reply ( struct nfs_readlink_reply *readlink_reply,
153 struct oncrpc_reply *reply );
154int nfs_get_read_reply ( struct nfs_read_reply *read_reply,
155 struct oncrpc_reply *reply );
156
157#endif /* _IPXE_NFS_H */
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
uint16_t offset
Offset to command line.
Definition bzimage.h:3
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
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
int nfs_get_read_reply(struct nfs_read_reply *read_reply, struct oncrpc_reply *reply)
Parse a READ reply.
Definition nfs.c:243
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.
Definition nfs.h:137
int nfs_get_lookup_reply(struct nfs_lookup_reply *lookup_reply, struct oncrpc_reply *reply)
Parse a LOOKUP reply.
Definition nfs.c:156
int nfs_readlink(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh)
Send a READLINK request.
Definition nfs.c:117
#define ONCRPC_NFS
NFS protocol number.
Definition nfs.h:16
#define NFS_VERS
NFS protocol version.
Definition nfs.h:19
nfs_attr_type
Definition nfs.h:66
@ NFS_ATTR_SYMLINK
Definition nfs.h:67
size_t nfs_iob_add_fh(struct io_buffer *io_buf, const struct nfs_fh *fh)
Add a file handle to the end of an I/O buffer.
Definition nfs.c:80
int nfs_lookup(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh, const char *filename)
Send a LOOKUP request.
Definition nfs.c:98
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.
Definition nfs.c:137
int nfs_get_readlink_reply(struct nfs_readlink_reply *readlink_reply, struct oncrpc_reply *reply)
Parse a READLINK reply.
Definition nfs.c:200
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
SUN ONC RPC protocol.
An object interface.
Definition interface.h:125
A persistent I/O buffer.
Definition iobuf.h:38
A NFS file handle.
Definition nfs.h:74
uint8_t fh[64]
Definition nfs.h:75
size_t size
Definition nfs.h:76
A NFS LOOKUP reply.
Definition nfs.h:83
enum nfs_attr_type ent_type
Entity type.
Definition nfs.h:87
struct nfs_fh fh
File handle.
Definition nfs.h:89
uint32_t status
Reply status.
Definition nfs.h:85
A NFS READ reply.
Definition nfs.h:110
uint32_t count
Bytes read.
Definition nfs.h:116
uint32_t status
Reply status.
Definition nfs.h:112
uint32_t data_len
Data length.
Definition nfs.h:120
void * data
Data read.
Definition nfs.h:122
uint32_t eof
End-of-File indicator.
Definition nfs.h:118
uint64_t filesize
File size.
Definition nfs.h:114