/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include "mt.h"
#include "uucp.h"
static void stlock(char *);
static int onelock(char *, char *, char *);
/*
* make a lock file with given 'name'
* If one already exists, send a signal 0 to the process--if
* it fails, then unlink it and make a new one.
*
* input:
* name - name of the lock file to make
*
* return:
* 0 -> success
* FAIL -> failure
*/
static int
{
static char *tempfile;
if (pid[0] == '\0') {
return (FAIL);
(long)getpid());
}
return (FAIL);
else {
return (FAIL);
}
}
}
return (0);
}
/*
* check to see if the lock file exists and is still active
* - use kill(pid, 0)
*
* return:
* 0 -> success (lock file removed - no longer active
* FAIL -> lock file still active
*/
static int
{
int ret;
int fd;
if (fd == -1) {
return (0);
}
errno);
goto unlk;
}
goto unlk;
}
"");
return (FAIL);
}
/* process no longer active */
unlk:
return (FAIL);
}
return (0);
}
static int Nlocks = 0;
/*
* put name in list of lock files
* return:
* none
*/
static void
{
int i;
char *p;
for (i = 0; i < Nlocks; i++) {
break;
}
if (i >= Nlocks)
i = Nlocks++;
Lockfile[i] = p;
}
/*
* remove the named lock. If named lock is NULL,
* then remove all locks currently in list.
* return:
* none
*/
static void
{
int i;
for (i = 0; i < Nlocks; i++) {
continue;
}
}
}
/*
* makes a lock on behalf of pid.
* input:
* pid - process id
* tempfile - name of a temporary in the same file system
* name - lock file name (full path name)
* return:
* -1 - failed
* 0 - lock made successfully
*/
static int
{
int fd;
if (fd < 0) {
return (-1);
}
/* +1 for '\n' */
return (-1);
}
}
return (-1);
}
}
return (0);
}
/*
* fd_mklock(fd) - lock the device indicated by fd is possible
*
* return -
* SUCCESS - this process now has the fd locked
* FAIL - this process was not able to lock the fd
*/
static int
{
int tries = 0;
return (FAIL);
"%s.%3.3lu.%3.3lu.%3.3lu", L_LOCK,
return (FAIL);
return (FAIL);
}
(void) sleep(2);
}
return (SUCCESS);
}
/*
* remove the locks associated with the device file descriptor
*
* return -
* SUCCESS - both BNU lock file and advisory locks removed
* FAIL -
*/
static void
{
"%s.%3.3lu.%3.3lu.%3.3lu", L_LOCK,
}
}