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 
13 FILE_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 
68 };
69 
70 /**
71  * A NFS file handle
72  *
73  */
74 struct nfs_fh {
75  uint8_t fh[64];
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 
125 size_t nfs_iob_get_fh ( struct io_buffer *io_buf, struct nfs_fh *fh );
126 size_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  */
137 static inline void nfs_init_session ( struct oncrpc_session *session,
138  struct oncrpc_cred *credential ) {
140  ONCRPC_NFS, NFS_VERS );
141 }
142 
143 int nfs_lookup ( struct interface *intf, struct oncrpc_session *session,
144  const struct nfs_fh *fh, const char *filename );
145 int nfs_readlink ( struct interface *intf, struct oncrpc_session *session,
146  const struct nfs_fh *fh );
147 int nfs_read ( struct interface *intf, struct oncrpc_session *session,
148  const struct nfs_fh *fh, uint64_t offset, uint32_t count );
149 
150 int nfs_get_lookup_reply ( struct nfs_lookup_reply *lookup_reply,
151  struct oncrpc_reply *reply );
152 int nfs_get_readlink_reply ( struct nfs_readlink_reply *readlink_reply,
153  struct oncrpc_reply *reply );
154 int nfs_get_read_reply ( struct nfs_read_reply *read_reply,
155  struct oncrpc_reply *reply );
156 
157 #endif /* _IPXE_NFS_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t status
Reply status.
Definition: nfs.h:85
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:78
uint32_t status
Reply status.
Definition: nfs.h:112
#define ONCRPC_NFS
NFS protocol number.
Definition: nfs.h:16
A NFS file handle.
Definition: nfs.h:74
uint32_t count
Bytes read.
Definition: nfs.h:116
uint8_t fh[64]
Definition: nfs.h:75
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
struct nfs_fh fh
File handle.
Definition: nfs.h:89
unsigned long long uint64_t
Definition: stdint.h:13
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
#define NFS_VERS
NFS protocol version.
Definition: nfs.h:19
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
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:96
int nfs_get_lookup_reply(struct nfs_lookup_reply *lookup_reply, struct oncrpc_reply *reply)
Parse a LOOKUP reply.
Definition: nfs.c:154
uint32_t eof
End-of-File indicator.
Definition: nfs.h:118
A NFS LOOKUP reply.
Definition: nfs.h:83
enum nfs_attr_type ent_type
Entity type.
Definition: nfs.h:87
size_t size
Definition: nfs.h:76
nfs_attr_type
Definition: nfs.h:66
An object interface.
Definition: interface.h:124
struct ntlm_data session
Session key.
Definition: ntlm.h:24
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
int nfs_get_read_reply(struct nfs_read_reply *read_reply, struct oncrpc_reply *reply)
Parse a READ reply.
Definition: nfs.c:241
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition: oncrpc.c:56
uint32_t data_len
Data length.
Definition: nfs.h:120
A NFS READ reply.
Definition: nfs.h:110
unsigned char uint8_t
Definition: stdint.h:10
unsigned int uint32_t
Definition: stdint.h:12
uint16_t count
Number of entries.
Definition: ena.h:22
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:135
int nfs_get_readlink_reply(struct nfs_readlink_reply *readlink_reply, struct oncrpc_reply *reply)
Parse a READLINK reply.
Definition: nfs.c:198
void * data
Data read.
Definition: nfs.h:122
int nfs_readlink(struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh)
Send a READLINK request.
Definition: nfs.c:115
SUN ONC RPC protocol.
uint64_t filesize
File size.
Definition: nfs.h:114
A persistent I/O buffer.
Definition: iobuf.h:33