2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
28 #include "configd_server.h"
32 #define SNAPSHOT_PATH_CACHE _PATH_VARTMP "configd-cache.xml"
33 #define SNAPSHOT_PATH_SESSION _PATH_VARTMP "configd-session.xml"
37 _SCDSnapshot(SCDSessionRef session
)
42 SCDLog(LOG_DEBUG
, CFSTR("_SCDSnapshot:"));
44 /* Save a snapshot of the "cache" data */
46 (void) unlink(SNAPSHOT_PATH_CACHE
);
47 fd
= open(SNAPSHOT_PATH_CACHE
, O_WRONLY
|O_CREAT
|O_TRUNC
, 0644);
52 xmlData
= CFPropertyListCreateXMLData(NULL
, cacheData
);
53 (void) write(fd
, CFDataGetBytePtr(xmlData
), CFDataGetLength(xmlData
));
57 /* Save a snapshot of the "session" data */
59 (void) unlink(SNAPSHOT_PATH_SESSION
);
60 fd
= open(SNAPSHOT_PATH_SESSION
, O_WRONLY
|O_CREAT
|O_TRUNC
, 0644);
65 /* Save a snapshot of the "session" data */
67 xmlData
= CFPropertyListCreateXMLData(NULL
, sessionData
);
68 (void) write(fd
, CFDataGetBytePtr(xmlData
), CFDataGetLength(xmlData
));
77 _snapshot(mach_port_t server
, int *scd_status
)
79 serverSessionRef mySession
= getSession(server
);
81 SCDLog(LOG_DEBUG
, CFSTR("Snapshot configuration database."));
83 *scd_status
= _SCDSnapshot(mySession
->session
);
84 if (*scd_status
!= SCD_OK
) {
85 SCDLog(LOG_DEBUG
, CFSTR(" SCDUnlock(): %s"), SCDError(*scd_status
));