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.
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.
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]
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
25 #include <sys/types.h>
26 #include <sys/systm.h>
28 #include <sys/errno.h>
30 #include <sys/policy.h>
32 #include <sys/fs/autofs.h>
34 extern struct autofs_globals
*autofs_zone_init(void);
37 autofssys(enum autofssys_op opcode
, uintptr_t arg
)
42 case AUTOFS_UNMOUNTALL
: { /* attempt to remove all autofs mounts */
45 struct autofs_globals
*fngp
;
47 zoneid
= (zoneid_t
)arg
;
48 if (secpolicy_fs_unmount(CRED(), NULL
) != 0 ||
49 crgetzoneid(CRED()) != GLOBAL_ZONEID
)
50 return (set_errno(EPERM
));
51 if ((zone
= zone_find_by_id(zoneid
)) == NULL
)
52 return (set_errno(EINVAL
));
53 mutex_enter(&autofs_minor_lock
);
54 fngp
= zone_getspecific(autofs_key
, zone
);
56 mutex_exit(&autofs_minor_lock
);
59 * There were no mounts, so no work to do. Success.
63 mutex_exit(&autofs_minor_lock
);
64 unmount_tree(fngp
, B_TRUE
);
68 case AUTOFS_SETDOOR
: { /* set door handle for zone */
70 struct autofs_globals
*fngp
;
73 * We need to use the minor_lock to serialize setting this.
75 mutex_enter(&autofs_minor_lock
);
76 fngp
= zone_getspecific(autofs_key
, curproc
->p_zone
);
78 fngp
= autofs_zone_init();
79 (void) zone_setspecific(autofs_key
,
80 curproc
->p_zone
, fngp
);
82 mutex_exit(&autofs_minor_lock
);
85 if (copyin((uint_t
*)arg
, &did
, sizeof (uint_t
)))
86 return (set_errno(EFAULT
));
88 mutex_enter(&fngp
->fng_autofs_daemon_lock
);
89 if (fngp
->fng_autofs_daemon_dh
)
90 door_ki_rele(fngp
->fng_autofs_daemon_dh
);
91 fngp
->fng_autofs_daemon_dh
= door_ki_lookup(did
);
92 fngp
->fng_autofs_pid
= curproc
->p_pid
;
93 mutex_exit(&fngp
->fng_autofs_daemon_lock
);
100 return (error
? set_errno(error
) : 0);