77 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * NFS protocol definitions4 *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).7 */8#ifndef _LINUX_NFS_H9#define _LINUX_NFS_H10 11#include <linux/cred.h>12#include <linux/sunrpc/auth.h>13#include <linux/sunrpc/msg_prot.h>14#include <linux/string.h>15#include <linux/crc32.h>16#include <uapi/linux/nfs.h>17 18/* The LOCALIO program is entirely private to Linux and is19 * NOT part of the uapi.20 */21#define NFS_LOCALIO_PROGRAM 40012222#define LOCALIOPROC_NULL 023#define LOCALIOPROC_UUID_IS_LOCAL 124 25/*26 * This is the kernel NFS client file handle representation27 */28#define NFS_MAXFHSIZE 12829struct nfs_fh {30 unsigned short size;31 unsigned char data[NFS_MAXFHSIZE];32};33 34/*35 * Returns a zero iff the size and data fields match.36 * Checks only "size" bytes in the data field.37 */38static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)39{40 return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;41}42 43static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)44{45 target->size = source->size;46 memcpy(target->data, source->data, source->size);47}48 49enum nfs3_stable_how {50 NFS_UNSTABLE = 0,51 NFS_DATA_SYNC = 1,52 NFS_FILE_SYNC = 2,53 54 /* used by direct.c to mark verf as invalid */55 NFS_INVALID_STABLE_HOW = -156};57 58#ifdef CONFIG_CRC3259/**60 * nfs_fhandle_hash - calculate the crc32 hash for the filehandle61 * @fh - pointer to filehandle62 *63 * returns a crc32 hash for the filehandle that is compatible with64 * the one displayed by "wireshark".65 */66static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)67{68 return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);69}70#else /* CONFIG_CRC32 */71static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)72{73 return 0;74}75#endif /* CONFIG_CRC32 */76#endif /* _LINUX_NFS_H */77