nfs.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * (C) Masami Komiya <mkomiya@sonare.it> 2004
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __NFS_H__
  7. #define __NFS_H__
  8. #define SUNRPC_PORT 111
  9. #define PROG_PORTMAP 100000
  10. #define PROG_NFS 100003
  11. #define PROG_MOUNT 100005
  12. #define MSG_CALL 0
  13. #define MSG_REPLY 1
  14. #define PORTMAP_GETPORT 3
  15. #define MOUNT_ADDENTRY 1
  16. #define MOUNT_UMOUNTALL 4
  17. #define NFS_LOOKUP 4
  18. #define NFS_READLINK 5
  19. #define NFS_READ 6
  20. #define NFS3PROC_LOOKUP 3
  21. #define NFS_FHSIZE 32
  22. #define NFS3_FHSIZE 64
  23. #define NFSERR_PERM 1
  24. #define NFSERR_NOENT 2
  25. #define NFSERR_ACCES 13
  26. #define NFSERR_ISDIR 21
  27. #define NFSERR_INVAL 22
  28. /* Block size used for NFS read accesses. A RPC reply packet (including all
  29. * headers) must fit within a single Ethernet frame to avoid fragmentation.
  30. * However, if CONFIG_IP_DEFRAG is set, the config file may want to use a
  31. * bigger value. In any case, most NFS servers are optimized for a power of 2.
  32. */
  33. #ifdef CONFIG_NFS_READ_SIZE
  34. #define NFS_READ_SIZE CONFIG_NFS_READ_SIZE
  35. #else
  36. #define NFS_READ_SIZE 1024 /* biggest power of two that fits Ether frame */
  37. #endif
  38. /* Values for Accept State flag on RPC answers (See: rfc1831) */
  39. enum rpc_accept_stat {
  40. NFS_RPC_SUCCESS = 0, /* RPC executed successfully */
  41. NFS_RPC_PROG_UNAVAIL = 1, /* remote hasn't exported program */
  42. NFS_RPC_PROG_MISMATCH = 2, /* remote can't support version # */
  43. NFS_RPC_PROC_UNAVAIL = 3, /* program can't support procedure */
  44. NFS_RPC_GARBAGE_ARGS = 4, /* procedure can't decode params */
  45. NFS_RPC_SYSTEM_ERR = 5 /* errors like memory allocation failure */
  46. };
  47. struct rpc_t {
  48. union {
  49. uint8_t data[2048];
  50. struct {
  51. uint32_t id;
  52. uint32_t type;
  53. uint32_t rpcvers;
  54. uint32_t prog;
  55. uint32_t vers;
  56. uint32_t proc;
  57. uint32_t data[1];
  58. } call;
  59. struct {
  60. uint32_t id;
  61. uint32_t type;
  62. uint32_t rstatus;
  63. uint32_t verifier;
  64. uint32_t v2;
  65. uint32_t astatus;
  66. uint32_t data[NFS_READ_SIZE];
  67. } reply;
  68. } u;
  69. } __attribute__((packed));
  70. void nfs_start(void); /* Begin NFS */
  71. /**********************************************************************/
  72. #endif /* __NFS_H__ */