File minicom-2.4-lockdev.diff of Package minicom.import4928
Index: minicom-2.5/src/main.c
===================================================================
--- minicom-2.5.orig/src/main.c
+++ minicom-2.5/src/main.c
@@ -164,6 +164,20 @@ int open_term(int doinit, int show_win_o
int s_errno;
#endif
+#ifdef USE_SOCKET
+#define SOCKET_PREFIX "unix#"
+ portfd_is_socket = portfd_is_connected = 0;
+ if (strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) == 0) {
+ portfd_is_socket = 1;
+ }
+#endif
+
+ lockfile[0] = 0;
+ if (portfd_is_socket)
+ goto nolock;
+
+#if !HAVE_LOCKDEV
+
/* First see if the lock file directory is present. */
if (P_LOCK[0] && stat(P_LOCK, &stt) == 0) {
@@ -211,10 +225,12 @@ int open_term(int doinit, int show_win_o
return -1;
}
}
+#endif
if (doinit > 0)
lockfile_create();
+nolock:
/* Run a special program to disable callin if needed. */
if (doinit > 0 && P_CALLOUT[0]) {
if (fastsystem(P_CALLOUT, NULL, NULL, NULL) < 0) {
@@ -232,11 +248,7 @@ int open_term(int doinit, int show_win_o
signal(SIGALRM, get_alrm);
alarm(4);
#ifdef USE_SOCKET
-#define SOCKET_PREFIX "unix#"
- portfd_is_socket = portfd_is_connected = 0;
- if (strncmp(dial_tty, SOCKET_PREFIX, strlen(SOCKET_PREFIX)) == 0) {
- portfd_is_socket = 1;
-
+ if (portfd_is_socket) {
portfd_sock_addr.sun_family = AF_UNIX;
strncpy(portfd_sock_addr.sun_path,
dial_tty + strlen(SOCKET_PREFIX),
Index: minicom-2.5/src/minicom.c
===================================================================
--- minicom-2.5.orig/src/minicom.c
+++ minicom-2.5/src/minicom.c
@@ -1570,7 +1570,7 @@ dirty_goto:
mc_wclose(stdwin, 1);
keyboard(KUNINSTALL, 0);
if (lockfile[0])
- unlink(lockfile);
+ ttyunlock(lockfile);
close(portfd);
if (quit != NORESET && P_CALLIN[0])
Index: minicom-2.5/src/minicom.h
===================================================================
--- minicom-2.5.orig/src/minicom.h
+++ minicom-2.5/src/minicom.h
@@ -35,6 +35,12 @@
#include <time.h>
+#if HAVE_LOCKDEV
+#include <ttylock.h>
+#else
+#define ttyunlock(x) unlink(x)
+#endif
+
#ifdef USE_SOCKET
#include <sys/socket.h>
#include <sys/un.h>
@@ -82,7 +88,7 @@ EXTERN int tempst; /* Status line is tem
EXTERN int escape; /* Escape code. */
EXTERN int disable_online_time; /* disable online time display */
-EXTERN char lockfile[128]; /* UUCP lock file of terminal */
+EXTERN char lockfile[1024]; /* UUCP lock file of terminal */
EXTERN char homedir[256]; /* Home directory of user */
EXTERN char logfname[PARS_VAL_LEN]; /* Name of the logfile */
EXTERN char username[16]; /* Who is using minicom? */
Index: minicom-2.5/src/updown.c
===================================================================
--- minicom-2.5.orig/src/updown.c
+++ minicom-2.5/src/updown.c
@@ -457,17 +457,28 @@ void updown(int what, int nr)
void lockfile_remove(void)
{
+ if (portfd_is_socket)
+ return;
+
if (lockfile[0])
- unlink(lockfile);
+ ttyunlock(lockfile);
}
void lockfile_create(void)
{
- int fd, n;
+ int n;
+#if !HAVE_LOCKDEV
+ int fd;
+ char buf[81];
+#endif
+
+ if (portfd_is_socket)
+ return;
if (!lockfile[0])
return;
+#if !HAVE_LOCKDEV
n = umask(022);
/* Create lockfile compatible with UUCP-1.2 */
if ((fd = open(lockfile, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0) {
@@ -484,6 +495,9 @@ void lockfile_create(void)
close(fd);
}
umask(n);
+#else
+ ttylock(lockfile);
+#endif
}
/*
Index: minicom-2.5/configure.in
===================================================================
--- minicom-2.5.orig/configure.in
+++ minicom-2.5/configure.in
@@ -38,6 +38,11 @@ if test "x$enable_socket" = xyes; then
AC_DEFINE(USE_SOCKET, [1], [Socket support is enabled])
fi
+PKG_PROG_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+ PKG_CHECK_MODULES([LOCKDEV], [lockdev], AC_DEFINE([HAVE_LOCKDEV],[1],[Define if you have lockdev]),[:])
+fi
+
AC_ARG_ENABLE([lock-dir],
AS_HELP_STRING([--enable-lock-dir=DIR],
[Set com line lock directory (def: try common locations)]),
Index: minicom-2.5/src/Makefile.am
===================================================================
--- minicom-2.5.orig/src/Makefile.am
+++ minicom-2.5/src/Makefile.am
@@ -29,7 +29,7 @@ confdir = @MINICOM_CONFDIR@
AM_CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/lib -DCONFDIR=\"$(confdir)\" \
-DLOCALEDIR=\"$(datadir)/locale\"
-minicom_LDADD = @LIBINTL@ $(MINICOM_LIBPORT)
+minicom_LDADD = @LIBINTL@ $(MINICOM_LIBPORT) $(LOCKDEV_LIBS)
minicom_keyserv_LDADD = @LIBINTL@ $(MINICOM_LIBPORT)
runscript_LDADD = @LIBINTL@ $(MINICOM_LIBPORT)