1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * NFS protocol definitions
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * This file contains constants mostly for Version 2 of the protocol,
6*4882a593Smuzhiyun * but also has a couple of NFSv3 bits in (notably the error codes).
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun #ifndef _LINUX_NFS_H
9*4882a593Smuzhiyun #define _LINUX_NFS_H
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #include <linux/sunrpc/msg_prot.h>
12*4882a593Smuzhiyun #include <linux/string.h>
13*4882a593Smuzhiyun #include <uapi/linux/nfs.h>
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun /*
16*4882a593Smuzhiyun * This is the kernel NFS client file handle representation
17*4882a593Smuzhiyun */
18*4882a593Smuzhiyun #define NFS_MAXFHSIZE 128
19*4882a593Smuzhiyun struct nfs_fh {
20*4882a593Smuzhiyun unsigned short size;
21*4882a593Smuzhiyun unsigned char data[NFS_MAXFHSIZE];
22*4882a593Smuzhiyun };
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun * Returns a zero iff the size and data fields match.
26*4882a593Smuzhiyun * Checks only "size" bytes in the data field.
27*4882a593Smuzhiyun */
nfs_compare_fh(const struct nfs_fh * a,const struct nfs_fh * b)28*4882a593Smuzhiyun static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)
29*4882a593Smuzhiyun {
30*4882a593Smuzhiyun return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;
31*4882a593Smuzhiyun }
32*4882a593Smuzhiyun
nfs_copy_fh(struct nfs_fh * target,const struct nfs_fh * source)33*4882a593Smuzhiyun static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun target->size = source->size;
36*4882a593Smuzhiyun memcpy(target->data, source->data, source->size);
37*4882a593Smuzhiyun }
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun /*
41*4882a593Smuzhiyun * This is really a general kernel constant, but since nothing like
42*4882a593Smuzhiyun * this is defined in the kernel headers, I have to do it here.
43*4882a593Smuzhiyun */
44*4882a593Smuzhiyun #define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1))
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun enum nfs3_stable_how {
48*4882a593Smuzhiyun NFS_UNSTABLE = 0,
49*4882a593Smuzhiyun NFS_DATA_SYNC = 1,
50*4882a593Smuzhiyun NFS_FILE_SYNC = 2,
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun /* used by direct.c to mark verf as invalid */
53*4882a593Smuzhiyun NFS_INVALID_STABLE_HOW = -1
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun #endif /* _LINUX_NFS_H */
56