1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _LX_AUTOFS_IMPL_H
  28 #define _LX_AUTOFS_IMPL_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #ifdef  __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #include <sys/file.h>
  37 #include <sys/id_space.h>
  38 #include <sys/modhash.h>
  39 #include <sys/vnode.h>
  40 
  41 #include <sys/lx_autofs.h>
  42 
  43 /*
  44  * Space key.
  45  * Used to persist data across lx_autofs filesystem module unloads.
  46  */
  47 #define LX_AUTOFS_SPACE_KEY_UDEV        LX_AUTOFS_NAME "_udev"
  48 
  49 /*
  50  * Name of the backing store directory.
  51  */
  52 #define LX_AUTOFS_BS_DIR                "." LX_AUTOFS_NAME
  53 
  54 #define LX_AUTOFS_VFS_ID_HASH_SIZE      15
  55 #define LX_AUTOFS_VFS_PATH_HASH_SIZE    15
  56 #define LX_AUTOFS_VFS_VN_HASH_SIZE      15
  57 
  58 /*
  59  * VFS data object.
  60  */
  61 typedef struct lx_autofs_vfs {
  62         /* Info about the underlying filesystem and backing store. */
  63         vnode_t         *lav_mvp;
  64         char            *lav_bs_name;
  65         vnode_t         *lav_bs_vp;
  66 
  67         /* Info about the automounter process managing this filesystem. */
  68         int             lav_fd;
  69         pid_t           lav_pgrp;
  70         file_t          *lav_fifo_wr;
  71         file_t          *lav_fifo_rd;
  72 
  73         /* Each automount requests needs a unique id. */
  74         id_space_t      *lav_ids;
  75 
  76         /* All remaining structure members are protected by lav_lock. */
  77         kmutex_t        lav_lock;
  78 
  79         /* Hashes to keep track of outstanding automounter requests. */
  80         mod_hash_t      *lav_path_hash;
  81         mod_hash_t      *lav_id_hash;
  82 
  83         /* We need to keep track of all our vnodes. */
  84         vnode_t         *lav_root;
  85         mod_hash_t      *lav_vn_hash;
  86 } lx_autofs_vfs_t;
  87 
  88 /*
  89  * Structure to keep track of requests sent to the automounter.
  90  */
  91 typedef struct lx_autofs_lookup_req {
  92         /* Packet that gets sent to the automounter. */
  93         lx_autofs_pkt_t lalr_pkt;
  94 
  95         /* Reference count.  Always updated atomically. */
  96         uint_t          lalr_ref;
  97 
  98         /*
  99          * Fields to keep track and sync threads waiting on a lookup.
 100          * Fields are protected by lalr_lock.
 101          */
 102         kmutex_t        lalr_lock;
 103         kcondvar_t      lalr_cv;
 104         int             lalr_complete;
 105 } lx_autofs_lookup_req_t;
 106 
 107 /*
 108  * Generic stack structure.
 109  */
 110 typedef struct stack_elem {
 111         list_node_t     se_list;
 112         caddr_t         se_ptr1;
 113         caddr_t         se_ptr2;
 114         caddr_t         se_ptr3;
 115 } stack_elem_t;
 116 
 117 #ifdef  __cplusplus
 118 }
 119 #endif
 120 
 121 #endif  /* _LX_AUTOFS_IMPL_H */