iPXE
Data Structures | Macros | Enumerations | Functions
nfs.h File Reference

Network File System protocol. More...

#include <stdint.h>
#include <ipxe/oncrpc.h>

Go to the source code of this file.

Data Structures

struct  nfs_fh
 A NFS file handle. More...
 
struct  nfs_lookup_reply
 A NFS LOOKUP reply. More...
 
struct  nfs_readlink_reply
 A NFS READLINK reply. More...
 
struct  nfs_read_reply
 A NFS READ reply. More...
 

Macros

#define ONCRPC_NFS   100003
 NFS protocol number. More...
 
#define NFS_VERS   3
 NFS protocol version. More...
 
#define NFS3_OK   0
 No error. More...
 
#define NFS3ERR_PERM   1
 Not owner. More...
 
#define NFS3ERR_NOENT   2
 No such file or directory. More...
 
#define NFS3ERR_IO   5
 I/O error. More...
 
#define NFS3ERR_NXIO   6
 No such device or address. More...
 
#define NFS3ERR_ACCES   13
 Permission denied. More...
 
#define NFS3ERR_EXIST   17
 The file specified already exists. More...
 
#define NFS3ERR_XDEV   18
 Attempt to do a cross-device hard link. More...
 
#define NFS3ERR_NODEV   19
 No such device. More...
 
#define NFS3ERR_NOTDIR   20
 Not a directory. More...
 
#define NFS3ERR_ISDIR   21
 Is a directory. More...
 
#define NFS3ERR_INVAL   22
 Invalid argument. More...
 
#define NFS3ERR_NAMETOOLONG   63
 Filename too long. More...
 
#define NFS3ERR_STALE   70
 Invalid file handle. More...
 
#define NFS3ERR_REMOTE   71
 Too many levels of remote in path. More...
 
#define NFS3ERR_BADHANDLE   10001
 Illegal NFS file handle. More...
 
#define NFS3ERR_BAD_COOKIE   10003
 READDIR or READDIRPLUS cookie is stale. More...
 
#define NFS3ERR_NOTSUPP   10004
 Operation not supported. More...
 
#define NFS3ERR_TOOSMALL   10005
 Buffer or request is too small. More...
 
#define NFS3ERR_SERVERFAULT   10006
 An error occurred on the server which does not map to any of the legal NFS version 3 protocol error values. More...
 
#define NFS3ERR_JUKEBOX   10008
 The server initiated the request, but was not able to complete it in a timely fashion. More...
 

Enumerations

enum  nfs_attr_type { NFS_ATTR_SYMLINK = 5 }
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
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. More...
 
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. More...
 
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. More...
 
int nfs_lookup (struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh, const char *filename)
 Send a LOOKUP request. More...
 
int nfs_readlink (struct interface *intf, struct oncrpc_session *session, const struct nfs_fh *fh)
 Send a READLINK request. More...
 
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. More...
 
int nfs_get_lookup_reply (struct nfs_lookup_reply *lookup_reply, struct oncrpc_reply *reply)
 Parse a LOOKUP reply. More...
 
int nfs_get_readlink_reply (struct nfs_readlink_reply *readlink_reply, struct oncrpc_reply *reply)
 Parse a READLINK reply. More...
 
int nfs_get_read_reply (struct nfs_read_reply *read_reply, struct oncrpc_reply *reply)
 Parse a READ reply. More...
 

Detailed Description

Network File System protocol.

Definition in file nfs.h.

Macro Definition Documentation

◆ ONCRPC_NFS

#define ONCRPC_NFS   100003

NFS protocol number.

Definition at line 16 of file nfs.h.

◆ NFS_VERS

#define NFS_VERS   3

NFS protocol version.

Definition at line 19 of file nfs.h.

◆ NFS3_OK

#define NFS3_OK   0

No error.

Definition at line 22 of file nfs.h.

◆ NFS3ERR_PERM

#define NFS3ERR_PERM   1

Not owner.

Definition at line 24 of file nfs.h.

◆ NFS3ERR_NOENT

#define NFS3ERR_NOENT   2

No such file or directory.

Definition at line 26 of file nfs.h.

◆ NFS3ERR_IO

#define NFS3ERR_IO   5

I/O error.

Definition at line 28 of file nfs.h.

◆ NFS3ERR_NXIO

#define NFS3ERR_NXIO   6

No such device or address.

Definition at line 30 of file nfs.h.

◆ NFS3ERR_ACCES

#define NFS3ERR_ACCES   13

Permission denied.

Definition at line 32 of file nfs.h.

◆ NFS3ERR_EXIST

#define NFS3ERR_EXIST   17

The file specified already exists.

Definition at line 34 of file nfs.h.

◆ NFS3ERR_XDEV

#define NFS3ERR_XDEV   18

Attempt to do a cross-device hard link.

Definition at line 36 of file nfs.h.

◆ NFS3ERR_NODEV

#define NFS3ERR_NODEV   19

No such device.

Definition at line 38 of file nfs.h.

◆ NFS3ERR_NOTDIR

#define NFS3ERR_NOTDIR   20

Not a directory.

Definition at line 40 of file nfs.h.

◆ NFS3ERR_ISDIR

#define NFS3ERR_ISDIR   21

Is a directory.

Definition at line 42 of file nfs.h.

◆ NFS3ERR_INVAL

#define NFS3ERR_INVAL   22

Invalid argument.

Definition at line 44 of file nfs.h.

◆ NFS3ERR_NAMETOOLONG

#define NFS3ERR_NAMETOOLONG   63

Filename too long.

Definition at line 46 of file nfs.h.

◆ NFS3ERR_STALE

#define NFS3ERR_STALE   70

Invalid file handle.

Definition at line 48 of file nfs.h.

◆ NFS3ERR_REMOTE

#define NFS3ERR_REMOTE   71

Too many levels of remote in path.

Definition at line 50 of file nfs.h.

◆ NFS3ERR_BADHANDLE

#define NFS3ERR_BADHANDLE   10001

Illegal NFS file handle.

Definition at line 52 of file nfs.h.

◆ NFS3ERR_BAD_COOKIE

#define NFS3ERR_BAD_COOKIE   10003

READDIR or READDIRPLUS cookie is stale.

Definition at line 54 of file nfs.h.

◆ NFS3ERR_NOTSUPP

#define NFS3ERR_NOTSUPP   10004

Operation not supported.

Definition at line 56 of file nfs.h.

◆ NFS3ERR_TOOSMALL

#define NFS3ERR_TOOSMALL   10005

Buffer or request is too small.

Definition at line 58 of file nfs.h.

◆ NFS3ERR_SERVERFAULT

#define NFS3ERR_SERVERFAULT   10006

An error occurred on the server which does not map to any of the legal NFS version 3 protocol error values.

Definition at line 61 of file nfs.h.

◆ NFS3ERR_JUKEBOX

#define NFS3ERR_JUKEBOX   10008

The server initiated the request, but was not able to complete it in a timely fashion.

Definition at line 64 of file nfs.h.

Enumeration Type Documentation

◆ nfs_attr_type

Enumerator
NFS_ATTR_SYMLINK 

Definition at line 66 of file nfs.h.

66  {
67  NFS_ATTR_SYMLINK = 5,
68 };

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ nfs_iob_get_fh()

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.

Parameters
io_bufI/O buffer
fhFile handle
Return values
sizeSize of the data read

Definition at line 59 of file nfs.c.

59  {
60  fh->size = oncrpc_iob_get_int ( io_buf );
61 
62  if ( fh->size > 64 )
63  return sizeof ( uint32_t );
64 
65  memcpy (fh->fh, io_buf->data, fh->size );
66  iob_pull ( io_buf, fh->size );
67 
68  return fh->size + sizeof ( uint32_t );
69 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
uint8_t fh[64]
Definition: nfs.h:75
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define oncrpc_iob_get_int(buf)
Get a 32 bits integer from the beginning of an I/O buffer.
Definition: oncrpc_iob.h:38
size_t size
Definition: nfs.h:76
unsigned int uint32_t
Definition: stdint.h:12
void * data
Start of data.
Definition: iobuf.h:48

References io_buffer::data, nfs_fh::fh, iob_pull, memcpy(), oncrpc_iob_get_int, and nfs_fh::size.

Referenced by mount_get_mnt_reply(), and nfs_get_lookup_reply().

◆ nfs_iob_add_fh()

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.

Parameters
io_bufI/O buffer
fhFile handle
Return values
sizeSize of the data written

Definition at line 78 of file nfs.c.

78  {
79  size_t s;
80 
81  s = oncrpc_iob_add_int ( io_buf, fh->size );
82  memcpy ( iob_put ( io_buf, fh->size ), &fh->fh, fh->size );
83 
84  return s + fh->size;
85 }
#define iob_put(iobuf, len)
Definition: iobuf.h:120
uint8_t fh[64]
Definition: nfs.h:75
void * memcpy(void *dest, const void *src, size_t len) __nonnull
size_t size
Definition: nfs.h:76
static size_t oncrpc_iob_add_int(struct io_buffer *io_buf, uint32_t val)
Add a 32 bits integer to the end of an I/O buffer.
Definition: oncrpc_iob.h:83

References nfs_fh::fh, iob_put, memcpy(), oncrpc_iob_add_int(), and nfs_fh::size.

◆ nfs_init_session()

static void nfs_init_session ( struct oncrpc_session session,
struct oncrpc_cred credential 
)
inlinestatic

Prepare an ONC RPC session to be used as a NFS 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 137 of file nfs.h.

138  {
140  ONCRPC_NFS, NFS_VERS );
141 }
#define ONCRPC_NFS
NFS protocol number.
Definition: nfs.h:16
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
struct ntlm_data session
Session key.
Definition: ntlm.h:24
struct oncrpc_cred oncrpc_auth_none
AUTH NONE authentication flavor.
Definition: oncrpc.c:56

References NFS_VERS, oncrpc_auth_none, oncrpc_init_session(), ONCRPC_NFS, and session.

Referenced by nfs_open().

◆ nfs_lookup()

int nfs_lookup ( struct interface intf,
struct oncrpc_session session,
const struct nfs_fh fh,
const char *  filename 
)

Send a LOOKUP request.

Parameters
intfInterface to send the request on
sessionONC RPC session
fhThe file handle of the the directory
filenameThe file name
Return values
rcReturn status code

Definition at line 96 of file nfs.c.

97  {
98  struct oncrpc_field fields[] = {
99  ONCRPC_SUBFIELD ( array, fh->size, &fh->fh ),
100  ONCRPC_FIELD ( str, filename ),
102  };
103 
104  return oncrpc_call ( intf, session, NFS_LOOKUP, fields );
105 }
#define ONCRPC_FIELD(type, value)
Definition: oncrpc.h:28
#define NFS_LOOKUP
NFS LOOKUP procedure.
Definition: nfs.c:46
uint8_t fh[64]
Definition: nfs.h:75
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
size_t size
Definition: nfs.h:76
uint32_t array
Array number.
Definition: edd.h:30
struct ntlm_data session
Session key.
Definition: ntlm.h:24
#define ONCRPC_SUBFIELD(type, args...)
Definition: oncrpc.h:29
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32

References array, nfs_fh::fh, NFS_LOOKUP, oncrpc_call(), ONCRPC_FIELD, ONCRPC_FIELD_END, ONCRPC_SUBFIELD, session, and nfs_fh::size.

Referenced by nfs_step().

◆ nfs_readlink()

int nfs_readlink ( struct interface intf,
struct oncrpc_session session,
const struct nfs_fh fh 
)

Send a READLINK request.

Parameters
intfInterface to send the request on
sessionONC RPC session
fhThe symlink file handle
Return values
rcReturn status code

Definition at line 115 of file nfs.c.

116  {
117  struct oncrpc_field fields[] = {
118  ONCRPC_SUBFIELD ( array, fh->size, &fh->fh ),
120  };
121 
122  return oncrpc_call ( intf, session, NFS_READLINK, fields );
123 }
uint8_t fh[64]
Definition: nfs.h:75
#define NFS_READLINK
NFS READLINK procedure.
Definition: nfs.c:48
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
size_t size
Definition: nfs.h:76
uint32_t array
Array number.
Definition: edd.h:30
struct ntlm_data session
Session key.
Definition: ntlm.h:24
#define ONCRPC_SUBFIELD(type, args...)
Definition: oncrpc.h:29
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32

References array, nfs_fh::fh, NFS_READLINK, oncrpc_call(), ONCRPC_FIELD_END, ONCRPC_SUBFIELD, session, and nfs_fh::size.

Referenced by nfs_step().

◆ nfs_read()

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.

Parameters
intfInterface to send the request on
sessionONC RPC session
fhThe file handle
offsetOffset
countByte count
Return values
rcReturn status code

Definition at line 135 of file nfs.c.

136  {
137  struct oncrpc_field fields[] = {
138  ONCRPC_SUBFIELD ( array, fh->size, &fh->fh ),
140  ONCRPC_FIELD ( int32, count ),
142  };
143 
144  return oncrpc_call ( intf, session, NFS_READ, fields );
145 }
#define ONCRPC_FIELD(type, value)
Definition: oncrpc.h:28
uint8_t fh[64]
Definition: nfs.h:75
int oncrpc_call(struct interface *intf, struct oncrpc_session *session, uint32_t proc_name, const struct oncrpc_field fields[])
Definition: oncrpc.c:129
int64_t int64
Definition: stdint.h:33
size_t size
Definition: nfs.h:76
uint32_t array
Array number.
Definition: edd.h:30
int32_t int32
Definition: stdint.h:31
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
#define ONCRPC_SUBFIELD(type, args...)
Definition: oncrpc.h:29
#define ONCRPC_FIELD_END
Definition: oncrpc.h:32
uint16_t count
Number of entries.
Definition: ena.h:22
#define NFS_READ
NFS READ procedure.
Definition: nfs.c:50

References array, count, nfs_fh::fh, NFS_READ, offset, oncrpc_call(), ONCRPC_FIELD, ONCRPC_FIELD_END, ONCRPC_SUBFIELD, session, and nfs_fh::size.

Referenced by nfs_step().

◆ nfs_get_lookup_reply()

int nfs_get_lookup_reply ( struct nfs_lookup_reply lookup_reply,
struct oncrpc_reply reply 
)

Parse a LOOKUP reply.

Parameters
lookup_replyA structure where the data will be saved
replyThe ONC RPC reply to get data from
Return values
rcReturn status code

Definition at line 154 of file nfs.c.

155  {
156  if ( ! lookup_reply || ! reply )
157  return -EINVAL;
158 
159  lookup_reply->status = oncrpc_iob_get_int ( reply->data );
160  switch ( lookup_reply->status )
161  {
162  case NFS3_OK:
163  break;
164  case NFS3ERR_PERM:
165  return -EPERM;
166  case NFS3ERR_NOENT:
167  return -ENOENT;
168  case NFS3ERR_IO:
169  return -EIO;
170  case NFS3ERR_ACCES:
171  return -EACCES;
172  case NFS3ERR_NOTDIR:
173  return -ENOTDIR;
174  case NFS3ERR_NAMETOOLONG:
175  return -ENAMETOOLONG;
176  case NFS3ERR_STALE:
177  return -ESTALE;
178  case NFS3ERR_BADHANDLE:
179  case NFS3ERR_SERVERFAULT:
180  default:
181  return -EPROTO;
182  }
183 
184  nfs_iob_get_fh ( reply->data, &lookup_reply->fh );
185 
186  if ( oncrpc_iob_get_int ( reply->data ) == 1 )
187  lookup_reply->ent_type = oncrpc_iob_get_int ( reply->data );
188 
189  return 0;
190 }
#define NFS3ERR_NAMETOOLONG
Filename too long.
Definition: nfs.h:46
#define EINVAL
Invalid argument.
Definition: errno.h:428
uint32_t status
Reply status.
Definition: nfs.h:85
#define NFS3_OK
No error.
Definition: nfs.h:22
struct nfs_fh fh
File handle.
Definition: nfs.h:89
#define ENOENT
No such file or directory.
Definition: errno.h:514
#define EACCES
Permission denied.
Definition: errno.h:298
enum nfs_attr_type ent_type
Entity type.
Definition: nfs.h:87
#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 NFS3ERR_SERVERFAULT
An error occurred on the server which does not map to any of the legal NFS version 3 protocol error v...
Definition: nfs.h:61
#define NFS3ERR_PERM
Not owner.
Definition: nfs.h:24
#define ENOTDIR
Not a directory.
Definition: errno.h:574
#define EPROTO
Protocol error.
Definition: errno.h:624
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 NFS3ERR_IO
I/O error.
Definition: nfs.h:28
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define NFS3ERR_NOENT
No such file or directory.
Definition: nfs.h:26
#define EIO
Input/output error.
Definition: errno.h:433
#define NFS3ERR_BADHANDLE
Illegal NFS file handle.
Definition: nfs.h:52
#define ENAMETOOLONG
Filename too long.
Definition: errno.h:473
#define NFS3ERR_STALE
Invalid file handle.
Definition: nfs.h:48
#define ESTALE
Stale file handle.
Definition: errno.h:659
#define NFS3ERR_ACCES
Permission denied.
Definition: nfs.h:32
struct io_buffer * data
Definition: oncrpc.h:68
#define NFS3ERR_NOTDIR
Not a directory.
Definition: nfs.h:40

References oncrpc_reply::data, EACCES, EINVAL, EIO, ENAMETOOLONG, ENOENT, ENOTDIR, nfs_lookup_reply::ent_type, EPERM, EPROTO, ESTALE, nfs_lookup_reply::fh, NFS3_OK, NFS3ERR_ACCES, NFS3ERR_BADHANDLE, NFS3ERR_IO, NFS3ERR_NAMETOOLONG, NFS3ERR_NOENT, NFS3ERR_NOTDIR, NFS3ERR_PERM, NFS3ERR_SERVERFAULT, NFS3ERR_STALE, nfs_iob_get_fh(), oncrpc_iob_get_int, and nfs_lookup_reply::status.

Referenced by nfs_deliver().

◆ nfs_get_readlink_reply()

int nfs_get_readlink_reply ( struct nfs_readlink_reply readlink_reply,
struct oncrpc_reply reply 
)

Parse a READLINK reply.

Parameters
readlink_replyA structure where the data will be saved
replyThe ONC RPC reply to get data from
Return values
rcReturn status code

Definition at line 198 of file nfs.c.

199  {
200  if ( ! readlink_reply || ! reply )
201  return -EINVAL;
202 
203  readlink_reply->status = oncrpc_iob_get_int ( reply->data );
204  switch ( readlink_reply->status )
205  {
206  case NFS3_OK:
207  break;
208  case NFS3ERR_IO:
209  return -EIO;
210  case NFS3ERR_ACCES:
211  return -EACCES;
212  case NFS3ERR_INVAL:
213  return -EINVAL;
214  case NFS3ERR_NOTSUPP:
215  return -ENOTSUP;
216  case NFS3ERR_STALE:
217  return -ESTALE;
218  case NFS3ERR_BADHANDLE:
219  case NFS3ERR_SERVERFAULT:
220  default:
221  return -EPROTO;
222  }
223 
224  if ( oncrpc_iob_get_int ( reply->data ) == 1 )
225  iob_pull ( reply->data, 5 * sizeof ( uint32_t ) +
226  8 * sizeof ( uint64_t ) );
227 
228  readlink_reply->path_len = oncrpc_iob_get_int ( reply->data );
229  readlink_reply->path = reply->data->data;
230 
231  return 0;
232 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define NFS3_OK
No error.
Definition: nfs.h:22
unsigned long long uint64_t
Definition: stdint.h:13
#define EACCES
Permission denied.
Definition: errno.h:298
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#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 NFS3ERR_SERVERFAULT
An error occurred on the server which does not map to any of the legal NFS version 3 protocol error v...
Definition: nfs.h:61
#define EPROTO
Protocol error.
Definition: errno.h:624
#define NFS3ERR_IO
I/O error.
Definition: nfs.h:28
#define NFS3ERR_NOTSUPP
Operation not supported.
Definition: nfs.h:56
unsigned int uint32_t
Definition: stdint.h:12
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
#define NFS3ERR_BADHANDLE
Illegal NFS file handle.
Definition: nfs.h:52
#define NFS3ERR_STALE
Invalid file handle.
Definition: nfs.h:48
#define NFS3ERR_INVAL
Invalid argument.
Definition: nfs.h:44
#define ESTALE
Stale file handle.
Definition: errno.h:659
#define NFS3ERR_ACCES
Permission denied.
Definition: nfs.h:32
struct io_buffer * data
Definition: oncrpc.h:68

References io_buffer::data, oncrpc_reply::data, EACCES, EINVAL, EIO, ENOTSUP, EPROTO, ESTALE, iob_pull, NFS3_OK, NFS3ERR_ACCES, NFS3ERR_BADHANDLE, NFS3ERR_INVAL, NFS3ERR_IO, NFS3ERR_NOTSUPP, NFS3ERR_SERVERFAULT, NFS3ERR_STALE, oncrpc_iob_get_int, nfs_readlink_reply::path, nfs_readlink_reply::path_len, and nfs_readlink_reply::status.

Referenced by nfs_deliver().

◆ nfs_get_read_reply()

int nfs_get_read_reply ( struct nfs_read_reply read_reply,
struct oncrpc_reply reply 
)

Parse a READ reply.

Parameters
read_replyA structure where the data will be saved
replyThe ONC RPC reply to get data from
Return values
rcReturn status code

Definition at line 241 of file nfs.c.

242  {
243  if ( ! read_reply || ! reply )
244  return -EINVAL;
245 
246  read_reply->status = oncrpc_iob_get_int ( reply->data );
247  switch ( read_reply->status )
248  {
249  case NFS3_OK:
250  break;
251  case NFS3ERR_PERM:
252  return -EPERM;
253  case NFS3ERR_NOENT:
254  return -ENOENT;
255  case NFS3ERR_IO:
256  return -EIO;
257  case NFS3ERR_NXIO:
258  return -ENXIO;
259  case NFS3ERR_ACCES:
260  return -EACCES;
261  case NFS3ERR_INVAL:
262  return -EINVAL;
263  case NFS3ERR_STALE:
264  return -ESTALE;
265  case NFS3ERR_BADHANDLE:
266  case NFS3ERR_SERVERFAULT:
267  default:
268  return -EPROTO;
269  }
270 
271  if ( oncrpc_iob_get_int ( reply->data ) == 1 )
272  {
273  iob_pull ( reply->data, 5 * sizeof ( uint32_t ) );
274  read_reply->filesize = oncrpc_iob_get_int64 ( reply->data );
275  iob_pull ( reply->data, 7 * sizeof ( uint64_t ) );
276  }
277 
278  read_reply->count = oncrpc_iob_get_int ( reply->data );
279  read_reply->eof = oncrpc_iob_get_int ( reply->data );
280  read_reply->data_len = oncrpc_iob_get_int ( reply->data );
281  read_reply->data = reply->data->data;
282 
283  if ( read_reply->count != read_reply->data_len )
284  return -EPROTO;
285 
286  return 0;
287 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
uint32_t status
Reply status.
Definition: nfs.h:112
uint32_t count
Bytes read.
Definition: nfs.h:116
#define oncrpc_iob_get_int64(buf)
Get a 64 bits integer from the beginning of an I/O buffer.
Definition: oncrpc_iob.h:52
#define NFS3_OK
No error.
Definition: nfs.h:22
#define ENOENT
No such file or directory.
Definition: errno.h:514
unsigned long long uint64_t
Definition: stdint.h:13
#define EACCES
Permission denied.
Definition: errno.h:298
uint32_t eof
End-of-File indicator.
Definition: nfs.h:118
#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 NFS3ERR_SERVERFAULT
An error occurred on the server which does not map to any of the legal NFS version 3 protocol error v...
Definition: nfs.h:61
#define NFS3ERR_PERM
Not owner.
Definition: nfs.h:24
#define EPROTO
Protocol error.
Definition: errno.h:624
#define NFS3ERR_NXIO
No such device or address.
Definition: nfs.h:30
uint32_t data_len
Data length.
Definition: nfs.h:120
#define NFS3ERR_IO
I/O error.
Definition: nfs.h:28
unsigned int uint32_t
Definition: stdint.h:12
#define EPERM
Operation not permitted.
Definition: errno.h:614
#define ENXIO
No such device or address.
Definition: errno.h:599
#define NFS3ERR_NOENT
No such file or directory.
Definition: nfs.h:26
void * data
Start of data.
Definition: iobuf.h:48
#define EIO
Input/output error.
Definition: errno.h:433
#define NFS3ERR_BADHANDLE
Illegal NFS file handle.
Definition: nfs.h:52
#define NFS3ERR_STALE
Invalid file handle.
Definition: nfs.h:48
void * data
Data read.
Definition: nfs.h:122
#define NFS3ERR_INVAL
Invalid argument.
Definition: nfs.h:44
#define ESTALE
Stale file handle.
Definition: errno.h:659
#define NFS3ERR_ACCES
Permission denied.
Definition: nfs.h:32
struct io_buffer * data
Definition: oncrpc.h:68
uint64_t filesize
File size.
Definition: nfs.h:114

References nfs_read_reply::count, io_buffer::data, oncrpc_reply::data, nfs_read_reply::data, nfs_read_reply::data_len, EACCES, EINVAL, EIO, ENOENT, ENXIO, nfs_read_reply::eof, EPERM, EPROTO, ESTALE, nfs_read_reply::filesize, iob_pull, NFS3_OK, NFS3ERR_ACCES, NFS3ERR_BADHANDLE, NFS3ERR_INVAL, NFS3ERR_IO, NFS3ERR_NOENT, NFS3ERR_NXIO, NFS3ERR_PERM, NFS3ERR_SERVERFAULT, NFS3ERR_STALE, oncrpc_iob_get_int, oncrpc_iob_get_int64, and nfs_read_reply::status.

Referenced by nfs_deliver().