fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _CFG_LOCKD_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _CFG_LOCKD_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum { LOCK_NOTLOCKED, /* Unlock message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_READ, /* ask for read lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_WRITE, /* ask for write lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_LOCKED, /* lock has been taken */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_LOCKEDBY, /* who has lock? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_STAT, /* ask daemon to print its state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LOCK_ACK /* acknowledge a notlocked msg */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } cfglockd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct sockaddr_in daemonaddr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct lock_msg {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t message;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pid_t pid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t order;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t seq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_PIDFILE "/var/tmp/.cfglockd.pid"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_SERVER_PORT 50121u
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_LF_EOF -1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_LF_OKAY 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CFG_LF_AGAIN 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_lfinit();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint cfg_filelock(int segment, int flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint cfg_fileunlock(int segment);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_readpid(int segment, pid_t *pidp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_writepid(int segment, pid_t pid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_enterpid();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint cfg_lockd_init();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecfglockd_t cfg_lockedby(pid_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_lockd_rdlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_lockd_wrlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_lockd_unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _CFG_LOCKD_H */