2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * We maintain a single list of all active cases across all 2N/A * subsidary diagnosis "modules". We also offer some serialization 2N/A * To open a new case a subsidiary engine should use swde_case_open 2N/A * indicating the subsidiary id (from which we lookup the enum sw_casetype) 2N/A * and, optionally, a pointer to a structure for serialization and its size. 2N/A * For each case opened with swde_case_open we maintain an swde_case_t 2N/A * structure in-core. Embedded in this is the swde_case_data_t with 2N/A * information we need to keep track of and manage this case - it's 2N/A * case type, buffer name used for the sub-de-private data (if any) 2N/A * and the size of the sub-de-private structure. It is this 2N/A * embedded structure which is serialized as the "casedata" buffer, 2N/A * while the subsidiary-private structure is serialized into another buffer 2N/A * "casedata_<casetype-in-hex>". 2N/A * The subsidiary-private data structure, if any, is required to start 2N/A * with a uint32_t recording the data structure version. This 2N/A * version is also specified as an argument to swde_case_open, and 2N/A * we note it in the "casedata" buffer we write out and require 2N/A * a match on restore. 2N/A * When we unserialize we restore our management structure as well as 2N/A * the sub-de-private structure. 2N/A * Here's how serialization works: 2N/A * In swde_case_open we create a case data buffer for the case named 2N/A * SW_CASE_DATA_BUFNAME. We write the buffer out after filling in the 2N/A * structure version and recording the type of case this is, and if there 2N/A * is data for the subsidiary then we call swde_subdata to note the 2N/A * size and version of that data in the case data buf and then to create 2N/A * and write the subdata in a buffer named SW_CASE_DATA_BUFNAME_<casetype>. 2N/A * If the subsidiary updates its case data it is required to call 2N/A * swde_case_data_write. This just calls fmd_buf_write for the subsidiary 2N/A * A subsidiary can retrieve its private data buffer for a case using 2N/A * swde_case_data. This also fills a uint32_t with the version of the 2N/A * buffer that we have for this subsidiary; if that is an old version 2N/A * the subsidiary can cast appropriately and/or upgrade the buffer as 2N/A * When the host module is reloaded it calls swde_case_init to iterate 2N/A * through all cases we own. For each we call swde_case_unserialize 2N/A * which restores our case tracking data and any subsidiary-private 2N/A * data that our case data notes. We then call swde_case_verify which 2N/A * calls any registered verify function in the subsidiary owner, and if this 2N/A * returns 0 the case is closed. 2N/A * After initial write, we don't usually have to update the 2N/A * SW_CASE_DATA_BUFNAME buffer unless the subsidiary changes the size or 2N/A * version of its private buffer. To do that the subsidiary must call 2N/A * swde_case_data_upgrade. In that function we destroy the old subsidiary 2N/A * buffer and, if there is still a subsidiary data structure, create a 2N/A * new buffer appropriately sized and call swde_subdata to write it out 2N/A * after updating our case structure with new size etc. Finally we write 2N/A * out our updated case data structure. 2N/A * In-core case structure. "version %u but received %u\n",
"does not match argument\n");
* fmdo_close entry point for software-diagnosis * Now that the sub-de has had a chance to clean up, do some ourselves. * Note that we free the sub-de-private subdata structure.