wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Masami Komiya <mkomiya@sonare.it> 2004 |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __NFS_H__ |
| 8 | #define __NFS_H__ |
| 9 | |
| 10 | #define SUNRPC_PORT 111 |
| 11 | |
| 12 | #define PROG_PORTMAP 100000 |
| 13 | #define PROG_NFS 100003 |
| 14 | #define PROG_MOUNT 100005 |
| 15 | |
| 16 | #define MSG_CALL 0 |
| 17 | #define MSG_REPLY 1 |
| 18 | |
| 19 | #define PORTMAP_GETPORT 3 |
| 20 | |
| 21 | #define MOUNT_ADDENTRY 1 |
| 22 | #define MOUNT_UMOUNTALL 4 |
| 23 | |
| 24 | #define NFS_LOOKUP 4 |
| 25 | #define NFS_READLINK 5 |
| 26 | #define NFS_READ 6 |
| 27 | |
Guillaume GARDET | 2a4bc83 | 2016-07-29 11:31:00 +0200 | [diff] [blame] | 28 | #define NFS3PROC_LOOKUP 3 |
| 29 | |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 30 | #define NFS_FHSIZE 32 |
Guillaume GARDET | 2a4bc83 | 2016-07-29 11:31:00 +0200 | [diff] [blame] | 31 | #define NFS3_FHSIZE 64 |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 32 | |
| 33 | #define NFSERR_PERM 1 |
| 34 | #define NFSERR_NOENT 2 |
| 35 | #define NFSERR_ACCES 13 |
| 36 | #define NFSERR_ISDIR 21 |
| 37 | #define NFSERR_INVAL 22 |
| 38 | |
Tom Rini | bc27488 | 2017-08-20 22:40:01 -0400 | [diff] [blame] | 39 | /* |
| 40 | * Block size used for NFS read accesses. A RPC reply packet (including all |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 41 | * headers) must fit within a single Ethernet frame to avoid fragmentation. |
Tom Rini | bc27488 | 2017-08-20 22:40:01 -0400 | [diff] [blame] | 42 | * However, if CONFIG_IP_DEFRAG is set, a bigger value could be used. In any |
| 43 | * case, most NFS servers are optimized for a power of 2. |
Alessandro Rubini | 252f04d | 2009-08-07 13:59:16 +0200 | [diff] [blame] | 44 | */ |
Tom Rini | bc27488 | 2017-08-20 22:40:01 -0400 | [diff] [blame] | 45 | #define NFS_READ_SIZE 1024 /* biggest power of two that fits Ether frame */ |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 46 | |
Guillaume GARDET | 2a4bc83 | 2016-07-29 11:31:00 +0200 | [diff] [blame] | 47 | /* Values for Accept State flag on RPC answers (See: rfc1831) */ |
| 48 | enum rpc_accept_stat { |
| 49 | NFS_RPC_SUCCESS = 0, /* RPC executed successfully */ |
| 50 | NFS_RPC_PROG_UNAVAIL = 1, /* remote hasn't exported program */ |
| 51 | NFS_RPC_PROG_MISMATCH = 2, /* remote can't support version # */ |
| 52 | NFS_RPC_PROC_UNAVAIL = 3, /* program can't support procedure */ |
| 53 | NFS_RPC_GARBAGE_ARGS = 4, /* procedure can't decode params */ |
| 54 | NFS_RPC_SYSTEM_ERR = 5 /* errors like memory allocation failure */ |
| 55 | }; |
| 56 | |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 57 | struct rpc_t { |
| 58 | union { |
| 59 | uint8_t data[2048]; |
| 60 | struct { |
| 61 | uint32_t id; |
| 62 | uint32_t type; |
| 63 | uint32_t rpcvers; |
| 64 | uint32_t prog; |
| 65 | uint32_t vers; |
| 66 | uint32_t proc; |
| 67 | uint32_t data[1]; |
| 68 | } call; |
| 69 | struct { |
| 70 | uint32_t id; |
| 71 | uint32_t type; |
| 72 | uint32_t rstatus; |
| 73 | uint32_t verifier; |
| 74 | uint32_t v2; |
| 75 | uint32_t astatus; |
Joe Hershberger | 76a5c6b | 2016-09-09 13:01:24 -0500 | [diff] [blame] | 76 | uint32_t data[NFS_READ_SIZE]; |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 77 | } reply; |
| 78 | } u; |
Denis Pynkin | 4c7a6e0 | 2017-07-21 19:28:42 +0300 | [diff] [blame] | 79 | } __attribute__((packed)); |
Joe Hershberger | 40d7ca9 | 2015-04-08 01:41:10 -0500 | [diff] [blame] | 80 | void nfs_start(void); /* Begin NFS */ |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 81 | |
| 82 | |
| 83 | /**********************************************************************/ |
| 84 | |
| 85 | #endif /* __NFS_H__ */ |