manifest_find.c revision 293e3ab30a546cd932ee22f9d54b3979fcb52095
f808c858fa61e7769218966759510a8b1190dfcfraf * CDDL HEADER START
f808c858fa61e7769218966759510a8b1190dfcfraf * The contents of this file are subject to the terms of the
f808c858fa61e7769218966759510a8b1190dfcfraf * Common Development and Distribution License (the "License").
f808c858fa61e7769218966759510a8b1190dfcfraf * You may not use this file except in compliance with the License.
f808c858fa61e7769218966759510a8b1190dfcfraf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f808c858fa61e7769218966759510a8b1190dfcfraf * See the License for the specific language governing permissions
f808c858fa61e7769218966759510a8b1190dfcfraf * and limitations under the License.
f808c858fa61e7769218966759510a8b1190dfcfraf * When distributing Covered Code, include this CDDL HEADER in each
f808c858fa61e7769218966759510a8b1190dfcfraf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f808c858fa61e7769218966759510a8b1190dfcfraf * If applicable, add the following below this CDDL HEADER, with the
f808c858fa61e7769218966759510a8b1190dfcfraf * fields enclosed by brackets "[]" replaced with your own identifying
f808c858fa61e7769218966759510a8b1190dfcfraf * information: Portions Copyright [yyyy] [name of copyright owner]
f808c858fa61e7769218966759510a8b1190dfcfraf * CDDL HEADER END
f808c858fa61e7769218966759510a8b1190dfcfraf * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
f808c858fa61e7769218966759510a8b1190dfcfraf * The primary role of this file is to obtain a list of manifests that are
f808c858fa61e7769218966759510a8b1190dfcfraf * located in a specified directory or one of its subdirectories. The
f808c858fa61e7769218966759510a8b1190dfcfraf * find_manifests() function provides this service, and
f808c858fa61e7769218966759510a8b1190dfcfraf * free_manifest_array() is used to free the memory associated with the
f808c858fa61e7769218966759510a8b1190dfcfraf * returned list.
f808c858fa61e7769218966759510a8b1190dfcfraf * The find_manifests() function can return an array consisting of all the
f808c858fa61e7769218966759510a8b1190dfcfraf * .xml files in the directory and its subdirectories. Alternatively,
f808c858fa61e7769218966759510a8b1190dfcfraf * find_manifests() can be asked to only return new manifests based on the
f808c858fa61e7769218966759510a8b1190dfcfraf * return of mhash_test_file(). The list that is returned is an array of
f808c858fa61e7769218966759510a8b1190dfcfraf * pointers to manifest_info structures.
f808c858fa61e7769218966759510a8b1190dfcfraf * Implementation Notes:
f808c858fa61e7769218966759510a8b1190dfcfraf * ====================
f808c858fa61e7769218966759510a8b1190dfcfraf * This module makes use of the nftw(3C) function to scan the directory.
f808c858fa61e7769218966759510a8b1190dfcfraf * nftw() calls a processing function for every file that it finds.
f808c858fa61e7769218966759510a8b1190dfcfraf * Unfortunately, nftw does not allow us to pass in any structure pointers
f808c858fa61e7769218966759510a8b1190dfcfraf * to the processing function, and that makes it hard to accumulate a list.
f808c858fa61e7769218966759510a8b1190dfcfraf * Thus, we will use the thread specific data area to hold data that must
f808c858fa61e7769218966759510a8b1190dfcfraf * be retained between calls to the processing function. This will allow
f808c858fa61e7769218966759510a8b1190dfcfraf * this module to be used in multi-threaded applications if the need