]>
git.saurik.com Git - apple/system_cmds.git/blob - bootlog.tproj/bootlog.c
5f735a362115260c80751859859607c8e2374b01
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
18 * License for the specific language governing rights and limitations
21 * @APPLE_LICENSE_HEADER_END@
25 #include <sys/types.h>
26 #include <sys/socket.h>
27 #include <sys/sysctl.h>
35 #define _PATH_ASL_IN "/var/run/asl_input"
44 struct sockaddr_un server
;
48 sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
52 memset(&server
, 0, sizeof(struct sockaddr_un
));
53 server
.sun_family
= AF_UNIX
;
55 strcpy(server
.sun_path
, _PATH_ASL_IN
);
56 server
.sun_len
= strlen(server
.sun_path
) + 1;
57 len
= sizeof(server
.sun_len
) + sizeof(server
.sun_family
) + server
.sun_len
;
61 status
= connect(sock
, (const struct sockaddr
*)&server
, len
);
75 int mib
[2] = {CTL_KERN
, KERN_BOOTTIME
};
79 bzero(&utx
, sizeof(utx
));
80 utx
.ut_type
= BOOT_TIME
;
81 utx
.ut_pid
= 1; // on behave of launchd
83 /* get the boot time */
84 len
= sizeof(struct timeval
);
85 if(sysctl(mib
, 2, &utx
.ut_tv
, &len
, NULL
, 0) < 0)
86 gettimeofday(&utx
.ut_tv
, NULL
); /* fallback to now */
88 /* wait for asl before logging */