export.h revision af9f976974e1de7e139c213e6a8ab6e40196328c
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _NFS_EXPORT_H
#define _NFS_EXPORT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#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 */
#ifdef _KERNEL
/*
* Be very careful about which NFS procedures get the RPC_ALLOWANON bit.
* Right now, it 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 authorization cache entry
*/
struct auth_cache {
int auth_flavor;
int auth_access;
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); \
}
#define EXPTABLESIZE 16
/*
* 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 exportinfo *exi_hash;
struct log_buffer *exi_logbuffer;
struct exp_visible *exi_visible;
unsigned exi_volatile_dev: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).
*/
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.
*/
(vn_is_readonly(vp) || \
struct svc_req *);
extern int nfsauth4_secinfo_access(struct exportinfo *,
struct svc_req *, int, int);
extern int nfs_fhbcmp(char *, char *, int);
extern int nfs_exportinit(void);
extern void nfs_exportfini(void);
extern void exi_rele(struct exportinfo *);
int *, bool_t);
struct exportinfo **);
extern void export_link(struct exportinfo *);
struct exportinfo **);
/*
* Functions that handle the NFSv4 server namespace
*/
extern int treeclimb_export(struct exportinfo *);
extern int treeclimb_unexport(struct exportinfo *);
extern void free_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 */