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> 11 #include <linux/string.h> 13 #include <linux/crc32.h> << 14 #include <uapi/linux/nfs.h> 12 #include <uapi/linux/nfs.h> 15 13 16 /* 14 /* 17 * This is the kernel NFS client file handle r 15 * This is the kernel NFS client file handle representation 18 */ 16 */ 19 #define NFS_MAXFHSIZE 128 17 #define NFS_MAXFHSIZE 128 20 struct nfs_fh { 18 struct nfs_fh { 21 unsigned short size; 19 unsigned short size; 22 unsigned char data[NFS_MAXFH 20 unsigned char data[NFS_MAXFHSIZE]; 23 }; 21 }; 24 22 25 /* 23 /* 26 * Returns a zero iff the size and data fields 24 * Returns a zero iff the size and data fields match. 27 * Checks only "size" bytes in the data field. 25 * Checks only "size" bytes in the data field. 28 */ 26 */ 29 static inline int nfs_compare_fh(const struct 27 static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b) 30 { 28 { 31 return a->size != b->size || memcmp(a- 29 return a->size != b->size || memcmp(a->data, b->data, a->size) != 0; 32 } 30 } 33 31 34 static inline void nfs_copy_fh(struct nfs_fh * 32 static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source) 35 { 33 { 36 target->size = source->size; 34 target->size = source->size; 37 memcpy(target->data, source->data, sou 35 memcpy(target->data, source->data, source->size); 38 } 36 } 39 37 >> 38 >> 39 /* >> 40 * This is really a general kernel constant, but since nothing like >> 41 * this is defined in the kernel headers, I have to do it here. >> 42 */ >> 43 #define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1)) >> 44 >> 45 40 enum nfs3_stable_how { 46 enum nfs3_stable_how { 41 NFS_UNSTABLE = 0, 47 NFS_UNSTABLE = 0, 42 NFS_DATA_SYNC = 1, 48 NFS_DATA_SYNC = 1, 43 NFS_FILE_SYNC = 2, 49 NFS_FILE_SYNC = 2, 44 50 45 /* used by direct.c to mark verf as in 51 /* used by direct.c to mark verf as invalid */ 46 NFS_INVALID_STABLE_HOW = -1 52 NFS_INVALID_STABLE_HOW = -1 47 }; 53 }; 48 << 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 */ 54 #endif /* _LINUX_NFS_H */ 68 55
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.