xref: /third_party/NuttX/fs/nfs/nfs.h (revision beacf11b)
1beacf11bSopenharmony_ci/****************************************************************************
2beacf11bSopenharmony_ci * fs/nfs/nfs.h
3beacf11bSopenharmony_ci *
4beacf11bSopenharmony_ci *   Copyright (C) 2012 Gregory Nutt. All rights reserved.
5beacf11bSopenharmony_ci *   Copyright (C) 2012 Jose Pablo Rojas Vargas. All rights reserved.
6beacf11bSopenharmony_ci *   Author: Jose Pablo Rojas Vargas <jrojas@nx-engineering.com>
7beacf11bSopenharmony_ci *           Gregory Nutt <gnutt@nuttx.org>
8beacf11bSopenharmony_ci *
9beacf11bSopenharmony_ci * Leveraged from OpenBSD:
10beacf11bSopenharmony_ci *
11beacf11bSopenharmony_ci *   Copyright (c) 1989, 1993, 1995
12beacf11bSopenharmony_ci *   The Regents of the University of California.  All rights reserved.
13beacf11bSopenharmony_ci *
14beacf11bSopenharmony_ci * This code is derived from software contributed to Berkeley by
15beacf11bSopenharmony_ci * Rick Macklem at The University of Guelph.
16beacf11bSopenharmony_ci *
17beacf11bSopenharmony_ci * Redistribution and use in source and binary forms, with or without
18beacf11bSopenharmony_ci * modification, are permitted provided that the following conditions
19beacf11bSopenharmony_ci * are met:
20beacf11bSopenharmony_ci *
21beacf11bSopenharmony_ci * 1. Redistributions of source code must retain the above copyright
22beacf11bSopenharmony_ci *    notice, this list of conditions and the following disclaimer.
23beacf11bSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
24beacf11bSopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
25beacf11bSopenharmony_ci *    documentation and/or other materials provided with the distribution.
26beacf11bSopenharmony_ci * 3. Neither the name of the University nor the names of its contributors
27beacf11bSopenharmony_ci *    may be used to endorse or promote products derived from this software
28beacf11bSopenharmony_ci *    without specific prior written permission.
29beacf11bSopenharmony_ci *
30beacf11bSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31beacf11bSopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32beacf11bSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33beacf11bSopenharmony_ci * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34beacf11bSopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35beacf11bSopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36beacf11bSopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37beacf11bSopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38beacf11bSopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39beacf11bSopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40beacf11bSopenharmony_ci * SUCH DAMAGE.
41beacf11bSopenharmony_ci *
42beacf11bSopenharmony_ci ****************************************************************************/
43beacf11bSopenharmony_ci
44beacf11bSopenharmony_ci#ifndef __FS_NFS_NFS_H
45beacf11bSopenharmony_ci#define __FS_NFS_NFS_H
46beacf11bSopenharmony_ci
47beacf11bSopenharmony_ci/****************************************************************************
48beacf11bSopenharmony_ci * Included Files
49beacf11bSopenharmony_ci ****************************************************************************/
50beacf11bSopenharmony_ci
51beacf11bSopenharmony_ci#include "nfs_mount.h"
52beacf11bSopenharmony_ci
53beacf11bSopenharmony_ci#ifdef __cplusplus
54beacf11bSopenharmony_ci#if __cplusplus
55beacf11bSopenharmony_ciextern "C" {
56beacf11bSopenharmony_ci#endif /* __cplusplus */
57beacf11bSopenharmony_ci#endif /* __cplusplus */
58beacf11bSopenharmony_ci
59beacf11bSopenharmony_ci/****************************************************************************
60beacf11bSopenharmony_ci * Debug
61beacf11bSopenharmony_ci ****************************************************************************/
62beacf11bSopenharmony_ci
63beacf11bSopenharmony_ci#ifdef NFS_DEBUG
64beacf11bSopenharmony_ci#define nfs_debug_error(format, ...) PRINT_ERR(format, ##__VA_ARGS__)
65beacf11bSopenharmony_ci#define nfs_debug_info(format, ...) PRINTK(format, ##__VA_ARGS__)
66beacf11bSopenharmony_ci#else
67beacf11bSopenharmony_ci#define nfs_debug_error(...)
68beacf11bSopenharmony_ci#define nfs_debug_info(...)
69beacf11bSopenharmony_ci#endif
70beacf11bSopenharmony_ci
71beacf11bSopenharmony_ci#define nfs_error(format, ...) PRINT_ERR(format, ##__VA_ARGS__)
72beacf11bSopenharmony_ci#define nfs_info(format, ...) PRINTK(format, ##__VA_ARGS__)
73beacf11bSopenharmony_ci
74beacf11bSopenharmony_ci/****************************************************************************
75beacf11bSopenharmony_ci * Pre-processor Definitions
76beacf11bSopenharmony_ci ****************************************************************************/
77beacf11bSopenharmony_ci
78beacf11bSopenharmony_ci#define NFS_TICKS          1              /* Number of system ticks */
79beacf11bSopenharmony_ci#define NFS_HZ             CLOCKS_PER_SEC /* Ticks/sec */
80beacf11bSopenharmony_ci#define NFS_TIMEO          (1 * NFS_HZ)   /* Default timeout = 1 second */
81beacf11bSopenharmony_ci#define NFS_MINTIMEO       (1 * NFS_HZ)   /* Min timeout to use */
82beacf11bSopenharmony_ci#define NFS_MAXTIMEO       (60 * NFS_HZ)  /* Max timeout to backoff to */
83beacf11bSopenharmony_ci#define NFS_TIMEOUTMUL     2              /* Timeout/Delay multiplier */
84beacf11bSopenharmony_ci#define NFS_MAXREXMIT      10             /* Stop counting after this many */
85beacf11bSopenharmony_ci#define NFS_RETRANS        5              /* Num of retrans for soft mounts */
86beacf11bSopenharmony_ci#define NFS_WSIZE          (8192 * 4)     /* Def. write data size <= 8192 */
87beacf11bSopenharmony_ci#define NFS_RSIZE          (8192 * 4)     /* Def. read data size <= 8192 */
88beacf11bSopenharmony_ci#define NFS_READDIRSIZE    1024           /* Def. readdir size */
89beacf11bSopenharmony_ci#define NFS_NPROCS         23
90beacf11bSopenharmony_ci
91beacf11bSopenharmony_ci/* Ideally, NFS_DIRBLKSIZ should be bigger, but I've seen servers with
92beacf11bSopenharmony_ci * broken NFS/ethernet drivers that won't work with anything bigger (Linux..)
93beacf11bSopenharmony_ci */
94beacf11bSopenharmony_ci
95beacf11bSopenharmony_ci#define NFS_DIRBLKSIZ      1024           /* Must be a multiple of DIRBLKSIZ */
96beacf11bSopenharmony_ci
97beacf11bSopenharmony_ci/* Increment NFS statistics */
98beacf11bSopenharmony_ci
99beacf11bSopenharmony_ci#ifdef CONFIG_NFS_STATISTICS
100beacf11bSopenharmony_ci#  define nfs_statistics(n) do { nfsstats.rpccnt[n]++; } while (0)
101beacf11bSopenharmony_ci#else
102beacf11bSopenharmony_ci#  define nfs_statistics(n)
103beacf11bSopenharmony_ci#endif
104beacf11bSopenharmony_ci
105beacf11bSopenharmony_ci/****************************************************************************
106beacf11bSopenharmony_ci *  Public Data
107beacf11bSopenharmony_ci ****************************************************************************/
108beacf11bSopenharmony_ci
109beacf11bSopenharmony_citypedef void (*NFSMOUNT_HOOK)(struct nfs_args*);
110beacf11bSopenharmony_ciextern uint32_t nfs_true;
111beacf11bSopenharmony_ciextern uint32_t nfs_false;
112beacf11bSopenharmony_ciextern NFSMOUNT_HOOK g_NFSMOUNT_HOOK;
113beacf11bSopenharmony_ciextern uint32_t nfs_xdrneg1;
114beacf11bSopenharmony_ci#ifdef CONFIG_NFS_STATISTICS
115beacf11bSopenharmony_ciextern struct nfsstats nfsstats;
116beacf11bSopenharmony_ci#endif
117beacf11bSopenharmony_ci
118beacf11bSopenharmony_ci/****************************************************************************
119beacf11bSopenharmony_ci * Public Types
120beacf11bSopenharmony_ci ****************************************************************************/
121beacf11bSopenharmony_ci
122beacf11bSopenharmony_ci/* NFS statistics structure */
123beacf11bSopenharmony_ci
124beacf11bSopenharmony_cistruct nfsstats
125beacf11bSopenharmony_ci{
126beacf11bSopenharmony_ci  uint64_t rpccnt[NFS_NPROCS];
127beacf11bSopenharmony_ci};
128beacf11bSopenharmony_ci
129beacf11bSopenharmony_ci/****************************************************************************
130beacf11bSopenharmony_ci * Public Function Prototypes
131beacf11bSopenharmony_ci ****************************************************************************/
132beacf11bSopenharmony_ciextern void nfs_mux_take(struct nfsmount *nmp);
133beacf11bSopenharmony_ciextern void nfs_mux_release(struct nfsmount *nmp);
134beacf11bSopenharmony_ciextern int  nfs_checkmount(struct nfsmount *nmp);
135beacf11bSopenharmony_ciextern int  nfs_fsinfo(struct nfsmount *nmp);
136beacf11bSopenharmony_ciextern int nfs_request(struct nfsmount *nmp, int procnum,
137beacf11bSopenharmony_ci                void *request, size_t reqlen,
138beacf11bSopenharmony_ci                void *response, size_t resplen);
139beacf11bSopenharmony_ciextern int  nfs_lookup(struct nfsmount *nmp, const char *filename,
140beacf11bSopenharmony_ci              struct file_handle *fhandle,
141beacf11bSopenharmony_ci              struct nfs_fattr *obj_attributes,
142beacf11bSopenharmony_ci              struct nfs_fattr *dir_attributes);
143beacf11bSopenharmony_ciextern int  nfs_findnode(struct nfsmount *nmp, const char *relpath,
144beacf11bSopenharmony_ci              struct file_handle *fhandle,
145beacf11bSopenharmony_ci              struct nfs_fattr *obj_attributes,
146beacf11bSopenharmony_ci              struct nfs_fattr *dir_attributes);
147beacf11bSopenharmony_ciextern int nfs_finddir(struct nfsmount *nmp, const char *relpath,
148beacf11bSopenharmony_ci              struct file_handle *fhandle,
149beacf11bSopenharmony_ci              struct nfs_fattr *attributes, char *filename);
150beacf11bSopenharmony_ciextern void nfs_attrupdate(struct nfsnode *np,
151beacf11bSopenharmony_ci              struct nfs_fattr *attributes);
152beacf11bSopenharmony_ciextern int nfs_mount(const char *server_ip_and_path, const char *mount_path,
153beacf11bSopenharmony_ci              unsigned int uid, unsigned int gid);
154beacf11bSopenharmony_ci
155beacf11bSopenharmony_ci
156beacf11bSopenharmony_ci#ifdef __cplusplus
157beacf11bSopenharmony_ci#if __cplusplus
158beacf11bSopenharmony_ci}
159beacf11bSopenharmony_ci#endif /*__cplusplus */
160beacf11bSopenharmony_ci#endif /*__cplusplus */
161beacf11bSopenharmony_ci
162beacf11bSopenharmony_ci#endif /* _NFS_NFS_H */
163