1 /* SPDX-License-Identifier: GPL-2.0 */
3 * NFS protocol definitions
5 * This file contains constants mostly for Version 2 of the protocol,
6 * but also has a couple of NFSv3 bits in (notably the error codes).
11 #include <linux/sunrpc/msg_prot.h>
12 #include <linux/string.h>
13 #include <linux/crc32.h>
14 #include <uapi/linux/nfs.h>
17 * This is the kernel NFS client file handle representation
19 #define NFS_MAXFHSIZE 128
22 unsigned char data[NFS_MAXFHSIZE];
26 * Returns a zero iff the size and data fields match.
27 * Checks only "size" bytes in the data field.
29 static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)
31 return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;
34 static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)
36 target->size = source->size;
37 memcpy(target->data, source->data, source->size);
40 enum nfs3_stable_how {
45 /* used by direct.c to mark verf as invalid */
46 NFS_INVALID_STABLE_HOW = -1
51 * nfs_fhandle_hash - calculate the crc32 hash for the filehandle
52 * @fh - pointer to filehandle
54 * returns a crc32 hash for the filehandle that is compatible with
55 * the one displayed by "wireshark".
57 static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
59 return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
61 #else /* CONFIG_CRC32 */
62 static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
66 #endif /* CONFIG_CRC32 */
67 #endif /* _LINUX_NFS_H */