Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * NFS protocol definitions |
| 3 | * |
| 4 | * This file contains constants mostly for Version 2 of the protocol, |
| 5 | * but also has a couple of NFSv3 bits in (notably the error codes). |
| 6 | */ |
| 7 | #ifndef _LINUX_NFS_H |
| 8 | #define _LINUX_NFS_H |
| 9 | |
| 10 | #include <linux/sunrpc/msg_prot.h> |
| 11 | #include <linux/string.h> |
| 12 | |
| 13 | #define NFS_PROGRAM 100003 |
| 14 | #define NFS_PORT 2049 |
| 15 | #define NFS_MAXDATA 8192 |
| 16 | #define NFS_MAXPATHLEN 1024 |
| 17 | #define NFS_MAXNAMLEN 255 |
| 18 | #define NFS_MAXGROUPS 16 |
| 19 | #define NFS_FHSIZE 32 |
| 20 | #define NFS_COOKIESIZE 4 |
| 21 | #define NFS_FIFO_DEV (-1) |
| 22 | #define NFSMODE_FMT 0170000 |
| 23 | #define NFSMODE_DIR 0040000 |
| 24 | #define NFSMODE_CHR 0020000 |
| 25 | #define NFSMODE_BLK 0060000 |
| 26 | #define NFSMODE_REG 0100000 |
| 27 | #define NFSMODE_LNK 0120000 |
| 28 | #define NFSMODE_SOCK 0140000 |
| 29 | #define NFSMODE_FIFO 0010000 |
| 30 | |
| 31 | #define NFS_MNT_PROGRAM 100005 |
| 32 | #define NFS_MNT_PORT 627 |
| 33 | |
| 34 | /* |
| 35 | * NFS stats. The good thing with these values is that NFSv3 errors are |
| 36 | * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which |
| 37 | * no-one uses anyway), so we can happily mix code as long as we make sure |
| 38 | * no NFSv3 errors are returned to NFSv2 clients. |
| 39 | * Error codes that have a `--' in the v2 column are not part of the |
| 40 | * standard, but seem to be widely used nevertheless. |
| 41 | */ |
| 42 | enum nfs_stat { |
| 43 | NFS_OK = 0, /* v2 v3 v4 */ |
| 44 | NFSERR_PERM = 1, /* v2 v3 v4 */ |
| 45 | NFSERR_NOENT = 2, /* v2 v3 v4 */ |
| 46 | NFSERR_IO = 5, /* v2 v3 v4 */ |
| 47 | NFSERR_NXIO = 6, /* v2 v3 v4 */ |
| 48 | NFSERR_EAGAIN = 11, /* v2 v3 */ |
| 49 | NFSERR_ACCES = 13, /* v2 v3 v4 */ |
| 50 | NFSERR_EXIST = 17, /* v2 v3 v4 */ |
| 51 | NFSERR_XDEV = 18, /* v3 v4 */ |
| 52 | NFSERR_NODEV = 19, /* v2 v3 v4 */ |
| 53 | NFSERR_NOTDIR = 20, /* v2 v3 v4 */ |
| 54 | NFSERR_ISDIR = 21, /* v2 v3 v4 */ |
| 55 | NFSERR_INVAL = 22, /* v2 v3 v4 */ |
| 56 | NFSERR_FBIG = 27, /* v2 v3 v4 */ |
| 57 | NFSERR_NOSPC = 28, /* v2 v3 v4 */ |
| 58 | NFSERR_ROFS = 30, /* v2 v3 v4 */ |
| 59 | NFSERR_MLINK = 31, /* v3 v4 */ |
| 60 | NFSERR_OPNOTSUPP = 45, /* v2 v3 */ |
| 61 | NFSERR_NAMETOOLONG = 63, /* v2 v3 v4 */ |
| 62 | NFSERR_NOTEMPTY = 66, /* v2 v3 v4 */ |
| 63 | NFSERR_DQUOT = 69, /* v2 v3 v4 */ |
| 64 | NFSERR_STALE = 70, /* v2 v3 v4 */ |
| 65 | NFSERR_REMOTE = 71, /* v2 v3 */ |
| 66 | NFSERR_WFLUSH = 99, /* v2 */ |
| 67 | NFSERR_BADHANDLE = 10001, /* v3 v4 */ |
| 68 | NFSERR_NOT_SYNC = 10002, /* v3 */ |
| 69 | NFSERR_BAD_COOKIE = 10003, /* v3 v4 */ |
| 70 | NFSERR_NOTSUPP = 10004, /* v3 v4 */ |
| 71 | NFSERR_TOOSMALL = 10005, /* v3 v4 */ |
| 72 | NFSERR_SERVERFAULT = 10006, /* v3 v4 */ |
| 73 | NFSERR_BADTYPE = 10007, /* v3 v4 */ |
| 74 | NFSERR_JUKEBOX = 10008, /* v3 v4 */ |
| 75 | NFSERR_SAME = 10009, /* v4 */ |
| 76 | NFSERR_DENIED = 10010, /* v4 */ |
| 77 | NFSERR_EXPIRED = 10011, /* v4 */ |
| 78 | NFSERR_LOCKED = 10012, /* v4 */ |
| 79 | NFSERR_GRACE = 10013, /* v4 */ |
| 80 | NFSERR_FHEXPIRED = 10014, /* v4 */ |
| 81 | NFSERR_SHARE_DENIED = 10015, /* v4 */ |
| 82 | NFSERR_WRONGSEC = 10016, /* v4 */ |
| 83 | NFSERR_CLID_INUSE = 10017, /* v4 */ |
| 84 | NFSERR_RESOURCE = 10018, /* v4 */ |
| 85 | NFSERR_MOVED = 10019, /* v4 */ |
| 86 | NFSERR_NOFILEHANDLE = 10020, /* v4 */ |
| 87 | NFSERR_MINOR_VERS_MISMATCH = 10021, /* v4 */ |
| 88 | NFSERR_STALE_CLIENTID = 10022, /* v4 */ |
| 89 | NFSERR_STALE_STATEID = 10023, /* v4 */ |
| 90 | NFSERR_OLD_STATEID = 10024, /* v4 */ |
| 91 | NFSERR_BAD_STATEID = 10025, /* v4 */ |
| 92 | NFSERR_BAD_SEQID = 10026, /* v4 */ |
| 93 | NFSERR_NOT_SAME = 10027, /* v4 */ |
| 94 | NFSERR_LOCK_RANGE = 10028, /* v4 */ |
| 95 | NFSERR_SYMLINK = 10029, /* v4 */ |
| 96 | NFSERR_RESTOREFH = 10030, /* v4 */ |
| 97 | NFSERR_LEASE_MOVED = 10031, /* v4 */ |
| 98 | NFSERR_ATTRNOTSUPP = 10032, /* v4 */ |
| 99 | NFSERR_NO_GRACE = 10033, /* v4 */ |
| 100 | NFSERR_RECLAIM_BAD = 10034, /* v4 */ |
| 101 | NFSERR_RECLAIM_CONFLICT = 10035,/* v4 */ |
| 102 | NFSERR_BAD_XDR = 10036, /* v4 */ |
| 103 | NFSERR_LOCKS_HELD = 10037, /* v4 */ |
| 104 | NFSERR_OPENMODE = 10038, /* v4 */ |
| 105 | NFSERR_BADOWNER = 10039, /* v4 */ |
| 106 | NFSERR_BADCHAR = 10040, /* v4 */ |
| 107 | NFSERR_BADNAME = 10041, /* v4 */ |
| 108 | NFSERR_BAD_RANGE = 10042, /* v4 */ |
| 109 | NFSERR_LOCK_NOTSUPP = 10043, /* v4 */ |
| 110 | NFSERR_OP_ILLEGAL = 10044, /* v4 */ |
| 111 | NFSERR_DEADLOCK = 10045, /* v4 */ |
| 112 | NFSERR_FILE_OPEN = 10046, /* v4 */ |
| 113 | NFSERR_ADMIN_REVOKED = 10047, /* v4 */ |
| 114 | NFSERR_CB_PATH_DOWN = 10048, /* v4 */ |
| 115 | NFSERR_REPLAY_ME = 10049 /* v4 */ |
| 116 | }; |
| 117 | |
| 118 | /* NFSv2 file types - beware, these are not the same in NFSv3 */ |
| 119 | |
| 120 | enum nfs_ftype { |
| 121 | NFNON = 0, |
| 122 | NFREG = 1, |
| 123 | NFDIR = 2, |
| 124 | NFBLK = 3, |
| 125 | NFCHR = 4, |
| 126 | NFLNK = 5, |
| 127 | NFSOCK = 6, |
| 128 | NFBAD = 7, |
| 129 | NFFIFO = 8 |
| 130 | }; |
| 131 | |
| 132 | #if defined(__KERNEL__) |
| 133 | /* |
| 134 | * This is the kernel NFS client file handle representation |
| 135 | */ |
| 136 | #define NFS_MAXFHSIZE 128 |
| 137 | struct nfs_fh { |
| 138 | unsigned short size; |
| 139 | unsigned char data[NFS_MAXFHSIZE]; |
| 140 | }; |
| 141 | |
| 142 | /* |
| 143 | * Returns a zero iff the size and data fields match. |
| 144 | * Checks only "size" bytes in the data field. |
| 145 | */ |
| 146 | static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b) |
| 147 | { |
| 148 | return a->size != b->size || memcmp(a->data, b->data, a->size) != 0; |
| 149 | } |
| 150 | |
| 151 | static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source) |
| 152 | { |
| 153 | target->size = source->size; |
| 154 | memcpy(target->data, source->data, source->size); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | /* |
| 159 | * This is really a general kernel constant, but since nothing like |
| 160 | * this is defined in the kernel headers, I have to do it here. |
| 161 | */ |
| 162 | #define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1)) |
| 163 | |
| 164 | |
| 165 | enum nfs3_stable_how { |
| 166 | NFS_UNSTABLE = 0, |
| 167 | NFS_DATA_SYNC = 1, |
| 168 | NFS_FILE_SYNC = 2 |
| 169 | }; |
| 170 | #endif /* __KERNEL__ */ |
| 171 | #endif /* _LINUX_NFS_H */ |