a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * CDDL HEADER START
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * The contents of this file are subject to the terms of the
a237e38e9161f0acd6451439d4a7dd597e66291dth * Common Development and Distribution License (the "License").
a237e38e9161f0acd6451439d4a7dd597e66291dth * You may not use this file except in compliance with the License.
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a237e38e9161f0acd6451439d4a7dd597e66291dth * or http://www.opensolaris.org/os/licensing.
a237e38e9161f0acd6451439d4a7dd597e66291dth * See the License for the specific language governing permissions
a237e38e9161f0acd6451439d4a7dd597e66291dth * and limitations under the License.
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * When distributing Covered Code, include this CDDL HEADER in each
a237e38e9161f0acd6451439d4a7dd597e66291dth * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a237e38e9161f0acd6451439d4a7dd597e66291dth * If applicable, add the following below this CDDL HEADER, with the
a237e38e9161f0acd6451439d4a7dd597e66291dth * fields enclosed by brackets "[]" replaced with your own identifying
a237e38e9161f0acd6451439d4a7dd597e66291dth * information: Portions Copyright [yyyy] [name of copyright owner]
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * CDDL HEADER END
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
a237e38e9161f0acd6451439d4a7dd597e66291dth * Use is subject to license terms.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#ifndef _SHAREFS_SHAREFS_H
a237e38e9161f0acd6451439d4a7dd597e66291dth#define _SHAREFS_SHAREFS_H
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#pragma ident "%Z%%M% %I% %E% SMI"
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * This header provides service for the sharefs module.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/modctl.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/vfs.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/vnode.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sys/gfs.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sharefs/share.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth#include <sharefs/sharetab.h>
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#ifdef __cplusplus
a237e38e9161f0acd6451439d4a7dd597e66291dthextern "C" {
a237e38e9161f0acd6451439d4a7dd597e66291dth#endif
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#define SHAREFS_ROOT "/etc/dfs"
a237e38e9161f0acd6451439d4a7dd597e66291dth#define SHAREFS_BASE "sharetab"
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * Lengths of strings.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dthtypedef struct sharefs_lens {
a237e38e9161f0acd6451439d4a7dd597e66291dth int shl_path;
a237e38e9161f0acd6451439d4a7dd597e66291dth int shl_res;
a237e38e9161f0acd6451439d4a7dd597e66291dth int shl_fstype;
a237e38e9161f0acd6451439d4a7dd597e66291dth int shl_opts;
a237e38e9161f0acd6451439d4a7dd597e66291dth int shl_descr;
a237e38e9161f0acd6451439d4a7dd597e66291dth} sharefs_lens_t;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * VFS data object
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dthtypedef struct sharefs_vfs {
a237e38e9161f0acd6451439d4a7dd597e66291dth vnode_t *sharefs_vfs_root;
a237e38e9161f0acd6451439d4a7dd597e66291dth} sharefs_vfs_t;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#define SHAREFS_NAME_MAX MAXNAMELEN
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * The lock ordering whenever sharefs_lock and sharetab_lock both
a237e38e9161f0acd6451439d4a7dd597e66291dth * need to be held is: sharefs_lock and then sharetab_lock.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern krwlock_t sharefs_lock; /* lock for the vnode ops */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern sharetab_t *sharefs_sharetab; /* The sharetab. */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern uint_t sharetab_count; /* How many shares? */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern krwlock_t sharetab_lock; /* lock for the cached sharetab */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern size_t sharetab_size; /* How big is the sharetab file? */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern timestruc_t sharetab_mtime; /* Last mod to sharetab */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern timestruc_t sharetab_snap_time; /* Last snap */
a237e38e9161f0acd6451439d4a7dd597e66291dthextern uint_t sharetab_generation; /* Which copy is it? */
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#define SHAREFS_INO_FILE 0x80
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern vnode_t *sharefs_create_root_file(vfs_t *);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * Sharetab file
a237e38e9161f0acd6451439d4a7dd597e66291dth *
a237e38e9161f0acd6451439d4a7dd597e66291dth * Note that even though the sharetab code does not explictly
a237e38e9161f0acd6451439d4a7dd597e66291dth * use 'sharefs_file', it is required by GFS that the first
a237e38e9161f0acd6451439d4a7dd597e66291dth * field of the private data be a gfs_file_t.
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dthtypedef struct shnode_t {
a237e38e9161f0acd6451439d4a7dd597e66291dth gfs_file_t sharefs_file; /* gfs file */
a237e38e9161f0acd6451439d4a7dd597e66291dth char *sharefs_snap; /* snapshot of the share */
a237e38e9161f0acd6451439d4a7dd597e66291dth size_t sharefs_size; /* size of the snapshot */
a237e38e9161f0acd6451439d4a7dd597e66291dth uint_t sharefs_count; /* number of shares */
a237e38e9161f0acd6451439d4a7dd597e66291dth uint_t sharefs_refs; /* reference count */
a237e38e9161f0acd6451439d4a7dd597e66291dth uint_t sharefs_real_vp; /* Are we a real or snap */
a237e38e9161f0acd6451439d4a7dd597e66291dth uint_t sharefs_generation; /* Which copy are we? */
a237e38e9161f0acd6451439d4a7dd597e66291dth timestruc_t sharefs_snap_time; /* When were we modded? */
a237e38e9161f0acd6451439d4a7dd597e66291dth} shnode_t;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth/*
a237e38e9161f0acd6451439d4a7dd597e66291dth * Some conversion macros:
a237e38e9161f0acd6451439d4a7dd597e66291dth */
a237e38e9161f0acd6451439d4a7dd597e66291dth#define VTOSH(vp) ((shnode_t *)((vp)->v_data))
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern const fs_operation_def_t sharefs_tops_data[];
a237e38e9161f0acd6451439d4a7dd597e66291dthextern vnodeops_t *sharefs_ops_data;
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern void sharefs_data_init(void);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dthextern void sharefs_sharetab_init(void);
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#ifdef __cplusplus
a237e38e9161f0acd6451439d4a7dd597e66291dth}
a237e38e9161f0acd6451439d4a7dd597e66291dth#endif
a237e38e9161f0acd6451439d4a7dd597e66291dth
a237e38e9161f0acd6451439d4a7dd597e66291dth#endif /* !_SHAREFS_SHAREFS_H */