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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27/* 28 * Portions Copyright 2007-2011 Apple Inc. 29 */ 30 31/* 32 * Information kept for each trigger vnode. 33 * This is opaque outside the autofs project. 34 */ 35struct trigger_info { 36 TAILQ_ENTRY(trigger_info) ti_entries; 37 /* tail queue of resolved triggers */ 38 lck_mtx_t *ti_lock; /* mutex protecting accesses */ 39 uint32_t ti_seq; /* sequence number of state changes */ 40 u_int ti_flags; 41 int ti_error; 42 fsid_t ti_this_fsid; /* fsid of file system for this trigger */ 43 fsid_t ti_mounted_fsid; 44 /* fsid of file system mounted atop this */ 45 time_t ti_ref_time; /* last reference to this trigger */ 46 int (*ti_check_notrigger_process)(int); 47 /* call this to check whether this process should trigger mounts */ 48 int (*ti_check_nowait_process)(int); 49 /* call this to check whether this process should block on mount-in-progress */ 50 int (*ti_check_homedirmounter_process)(vnode_t, int); 51 /* call this to check whether this process is a home directory mounter */ 52 int (*ti_check_homedirmount)(vnode_t); 53 /* call this to check whether this trigger is having a home directory mount done */ 54 void *(*ti_get_mount_args)(vnode_t, vfs_context_t, int *); 55 /* call this to get mount arguments */ 56 int (*ti_do_mount)(void *); 57 /* call this to make the mount upcall */ 58 void (*ti_rel_mount_args)(void *); 59 /* call this to release mount arguments */ 60 void (*ti_rearm)(vnode_t, int); 61 /* call this on a rearm */ 62 void (*ti_reclaim)(void *); 63 /* call this on a reclaim */ 64 void *ti_private; /* private data, if any */ 65}; 66 67#define TF_INPROG 0x00000001 /* a mount is in progress for this trigger */ 68#define TF_WAITING 0x00000002 /* somebody's waiting for that mount to finish */ 69#define TF_FORCEMOUNT 0x00000004 /* all operations cause a mount */ 70#define TF_AUTOFS 0x00000008 /* an autofs mount will be done atop this trigger */ 71#define TF_DONTUNMOUNT 0x00000010 /* don't auto-unmount or preemptively unmount this */ 72#define TF_DONTPREUNMOUNT 0x00000020 /* don't preemptively unmount this */ 73#define TF_RESOLVED 0x00000040 /* trigger is on the resolved list */ 74 75/* 76 * Call used by the automounter to specify some additional routines 77 * to call. 78 */ 79extern trigger_info_t *trigger_new_autofs(struct vnode_trigger_param *vnt, 80 u_int flags, 81 int (*check_notrigger_process)(int), 82 int (*check_nowait_process)(int), 83 int (*check_homedirmounter_process)(vnode_t, int), 84 int (*check_homedirmount)(vnode_t), 85 void *(*get_mount_args)(vnode_t, vfs_context_t, int *), 86 int (*do_mount)(void *), 87 void (*rel_mount_args)(void *), 88 void (*rearm)(vnode_t, int), 89 void (*reclaim)(void *), 90 void *private); 91 92/* 93 * Set the mount timeout. 94 */ 95extern void trigger_set_mount_to(int); 96 97extern int auto_get_automountd_port(mach_port_t *automount_port); 98extern void auto_release_port(mach_port_t port); 99extern kern_return_t auto_new_thread(void (*)(void *), void *); 100 101/* 102 * Look at all triggered mounts, and, for each mount, if it is an 103 * unconditional operation or if it hasn't been referred to recently, 104 * unmount it. 105 */ 106extern void unmount_triggered_mounts(int unconditional); 107