export.h revision b4ecf764d8099c92d5c9c0f13a45514377f3d292
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _NFS_EXPORT_H
#define _NFS_EXPORT_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* nfs pseudo flavor number is owned by IANA. Need to make sure the
* Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any
* new IANA defined pseudo flavor numbers. The chance for the overlap
* is very small since the growth of new flavor numbers is expected
* to be limited.
*/
/*
* As duplicate flavors can be passed into exportfs in the arguments, we
* allocate a cleaned up array with non duplicate flavors on the stack.
* So we need to know how much to allocate.
*/
/*
* Note: exported_lock is currently used to ensure the integrity of
* the secinfo fields.
*/
struct secinfo {
unsigned int s_flags; /* flags (see below) */
/* how many children (self included) */
/* use this flavor. */
int s_window; /* window */
int s_rootcnt; /* count of root names */
/* they are strings for AUTH_DES and */
/* rpc_gss_principal_t for RPCSEC_GSS */
};
#ifdef _SYSCALL32
struct secinfo32 {
/* how many children (self included) */
/* use this flavor. */
/* they are strings for AUTH_DES and */
/* rpc_gss_principal_t for RPCSEC_GSS */
};
#endif /* _SYSCALL32 */
/*
* security negotiation related
*/
struct sec_ol {
int sec_flags; /* security nego flags */
};
/*
* Per-mode flags (secinfo.s_flags)
*/
/* invalid secinfo reference count */
/* last secinfo reference */
/* sec flavor explicitly shared for the exported node */
/* the only reference count left is for referring itself */
/*
* The export information passed to exportfs() (Version 2)
*/
struct exportdata {
int ex_version; /* structure version */
char *ex_path; /* exported path */
int ex_flags; /* flags */
unsigned int ex_anon; /* uid for unauthenticated requests */
int ex_seccnt; /* count of security modes */
char *ex_index; /* index file for public filesystem */
char *ex_log_buffer; /* path to logging buffer file */
char *ex_tag; /* tag used to identify log config */
};
#ifdef _SYSCALL32
struct exportdata32 {
};
#endif /* _SYSCALL32 */
/*
* exported vfs flags.
*/
/* by default only operations which affect */
/* transaction logging are enabled */
#ifdef VOLATILE_FH_TEST
#endif /* VOLATILE_FH_TEST */
/* fabricate ACL for VOP_GETSECATTR OTW call */
#ifdef _KERNEL
/*
* Be very careful about which NFS procedures get the RPC_ALLOWANON bit.
* Right now, if this bit is on, we ignore the results of per NFS request
* access control.
*/
/*
* RPC_ALL is an or of all above bits to be used with "don't care"
* nfsv4 ops. The flags of an nfsv4 request is the bit-AND of the
* per-op flags.
*/
#ifdef VOLATILE_FH_TEST
struct ex_vol_rename {
struct ex_vol_rename *vrn_next;
};
#endif /* VOLATILE_FH_TEST */
/*
* An auth cache entry can exist in 4 active states, with the inactive
* state being indicated by no entry in the cache.
*
* A FRESH entry is one which is either new or has been refreshed at
* least once.
*
* A STALE entry is one which has been detected to be too old. The
* transistion from FRESH to STALE prevents multiple threads from
* submitting refresh requests.
*
* A REFRESHING entry is one which is actively engaging the user land
* mountd code to re-authenticate the cache entry.
*
* An INVALID entry was one which was either STALE or REFRESHING
* and was deleted out of the encapsulating exi. Since we can't
* delete it yet, we mark it as INVALID, which lets the refreshq
* know not to work on it.
*
* Note that the auth state of the entry is always valid, even if the
* entry is STALE. Just as you can eat stale bread, you can consume
* a stale cache entry. The only time the contents change could be
* during the transistion from REFRESHING to FRESH.
*/
typedef enum auth_state {
} auth_state_t;
/*
* An authorization cache entry
*
* Either the state in auth_state will protect the
* contents or auth_lock must be held.
*/
struct auth_cache {
int auth_flavor;
int auth_access;
char *auth_netid;
struct auth_cache *auth_next;
};
#define AUTH_TABLESIZE 32
/*
* Structure containing log file meta-data.
*/
struct log_file {
unsigned int lf_flags; /* flags (see below) */
int lf_writers; /* outstanding writers */
int lf_refcnt; /* references to this struct */
};
/*
* log_file and log_buffer flags.
*/
/* storage in progress */
/*
* The logging buffer information.
* This structure may be shared by multiple exportinfo structures,
* if they share the same buffer file.
* This structure contains the basic information about the buffer, such
* as it's location in the filesystem.
*
* 'lb_lock' protects all the fields in this structure except for 'lb_path',
* and 'lb_next'.
* 'lb_path' is a write-once/read-many field which needs no locking, it is
* set before the structure is linked to any exportinfo structure.
* 'lb_next' is protected by the log_buffer_list_lock.
*/
struct log_buffer {
unsigned int lb_flags; /* L_ONLIST set? */
int lb_refcnt; /* references to this struct */
unsigned int lb_rec_id; /* used to generate unique id */
struct log_buffer *lb_next;
int lb_num_recs; /* # of records to write */
};
#define LOG_BUFFER_HOLD(lbp) { \
}
#define LOG_BUFFER_RELE(lbp) { \
log_buffer_rele(lbp); \
}
/*
* Structure for character set conversion mapping based on client address.
*/
struct charset_cache {
struct charset_cache *next;
struct sockaddr client_addr;
};
/* Forward declarations */
struct exportinfo;
struct exp_visible;
struct svc_req;
/*
* Treenodes are used to build tree representing every node which is part
* of nfs server pseudo namespace. They are connected with both exportinfo
* and exp_visible struct. They were introduced to avoid lookup of ".."
* in the underlying file system during unshare, which was failing if the
* file system was forcibly unmounted or if the directory was removed.
* One exp_visible_t can be shared via several treenode_t, i.e.
* different tree_vis can point to the same exp_visible_t.
* This will happen if some directory is on two different shared paths:
* corresponding to /tmp/a and both will have same value in tree_vis.
*
*
*
* NEW DATA STRUCT ORIGINAL DATA STRUCT
*
* ns_root +---+ +----------+
* | / | |PSEUDO EXP|-->+---+ +---+ +---+
* +---+--------- ----+----------+ | a |-->| k |-->| b |
* /\ +---+ +---+ +---+
* / \ . . .
* +---+...\......... ..................... . .
* *| a | \ +----------+ . .
* +---+-----\------- ----|REAL EXP a| . .
* / \ +----------+ . .
* / +===+... ............................. .
* / *| k | +----------+ .
* / +===+--- ----|REAL EXP k| .
* / +----------+ .
* +===+................ .....................................
* *| b | +----------+
* +===+---------------- ----|REAL EXP b|-->+---+
* \ +----------+ | d |
* +===+............. ...................+---+
* | d | +----------+
* +===+------------- ----|PSEUDO EXP|-->+---+ +---+
* / +----------+ | e |-->| g |
* +---+................. ...................+---+ +---+
* | e | .
* +---+ .
* \ .
* +---+.............. ............................
* *| g | +----------+
* +---+-------------- ----|REAL EXP g|
* +----------+
*
*
*
* +===+ +---+ +---+
* +===+ (VROOT) +---+ +---+
*
*
* Bi-directional interconnect:
* treenode_t::tree_exi --------- exportinfo_t::exi_tree
* One-way direction connection:
* treenode_t::tree_vis .........> exp_visible_t
*/
/* Access to treenode_t is under protection of exported_lock RW_LOCK */
typedef struct treenode {
/* support for generic n-ary trees */
struct treenode *tree_parent;
struct treenode *tree_child_first;
/* private, nfs specific part */
struct exportinfo *tree_exi;
struct exp_visible *tree_vis;
} treenode_t;
/*
* TREE_ROOT checks if the node corresponds to a filesystem root
* TREE_EXPORTED checks if the node is explicitly shared
*/
#define TREE_ROOT(t) \
#define TREE_EXPORTED(t) \
/* Root of nfs pseudo namespace */
extern treenode_t *ns_root;
#define EXPTABLESIZE 256
struct exp_hash {
};
/*
* A node associated with an export entry on the
* list of exported filesystems.
*
* exi_count+exi_lock protects an individual exportinfo from being freed
* when in use.
*
*
* exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the
* underlying fs devno can change on each mount. When set, the server
* should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must
* use exi_fsid because it is guaranteed to be persistent. This isn't
* in any way related to NFS4 volatile filehandles.
*/
struct exportinfo {
struct exportdata exi_export;
struct log_buffer *exi_logbuffer;
struct exp_visible *exi_visible;
struct charset_cache *exi_charset;
unsigned exi_volatile_dev:1;
unsigned exi_moved:1;
#ifdef VOLATILE_FH_TEST
struct ex_vol_rename *exi_vol_rename;
#endif /* VOLATILE_FH_TEST */
};
typedef struct exportinfo exportinfo_t;
typedef struct exportdata exportdata_t;
/*
* exp_visible is a visible list per filesystem. It is for filesystems
* that may need a limited view of its contents. A pseudo export and
* a real export at the mount point (VROOT) which has a subtree shared
* has a visible list.
*
* The exi_visible field is NULL for normal, non=pseudo filesystems
* which do not have any subtree exported. If the field is non-null,
* vis_ino. The presence of a "visible" list means that if this export
* can only have a limited view, it can only view the entries in the
* exp_visible list. The directories in the fid list comprise paths that
* lead to exported directories.
*
* The vis_count field records the number of paths in this filesystem
* that use this directory. The vis_exported field is non-zero if the
* entry is an exported directory (leaf node).
*
* exp_visible itself is not reference counted. Each exp_visible is
* referenced twice:
* 1) from treenode::tree_vis
* 2) linked from exportinfo::exi_visible
* The 'owner' of exp_visible is the exportinfo structure. exp_visible should
* be always freed only from exportinfo_t, never from treenode::tree_vis.
*/
struct exp_visible {
int vis_count;
int vis_exported;
struct exp_visible *vis_next;
struct secinfo *vis_secinfo;
int vis_seccnt;
};
typedef struct exp_visible exp_visible_t;
/*
* Returns true iff exported filesystem is read-only to the given host.
*
* Note: this macro should be as fast as possible since it's called
* on each NFS modification request.
*/
extern int nfsauth4_secinfo_access(struct exportinfo *,
extern int nfs_fhbcmp(char *, char *, int);
extern int nfs_exportinit(void);
extern void nfs_exportfini(void);
extern void exi_hold(struct exportinfo *);
extern void exi_rele(struct exportinfo *);
int *, bool_t);
struct exportinfo **);
extern void export_link(struct exportinfo *);
extern void export_unlink(struct exportinfo *);
extern int client_is_downrev(struct svc_req *);
/*
* Functions that handle the NFSv4 server namespace
*/
extern int treeclimb_export(struct exportinfo *);
extern void treeclimb_unexport(struct exportinfo *);
extern void free_visible(struct exp_visible *);
struct exp_visible *, struct exportdata *);
/*
* Functions that handle the NFSv4 server namespace security flavors
* information.
*/
extern void srv_secinfo_list_free(struct secinfo *, int);
/*
* "public" and default (root) location for public filehandle
*/
extern krwlock_t exported_lock;
extern struct exportinfo *exptable[];
/*
* Two macros for identifying public filehandles.
* A v2 public filehandle is 32 zero bytes.
* A v3 public filehandle is zero length.
*/
#define PUBLIC_FH2(fh) \
#define PUBLIC_FH3(fh) \
((fh)->fh3_length == 0)
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _NFS_EXPORT_H */