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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * file.c - file dependency vertex code
32 * In principle, file dependencies should be retested on mount/unmount
33 * events, and dependency error flow used to determine whether a lost file
34 * affects the dependent service. If mount/unmount events are not available,
35 * the kstat facility (which registers or deregisters a statistic at
36 * mount/umount) could be used as an indirect filesystem event detector.
38 * In practice, file dependencies are checked only for existence at start
43 #include <sys/types.h>
52 file_ready(graph_vertex_t
*v
)
57 char *file_fmri
= v
->gv_name
;
60 * Advance through file: FMRI until we have an absolute file path.
62 if (strncmp(file_fmri
, "file:///", sizeof ("file:///") - 1) == 0) {
63 fn
= file_fmri
+ sizeof ("file://") - 1;
64 } else if (strncmp(file_fmri
, "file://localhost/",
65 sizeof ("file://localhost/") - 1) == 0) {
66 fn
= file_fmri
+ sizeof ("file://localhost") - 1;
67 } else if (strncmp(file_fmri
, "file://", sizeof ("file://") - 1)
69 fn
= file_fmri
+ sizeof ("file://") - 1;
72 * Again, search for the next '/'.
74 if ((fn
= strchr(fn
, '/')) == NULL
)
79 * If stat(2) succeeds for that path, then the dependency is satisfied.
83 } while (r
== -1 && errno
== EINTR
);
85 return (r
== -1 ? 0 : 1);