1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * NFS protocol definitions 2 * NFS protocol definitions 4 * 3 * 5 * This file contains constants mostly for Ver 4 * This file contains constants mostly for Version 2 of the protocol, 6 * but also has a couple of NFSv3 bits in (not 5 * but also has a couple of NFSv3 bits in (notably the error codes). 7 */ 6 */ 8 #ifndef _LINUX_NFS_H 7 #ifndef _LINUX_NFS_H 9 #define _LINUX_NFS_H 8 #define _LINUX_NFS_H 10 9 11 #include <linux/sunrpc/msg_prot.h> 10 #include <linux/sunrpc/msg_prot.h> 12 #include <linux/string.h> << 13 #include <linux/crc32.h> << 14 #include <uapi/linux/nfs.h> << 15 11 >> 12 #define NFS_PROGRAM 100003 >> 13 #define NFS_PORT 2049 >> 14 #define NFS_MAXDATA 8192 >> 15 #define NFS_MAXPATHLEN 1024 >> 16 #define NFS_MAXNAMLEN 255 >> 17 #define NFS_MAXGROUPS 16 >> 18 #define NFS_FHSIZE 32 >> 19 #define NFS_COOKIESIZE 4 >> 20 #define NFS_FIFO_DEV (-1) >> 21 #define NFSMODE_FMT 0170000 >> 22 #define NFSMODE_DIR 0040000 >> 23 #define NFSMODE_CHR 0020000 >> 24 #define NFSMODE_BLK 0060000 >> 25 #define NFSMODE_REG 0100000 >> 26 #define NFSMODE_LNK 0120000 >> 27 #define NFSMODE_SOCK 0140000 >> 28 #define NFSMODE_FIFO 0010000 >> 29 >> 30 #define NFS_MNT_PROGRAM 100005 >> 31 #define NFS_MNT_PORT 627 >> 32 >> 33 #define NFS_MAJOR UNNAMED_MAJOR >> 34 #define NFS_MINOR 0xff >> 35 >> 36 /* >> 37 * NFS stats. The good thing with these values is that NFSv3 errors are >> 38 * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which >> 39 * no-one uses anyway), so we can happily mix code as long as we make sure >> 40 * no NFSv3 errors are returned to NFSv2 clients. >> 41 * Error codes that have a `--' in the v2 column are not part of the >> 42 * standard, but seem to be widely used nevertheless. >> 43 */ >> 44 enum nfs_stat { >> 45 NFS_OK = 0, /* v2 v3 */ >> 46 NFSERR_PERM = 1, /* v2 v3 */ >> 47 NFSERR_NOENT = 2, /* v2 v3 */ >> 48 NFSERR_IO = 5, /* v2 v3 */ >> 49 NFSERR_NXIO = 6, /* v2 v3 */ >> 50 NFSERR_EAGAIN = 11, /* v2 v3 */ >> 51 NFSERR_ACCES = 13, /* v2 v3 */ >> 52 NFSERR_EXIST = 17, /* v2 v3 */ >> 53 NFSERR_XDEV = 18, /* v3 */ >> 54 NFSERR_NODEV = 19, /* v2 v3 */ >> 55 NFSERR_NOTDIR = 20, /* v2 v3 */ >> 56 NFSERR_ISDIR = 21, /* v2 v3 */ >> 57 NFSERR_INVAL = 22, /* v2 v3 that Sun forgot */ >> 58 NFSERR_FBIG = 27, /* v2 v3 */ >> 59 NFSERR_NOSPC = 28, /* v2 v3 */ >> 60 NFSERR_ROFS = 30, /* v2 v3 */ >> 61 NFSERR_MLINK = 31, /* v3 */ >> 62 NFSERR_OPNOTSUPP = 45, /* v2 v3 */ >> 63 NFSERR_NAMETOOLONG = 63, /* v2 v3 */ >> 64 NFSERR_NOTEMPTY = 66, /* v2 v3 */ >> 65 NFSERR_DQUOT = 69, /* v2 v3 */ >> 66 NFSERR_STALE = 70, /* v2 v3 */ >> 67 NFSERR_REMOTE = 71, /* v2 v3 */ >> 68 NFSERR_WFLUSH = 99, /* v2 */ >> 69 NFSERR_BADHANDLE = 10001, /* v3 */ >> 70 NFSERR_NOT_SYNC = 10002, /* v3 */ >> 71 NFSERR_BAD_COOKIE = 10003, /* v3 */ >> 72 NFSERR_NOTSUPP = 10004, /* v3 */ >> 73 NFSERR_TOOSMALL = 10005, /* v3 */ >> 74 NFSERR_SERVERFAULT = 10006, /* v3 */ >> 75 NFSERR_BADTYPE = 10007, /* v3 */ >> 76 NFSERR_JUKEBOX = 10008 /* v3 */ >> 77 }; >> 78 >> 79 /* NFSv2 file types - beware, these are not the same in NFSv3 */ >> 80 >> 81 enum nfs_ftype { >> 82 NFNON = 0, >> 83 NFREG = 1, >> 84 NFDIR = 2, >> 85 NFBLK = 3, >> 86 NFCHR = 4, >> 87 NFLNK = 5, >> 88 NFSOCK = 6, >> 89 NFBAD = 7, >> 90 NFFIFO = 8 >> 91 }; >> 92 >> 93 #if defined(__KERNEL__) 16 /* 94 /* 17 * This is the kernel NFS client file handle r 95 * This is the kernel NFS client file handle representation 18 */ 96 */ 19 #define NFS_MAXFHSIZE 128 !! 97 #define NFS_MAXFHSIZE 64 20 struct nfs_fh { 98 struct nfs_fh { 21 unsigned short size; 99 unsigned short size; 22 unsigned char data[NFS_MAXFH 100 unsigned char data[NFS_MAXFHSIZE]; 23 }; 101 }; 24 102 25 /* 103 /* 26 * Returns a zero iff the size and data fields !! 104 * This is really a general kernel constant, but since nothing like 27 * Checks only "size" bytes in the data field. !! 105 * this is defined in the kernel headers, I have to do it here. 28 */ 106 */ 29 static inline int nfs_compare_fh(const struct !! 107 #define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1)) 30 { !! 108 31 return a->size != b->size || memcmp(a- << 32 } << 33 << 34 static inline void nfs_copy_fh(struct nfs_fh * << 35 { << 36 target->size = source->size; << 37 memcpy(target->data, source->data, sou << 38 } << 39 109 40 enum nfs3_stable_how { 110 enum nfs3_stable_how { 41 NFS_UNSTABLE = 0, 111 NFS_UNSTABLE = 0, 42 NFS_DATA_SYNC = 1, 112 NFS_DATA_SYNC = 1, 43 NFS_FILE_SYNC = 2, !! 113 NFS_FILE_SYNC = 2 44 << 45 /* used by direct.c to mark verf as in << 46 NFS_INVALID_STABLE_HOW = -1 << 47 }; 114 }; 48 !! 115 #endif /* __KERNEL__ */ 49 #ifdef CONFIG_CRC32 << 50 /** << 51 * nfs_fhandle_hash - calculate the crc32 hash << 52 * @fh - pointer to filehandle << 53 * << 54 * returns a crc32 hash for the filehandle tha << 55 * the one displayed by "wireshark". << 56 */ << 57 static inline u32 nfs_fhandle_hash(const struc << 58 { << 59 return ~crc32_le(0xFFFFFFFF, &fh->data << 60 } << 61 #else /* CONFIG_CRC32 */ << 62 static inline u32 nfs_fhandle_hash(const struc << 63 { << 64 return 0; << 65 } << 66 #endif /* CONFIG_CRC32 */ << 67 #endif /* _LINUX_NFS_H */ 116 #endif /* _LINUX_NFS_H */ 68 117
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.