/*
* 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
*/
/*
*/
#include <signal.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include "cfg_lockd.h"
static int lock_soc = 0;
static int locked;
static int initdone;
static int initresult;
static void cfg_lockd_reinit();
static void
{
int rc;
} else {
}
do {
#ifdef CFG_LOCKD_DEBUG
if (rc < 0) {
perror("send");
}
#endif
}
static void
{
int rc;
/* wait for response */
do {
if (!rc) {
#ifdef CFG_LOCKD_DEBUG
last_cmd);
#endif
}
do {
#ifdef CFG_LOCKD_DEBUG
if (rc < 0) {
perror("revcfrom");
}
#endif
}
static void
{
do {
}
static void
read_ack()
{
do {
}
void
{
#ifdef CFG_LOCKD_DEBUG
#endif
locked = 1;
read_reply();
#ifdef CFG_LOCKD_DEBUG
if (fp) {
}
sleep(3);
#endif
}
void
{
#ifdef CFG_LOCKD_DEBUG
#endif
locked = 1;
read_reply();
#ifdef CFG_LOCKD_DEBUG
if (fp) {
}
sleep(3);
#endif
}
void
{
#ifdef CFG_LOCKD_DEBUG
#endif
read_ack();
locked = 0;
#ifdef CFG_LOCKD_DEBUG
if (fp) {
}
sleep(3);
#endif
}
void
{
}
{
}
static void
{
if (locked)
}
static int
{
#ifdef CFG_LOCKD_DEBUG
perror("socket");
#endif
return (-1);
}
sizeof (clientaddr)) < 0) {
#ifdef CFG_LOCKD_DEBUG
perror("bind");
#endif
return (-1);
}
socket_pid = getpid();
return (0);
}
/*
* Re-initialise after a fork has been detected.
*
* Needs to create a new socket for new process to receive messages
* from the lock daemon and enter pid into lock file so that the daemon
* can detect new processes exit if it doesn't call unlock first.
*/
static void
{
if (lock_soc)
lock_soc = 0;
if (cfg_lockd_socket()) {
initresult = 0;
return;
}
cfg_enterpid();
initresult = 1;
}
int
{
if (initdone) {
/* only perform reinit if init worked first time */
return (initresult);
}
initdone = 1;
initresult = 0;
/* check if there's a lock daemon out there */
return (0);
return (0);
}
return (0);
/* there is a lock daemon */
cfg_lfinit();
cfg_enterpid();
if (cfg_lockd_socket())
return (0);
#ifdef CFG_LOCKD_DEBUG
#endif
return (0);
}
endhostent();
initresult = 1;
return (1);
}