ulockf.c revision ace1a5f11236a072fca1b5e0ea1416a083a9f2aa
/*
* 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 2005 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 "uucp.h"
#include <unistd.h>
#ifdef V7
#define O_RDONLY 0
#endif
static void stlock();
static int onelock();
/*
* 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
*/
GLOBAL int
register char *name;
{
static char tempfile[MAXNAMESIZE];
#ifdef V8
char *cp;
#endif
if (pid[0] == '\0') {
}
#ifdef V8 /* this wouldn't be a problem if we used lock directories */
/* some day the truncation of system names will bite us */
#endif /* V8 */
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
*/
GLOBAL int
register char *name;
{
register int ret;
int fd;
if (fd == -1) {
return(0);
goto unlk;
}
goto unlk;
}
return(FAIL);
}
else { /* process no longer active */
}
unlk:
return(FAIL);
}
return(0);
}
/*
* put name in list of lock files
* return:
* none
*/
static void
char *name;
{
register int i;
char *p;
for (i = 0; i < Nlocks; i++) {
break;
}
if (i >= Nlocks)
i = Nlocks++;
Lockfile[i] = p;
return;
}
/*
* remove the named lock. If named lock is NULL,
* then remove all locks currently in list.
* return:
* none
*/
GLOBAL void
register char *name;
{
register int i;
#ifdef V8
char *cp;
#endif /* V8 */
for (i = 0; i < Nlocks; i++) {
continue;
}
}
return;
}
/*
* remove a lock file
*
* Parameters:
* pre - Path and first part of file name of the lock file to be
* removed.
* s - The suffix part of the lock file. The name of the lock file
* will be derrived by concatenating pre, a period, and s.
*
* return:
* none
*/
GLOBAL void
char * pre;
char *s;
{
char ln[MAXNAMESIZE];
return;
}
/*
* create lock file
*
* Parameters:
* pre - Path and first part of file name of the lock file to be
* created.
* name - The suffix part of the lock file. The name of the lock file
* will be derrived by concatenating pre, a period, and name.
*
* return:
* 0 -> success
* FAIL -> failure
*/
GLOBAL int
char * pre;
char *name;
{
char lname[MAXNAMESIZE];
/*
* if name has a '/' in it, then it's a device name and it's
* not in /dev (i.e., it's a remotely-mounted device or it's
* in a subdirectory of /dev). in either case, creating our normal
* mind. since we're using advisory filelocks on the devices
* themselves, it'll be safe.
*
* of course, programs and people who are used to looking at the
* lockfiles to find out what's going on are going to be a trifle
* misled. we really need to re-consider the lockfile naming structure
* to accomodate devices in directories other than /dev ... maybe in
* the next release.
*/
return(0);
}
/*
* 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
char *pid;
{
register int fd;
char cb[100];
if(fd < 0){
return(-1);
}
/* +1 for '\n' */
return (-1);
}
}
return(-1);
}
}
return(0);
}
/*
* fd_mklock(fd) - lock the device indicated by fd if possible
*
* return -
* SUCCESS - this process now has the fd locked
* FAIL - this process was not able to lock the fd
*/
GLOBAL int
int fd;
{
int tries = 0;
return(FAIL);
return(FAIL);
return(FAIL);
}
sleep(2);
}
return(SUCCESS);
}
/*
* fn_cklock(name) - determine if the device indicated by name is locked
*
* return -
* SUCCESS - the name is not locked
* FAIL - the name is locked by another process
*/
GLOBAL int
char *name;
{
/* we temporarily use lockname to hold full path name */
return(FAIL);
}
/*
* fd_cklock(fd) - determine if the device indicated by fd is locked
*
* return -
* SUCCESS - the fd is not locked
* FAIL - the fd is locked by another process
*/
GLOBAL int
int fd;
{
return(FAIL);
return(FAIL);
else
}
/*
* remove the locks associated with the device file descriptor
*
* return -
* SUCCESS - both BNU lock file and advisory locks removed
* FAIL -
*/
GLOBAL void
int fd;
{
}
return;
}
#ifdef BSD4_2
static int
long size;
{
int ret;
if (size != 0) {
return (-1);
}
switch (cmd) {
case F_LOCK:
break;
case F_TLOCK:
break;
case F_ULOCK:
break;
case F_TEST:
return (0);
return (-1);
default:
return (-1);
}
}
#endif /* BSD4_2 */