/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2010, Intel Corporation.
* All rights reserved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <syslog.h>
#include <string.h>
#include <strings.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <config_admin.h>
#include <libscf.h>
#include <libsysevent.h>
#include <stdarg.h>
/* Signal handler type */
typedef void (sig_handler_t)(int);
/* Program Name */
char *g_prog_name;
int g_debuglevel = 0;
static int s_pid_fd;
static int daemon_init(void);
static void daemon_quit(int);
static int set_sig_handler(int, sig_handler_t *);
static int acpihpd_init(void);
static void acpihpd_fini(void);
static void acpihpd_event(sysevent_t *);
void debug_print(int, const char *, ...);
int
{
int c;
/* Get Program Name */
g_prog_name = argv[0];
} else {
g_prog_name++;
}
switch (c) {
case 'd':
g_debuglevel = 0;
}
break;
case ':':
"missed argument for option %c.", optopt);
break;
case '?':
break;
}
}
/* Check the daemon running lock and initialize the signal */
if (daemon_init() != 0) {
}
/* Subscribe to the hotplug event */
if (acpihpd_init() != 0) {
}
/*CONSTCOND*/
while (1) {
(void) pause();
}
return (SMF_EXIT_OK);
}
static int
daemon_init(void)
{
int i, ret;
if (geteuid() != 0) {
return (1);
}
return (1);
}
if (pid > 0) {
/* Parent to exit. */
}
(void) setsid();
(void) chdir("/");
(void) umask(0);
(void) closefrom(0);
(void) dup(1);
/*
* Create the lock file for singleton
*/
debug_print(0, "could not create pid file: %s",
return (1);
}
debug_print(0, "another acpihpd is already running");
} else {
debug_print(0, "could not lock pid file");
}
return (1);
}
continue;
}
if (ret < 0) {
debug_print(0, "pid file write failed: %s",
return (1);
}
}
return (1);
}
return (1);
}
return (1);
}
return (1);
}
return (0);
}
static void
{
int status = 0;
acpihpd_fini();
(void) unlink(ACPIHPD_PID_FILE);
if (signo < 0) {
}
}
static int
{
}
return (1);
}
return (0);
}
static int
acpihpd_init(void)
{
return (-1);
}
return (-1);
}
return (0);
}
static void
acpihpd_fini(void)
{
if (s_acpihpd_hdl != NULL) {
}
}
static void
{
/* Inform cfgadm of the hot-plug event. */
}
void
{
if (level <= g_debuglevel) {
switch (level) {
case 0:
pr_out = 1;
break;
case 1:
pri = LOG_NOTICE;
pr_out = 1;
break;
case 2:
pr_out = 1;
break;
}
if (pr_out) {
}
}
}