autofs.h revision a05fd0c9b9aa46cf66ddea7617e56facdf1f4aaf
/*
* 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.
*/
#ifndef _SYS_FS_AUTOFS_H
#define _SYS_FS_AUTOFS_H
#include <sys/time_impl.h>
#include <rpc/rpcsec_gss.h>
#include <rpcsvc/autofs_prot.h>
#ifdef _KERNEL
#include <sys/vfs_opreg.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* Tracing macro; expands to nothing for non-debug kernels.
*/
#ifndef DEBUG
#define AUTOFS_DPRINT(x)
#else
#define AUTOFS_DPRINT(x) auto_dprint x
#endif
/*
* Per AUTOFS mountpoint information.
*/
typedef struct fninfo {
char *fi_path; /* autofs mountpoint */
char *fi_subdir; /* subdir within map */
char *fi_key; /* key to use on direct maps */
char *fi_opts; /* default mount options */
int fi_pathlen; /* autofs mountpoint len */
int fi_maplen; /* size of context */
int fi_subdirlen;
int fi_keylen;
int fi_optslen; /* default mount options len */
int fi_refcnt; /* reference count */
int fi_flags;
int fi_mount_to;
int fi_rpc_to;
} fninfo_t;
/*
* The AUTOFS locking scheme:
*
* The locks:
* fn_lock: protects the fn_node. It must be grabbed to change any
* field on the fn_node, except for those protected by
* fn_rwlock.
*
* top level list traversal.
* Protects: fn_dirents
* fn_next
* fn_size
* fn_linkcnt
* - Grab readers when checking if certain fn_node exists
* under fn_dirents.
* - Grab readers when attempting to reference a node
* pointed to by fn_dirents, fn_next, and fn_parent.
* - Grab writers to add a new fnnode under fn_dirents and
* to remove a node pointed to by fn_dirents or fn_next.
*
* Lock ordering:
* fn_rwlock > fn_lock
*
* The flags:
* MF_INPROG:
* - Indicates a mount request has been sent to the daemon.
* - If this flag is set, the thread sets MF_WAITING on the
* fnnode and sleeps.
*
* MF_WAITING:
* - Set by a thread when it puts itself to sleep waiting for
* the ongoing operation on this fnnode to be done.
*
* MF_LOOKUP:
* - Indicates a lookup request has been sent to the daemon.
* - If this flag is set, the thread sets MF_WAITING on the
* fnnode and sleeps.
*
* MF_IK_MOUNT:
* - This flag is set to indicate the mount was done in the
* kernel, and so should the unmount.
*
* MF_DIRECT:
* - Direct mountpoint if set, indirect otherwise.
*
* MF_TRIGGER:
* - This is a trigger node.
*
* MF_THISUID_MATCH_RQD:
* - User-relative context binding kind of node.
* - Node with this flag set requires a name match as well
* as a cred match in order to be returned from the directory
* hierarchy.
*
* MF_MOUNTPOINT:
* - At some point automountd mounted a filesystem on this node.
* If fn_trigger is non-NULL, v_vfsmountedhere is NULL and this
* flag is set then the filesystem must have been forcibly
* unmounted.
*/
/*
* The inode of AUTOFS
*/
typedef struct fnnode {
char *fn_name;
char *fn_symlink; /* if VLNK, this is what it */
/* points to */
int fn_namelen;
int fn_symlinklen;
int fn_flags;
/* AUTOFS trigger nodes */
/* used for remounting */
/* trigger nodes */
/* "thisuser" processing */
/* modified fn_seen */
} fnnode_t;
#define MF_DIRECT 0x001
#define MF_WAITING 0x004
#define MF_ATTR_WAIT 0x010
#define MF_IK_MOUNT 0x040
#define MF_TRIGGER 0x080
/* required for thisuser kind of */
/* nodes */
#define AUTOFS_MODE 0555
#define AUTOFS_BLOCKSIZE 1024
struct autofs_callargs {
/* used for debugging purposes */
};
struct autofs_globals {
int fng_fnnode_count;
int fng_unmount_threads;
int fng_verbose;
/*
* autofs_daemon_lock protects fng_autofs_daemon_dh
*/
};
extern kmutex_t autofs_minor_lock;
extern zone_key_t autofs_key;
/*
* Sets the MF_INPROG flag on this fnnode.
* fnp->fn_lock should be held before this macro is called,
* operation is either MF_INPROG or MF_LOOKUP.
*/
}
}
extern struct vnodeops *auto_vnodeops;
extern const struct fs_operation_def auto_vnodeops_template[];
/*
* Utility routines
*/
extern int auto_wait4mount(fnnode_t *);
struct autofs_globals *);
extern void auto_freefnnode(fnnode_t *);
extern void auto_do_unmount(struct autofs_globals *);
/*PRINTFLIKE4*/
const char *fmt, ...)
__KPRINTFLIKE(4);
/*PRINTFLIKE2*/
__KPRINTFLIKE(2);
void *, int, bool_t);
extern int auto_nobrowse_option(char *);
extern void autofs_free_globals(struct autofs_globals *);
extern void autofs_shutdown_zone(struct autofs_globals *);
#endif /* _KERNEL */
/*
* autofs structures and defines needed for use with doors.
*/
#define AUTOFS_NULL 0
#define AUTOFS_MOUNT 1
#define AUTOFS_UNMOUNT 2
#define AUTOFS_READDIR 3
#define AUTOFS_LOOKUP 4
#define AUTOFS_SRVINFO 5
#define AUTOFS_MNTINFO 6
/*
* autofs_door_args is a generic structure used to grab the command
* from any of the argument structures passed in.
*/
typedef struct {
int cmd;
int xdr_len;
typedef struct {
int res_status;
int xdr_len;
typedef enum autofs_res autofs_res_t;
typedef enum autofs_stat autofs_stat_t;
typedef enum autofs_action autofs_action_t;
typedef struct {
void * atsd_buf;
} autofs_tsd_t;
typedef struct sec_desdata {
int nd_sec_syncaddr_len;
int nd_sec_knc_semantics;
int nd_sec_netnamelen;
int nd_sec_knc_unused[8];
typedef struct sec_gssdata {
int element_length;
char uname[MAX_NAME_LEN];
char inst[MAX_NAME_LEN];
char realm[MAX_NAME_LEN];
typedef struct nfs_secdata {
/*
* Comma separated list of mntoptions which are inherited when the
* "restrict" option is present. The RESTRICT option must be first!
* This define is shared between the kernel and the automount daemon.
*/
#define RESTRICTED_MNTOPTS \
/*
* AUTOFS syscall entry point
*/
#ifdef _KERNEL
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_AUTOFS_H */