Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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