Move uucplock into libutil and create a manual page.
This commit is contained in:
parent
0ae8758e00
commit
568b59b9df
@ -5,9 +5,10 @@ SHLIB_MAJOR= 2
|
||||
SHLIB_MINOR= 2
|
||||
CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR} -I/sys
|
||||
SRCS= login.c login_tty.c logout.c logwtmp.c pty.c setproctitle.c \
|
||||
login_cap.c login_class.c login_auth.c login_times.c login_ok.c
|
||||
login_cap.c login_class.c login_auth.c login_times.c login_ok.c \
|
||||
uucplock.c
|
||||
MAN3+= login.3 login_tty.3 logout.3 logwtmp.3 pty.3 setproctitle.3 \
|
||||
login_cap.3 login_class.3 login_times.3 login_ok.3
|
||||
login_cap.3 login_class.3 login_times.3 login_ok.3 uucplock.3
|
||||
MAN5+= login.conf.5
|
||||
MLINKS+= pty.3 openpty.3 pty.3 forkpty.3
|
||||
MLINKS+=login_cap.3 login_getclassbyname.3 login_cap.3 login_close.3 \
|
||||
@ -23,6 +24,7 @@ MLINKS+=login_times.3 parse_lt.3 login_times.3 in_ltm.3 \
|
||||
login_times.3 in_lts.3
|
||||
MLINKS+=login_ok.3 auth_ttyok.3 login_ok.3 auth_hostok.3 \
|
||||
login_ok.3 auth_timeok.3
|
||||
MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_unlock.3
|
||||
|
||||
beforeinstall:
|
||||
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/libutil.h \
|
||||
|
@ -18,7 +18,7 @@
|
||||
* 5. Modifications may be freely made to this file providing the above
|
||||
* conditions are met.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: libutil.h,v 1.4 1997/02/22 15:08:14 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _LIBUTIL_H_
|
||||
@ -41,6 +41,8 @@ int openpty __P((int *amaster, int *aslave, char *name,
|
||||
struct termios *termp, struct winsize *winp));
|
||||
int forkpty __P((int *amaster, char *name,
|
||||
struct termios *termp, struct winsize *winp));
|
||||
int uu_lock __P((char *ttyname));
|
||||
int uu_unlock __P((char *ttyname));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_LIBUTIL_H_ */
|
||||
|
108
lib/libutil/uucplock.3
Normal file
108
lib/libutil/uucplock.3
Normal file
@ -0,0 +1,108 @@
|
||||
.\"
|
||||
.\" Copyright (c) 1996 Brian Somers <brian@awfulhak.demon.co.uk>
|
||||
.\"
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\" "
|
||||
.Dd March 30, 1997
|
||||
.Os
|
||||
.Dt uucplock 3
|
||||
.Sh NAME
|
||||
.Nm uu_lock ,
|
||||
.Nm uu_unlock
|
||||
.Nd acquire and release control of a serial device
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <libutil.h>
|
||||
.Ft int
|
||||
.Fn uu_lock "char *ttyname"
|
||||
.Ft int
|
||||
.Fn uu_unlock "char *ttyname"
|
||||
.Pp
|
||||
Link with
|
||||
.Va -lutil
|
||||
on the
|
||||
.Xr cc 1
|
||||
command line.
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn uu_lock
|
||||
function attempts to create a lock file called
|
||||
.Dq /var/spool/lock/LCK..
|
||||
with a suffix given by the passed
|
||||
.Fa ttyname .
|
||||
If the file already exists, it is expected to contain the process
|
||||
id of the locking program.
|
||||
.Pp
|
||||
If the file does not already exist, or the owning process given by
|
||||
the process id found in the lock file is no longer running,
|
||||
.Fn uu_lock
|
||||
will write its own process id into the file and return success.
|
||||
.Pp
|
||||
.Fn uu_unlock
|
||||
removes the lockfile created by
|
||||
.Fn uu_lock
|
||||
for the given
|
||||
.Fa ttyname .
|
||||
Care should be taken that
|
||||
.Fn uu_lock
|
||||
was successful before calling
|
||||
.Fn uu_unlock .
|
||||
.Sh RETURN VALUES
|
||||
Both
|
||||
.Fn uu_lock
|
||||
and
|
||||
.Fn uu_unlock
|
||||
return 0 on success and -1 on failure.
|
||||
.Sh ERRORS
|
||||
On failure,
|
||||
.Fn uu_lock
|
||||
will log any unexpected errors using
|
||||
.Xr syslog 2 .
|
||||
If the lock already exists and contains the process id of a running
|
||||
process,
|
||||
.Fn uu_lock
|
||||
will silently fail. The value of
|
||||
.Dv errno
|
||||
can not be used to determine the cause of failure.
|
||||
.Pp
|
||||
.Fn uu_unlock
|
||||
will set the global variable
|
||||
.Dv errno
|
||||
to reflect the reason that the lock file could not be removed.
|
||||
Refer to the description of
|
||||
.Xr unlink 2
|
||||
for further details.
|
||||
.Sh BUGS
|
||||
Locking is not atomic. Should a race condition occur, it's entirely
|
||||
possible that both processes obtain the lock.
|
||||
.Pp
|
||||
It is possible that a stale lock is not recognised as such if a new
|
||||
processes is assigned the same processes id as the program that left
|
||||
the stale lock.
|
||||
.Pp
|
||||
The calling process must have write permissions to the
|
||||
.Dq /var/spool/lock
|
||||
directory. There is no mechanism in place to ensure that the
|
||||
permissions of this directory are the same as those of the
|
||||
serial devices that might be locked.
|
@ -1,14 +1,12 @@
|
||||
# @(#)Makefile 5.4 (Berkeley) 5/11/90
|
||||
#
|
||||
# $Header: /home/ncvs/src/sbin/slattach/Makefile,v 1.5 1995/09/19 03:27:23 ache Exp $
|
||||
# $Header: /home/ncvs/src/sbin/slattach/Makefile,v 1.6 1995/09/20 12:56:23 ache Exp $
|
||||
|
||||
PROG= slattach
|
||||
SRCS= slattach.c uucplock.c
|
||||
SRCS= slattach.c
|
||||
MAN8= slattach.8
|
||||
MLINKS= slattach.8 slip.8
|
||||
LDADD= -lutil
|
||||
DPADD= ${LIBUTIL}
|
||||
|
||||
.PATH: ${.CURDIR}/../startslip
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,6 +1,7 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
|
||||
PROG= startslip
|
||||
SRCS= startslip.c uucplock.c
|
||||
SRCS= startslip.c
|
||||
LDADD= -lutil
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -16,13 +16,11 @@ LIBACU=${.CURDIR}/../libacu/libacu.a
|
||||
PROG= tip
|
||||
CFLAGS+=-DUSE_PERROR
|
||||
DPADD= $(LIBACU)
|
||||
LDADD= $(LIBACU)
|
||||
LDADD= $(LIBACU) -lutil
|
||||
LINKS= ${BINDIR}/tip
|
||||
MAN1= tip.1
|
||||
MAN5= modems.5
|
||||
SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \
|
||||
remote.c tip.c tipout.c uucplock.c value.c vars.c
|
||||
|
||||
.PATH: ${.CURDIR}/../../../sbin/startslip
|
||||
remote.c tip.c tipout.c value.c vars.c
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,9 +1,9 @@
|
||||
# $Id: Makefile,v 1.15 1997/03/09 20:03:27 ache Exp $
|
||||
# $Id: Makefile,v 1.16 1997/03/13 12:45:26 brian Exp $
|
||||
|
||||
PROG= ppp
|
||||
SRCS= async.c auth.c ccp.c chap.c chat.c command.c filter.c fsm.c hdlc.c \
|
||||
ip.c ipcp.c lcp.c lqr.c log.c main.c mbuf.c modem.c os.c \
|
||||
pap.c pred.c route.c slcompress.c timer.c systems.c uucplock.c vars.c \
|
||||
pap.c pred.c route.c slcompress.c timer.c systems.c vars.c \
|
||||
vjcomp.c arp.c alias.c alias_db.c alias_ftp.c alias_util.c \
|
||||
passwdauth.c sig.c
|
||||
#CFLAGS+= -DHAVE_SHELL_CMD_WITH_ANY_MODE
|
||||
@ -14,6 +14,4 @@ MAN8= ppp.8
|
||||
BINMODE=4555
|
||||
BINOWN= root
|
||||
|
||||
.PATH: ${.CURDIR}/../../sbin/startslip
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
Loading…
Reference in New Issue
Block a user