- 1.0.3. No longer need 1.0.0-signal, 1.0.1-subdir, 1.0.1-fcntl,
1.0.1-32bit patches. - Renumbered patches and sources.
This commit is contained in:
parent
801ff01a7e
commit
649b6dcfed
@ -1 +1 @@
|
||||
lockdev_1.0.1.orig.tar.gz
|
||||
lockdev_1.0.3.orig.tar.gz
|
||||
|
@ -1,11 +0,0 @@
|
||||
--- lockdev-1.0.0/src/sample.c.jbj 2002-11-29 10:10:35.000000000 -0500
|
||||
+++ lockdev-1.0.0/src/sample.c 2002-11-29 10:12:24.000000000 -0500
|
||||
@@ -31,6 +31,8 @@
|
||||
}
|
||||
else dev = p;
|
||||
}
|
||||
+ if (dev == NULL)
|
||||
+ usage();
|
||||
i = 0;
|
||||
(void) dev_setpid(getppid());
|
||||
switch(ch) {
|
@ -1,41 +0,0 @@
|
||||
--- lockdev-1.0.0/src/baudboy.h Sat Apr 20 15:42:16 2002
|
||||
+++ lockdev-1.0.0-/src/baudboy.h Sat Apr 20 15:41:49 2002
|
||||
@@ -34,11 +34,11 @@
|
||||
|
||||
#define LOCKDEV_PATH "/usr/sbin/lockdev"
|
||||
|
||||
-static inline int doit(const char * argv[])
|
||||
+static inline int _doit(const char * argv[])
|
||||
{
|
||||
pid_t child;
|
||||
int status;
|
||||
- void (*osig) (int) = signal(SIGCHLD, SIG_IGN);
|
||||
+ void (*osig) (int) = signal(SIGCHLD, SIG_DFL);
|
||||
int rc;
|
||||
|
||||
if (!(child = fork())) {
|
||||
@@ -104,21 +104,21 @@
|
||||
{
|
||||
const char * argv[] = { LOCKDEV_PATH, "-l", NULL, NULL};
|
||||
argv[2] = devname;
|
||||
- return doit(argv);
|
||||
+ return _doit(argv);
|
||||
}
|
||||
|
||||
static inline int ttyunlock(const char * devname)
|
||||
{
|
||||
const char * argv[] = { LOCKDEV_PATH, "-u", NULL, NULL};
|
||||
argv[2] = devname;
|
||||
- return doit(argv);
|
||||
+ return _doit(argv);
|
||||
}
|
||||
|
||||
static inline int ttylocked(const char * devname)
|
||||
{
|
||||
const char * argv[] = { LOCKDEV_PATH, NULL, NULL};
|
||||
argv[1] = devname;
|
||||
- return doit(argv);
|
||||
+ return _doit(argv);
|
||||
}
|
||||
|
||||
static inline int ttywait(const char * devname)
|
@ -1,20 +0,0 @@
|
||||
--- lockdev-1.0.1/src/lockdev.c.32bit 2005-09-21 11:23:36.000000000 +0200
|
||||
+++ lockdev-1.0.1/src/lockdev.c 2005-09-21 11:55:22.000000000 +0200
|
||||
@@ -228,13 +228,13 @@
|
||||
_debug( 3, "_dl_filename_1 (stat=%d)\n", (int)st->st_rdev);
|
||||
#if defined (__linux__)
|
||||
/* this changes the major from 5 to 4 if it was a cua device */
|
||||
- if ( (int)st->st_rdev >= (TTYAUX_MAJOR*256)+64
|
||||
- && (int)st->st_rdev <= (TTYAUX_MAJOR*256)+127 )
|
||||
- add = (TTY_MAJOR - TTYAUX_MAJOR)*256;
|
||||
+ if ( (int)st->st_rdev >= makedev(TTYAUX_MAJOR,64)
|
||||
+ && (int)st->st_rdev <= makedev(TTYAUX_MAJOR,127))
|
||||
+ add = makedev((TTY_MAJOR - TTYAUX_MAJOR),0);
|
||||
#endif /* __linux__ */
|
||||
/* lockfile of type /var/lock/LCK.004.064 */
|
||||
l = sprintf( name, "%s/LCK.%03d.%03d", LOCK_PATH,
|
||||
- (int)MAJOR( add+st->st_rdev), (int)MINOR( add+st->st_rdev));
|
||||
+ (int)major(add+st->st_rdev), (int)minor(add+st->st_rdev));
|
||||
_debug( 2, "_dl_filename_1 () -> len=%d, name=%s<\n", l, name);
|
||||
return l;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
--- lockdev-1.0.1/src/lockdev.c.orig 2003-08-18 17:13:31.000000000 -0400
|
||||
+++ lockdev-1.0.1/src/lockdev.c 2003-08-18 17:13:43.000000000 -0400
|
||||
@@ -487,17 +487,18 @@
|
||||
* maybe we should check it and do something if not?
|
||||
*/
|
||||
p = devname; /* only a filename */
|
||||
- while ( (m=strrchr( p, '/')) != 0 ) {
|
||||
- p = m+1; /* was pointing to the slash */
|
||||
+ p += strspn(p, " \t\r\n\v\f\a"); /* skip leading whitespace */
|
||||
+ if (strncmp(p, DEV_PATH, strlen(DEV_PATH)) == 0) {
|
||||
+ p += strlen(DEV_PATH); /* 1st char after slash */
|
||||
_debug( 3, "_dl_check_devname(%s) name = %s\n", devname, p);
|
||||
if ( strcmp( p, "tty") == 0 )
|
||||
p = ttyname( 0); /* this terminal, if it exists */
|
||||
}
|
||||
- if ( ((l=strlen( p)) == 0 ) || ( l > (MAXPATHLEN - strlen(LOCK_PATH)) ))
|
||||
- return 0;
|
||||
- if ( ! (m = malloc( 1 + l)) )
|
||||
- return 0;
|
||||
- return strcpy( m, p);
|
||||
+ if (((l = strlen(p)) == 0) || (l > (MAXPATHLEN - strlen(LOCK_PATH))))
|
||||
+ return NULL;
|
||||
+ if ((m = malloc(++l)) == NULL)
|
||||
+ return NULL;
|
||||
+ return strcpy(m, p);
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
--- lockdev-1.0.1/src/baudboy.h.kzak 2005-09-01 15:32:30.000000000 +0200
|
||||
+++ lockdev-1.0.1/src/baudboy.h 2005-09-01 15:32:49.000000000 +0200
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
@ -1,21 +0,0 @@
|
||||
diff -up lockdev-1.0.1/src/sample.c.kzak lockdev-1.0.1/src/sample.c
|
||||
--- lockdev-1.0.1/src/sample.c.kzak 2008-10-06 11:29:48.000000000 +0200
|
||||
+++ lockdev-1.0.1/src/sample.c 2008-10-06 11:30:26.000000000 +0200
|
||||
@@ -1,4 +1,8 @@
|
||||
#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
#include "lockdev.h"
|
||||
|
||||
void
|
||||
@@ -13,7 +17,7 @@ int debug;
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
- int i, chld;
|
||||
+ int i;
|
||||
char *p = NULL, *dev = NULL, ch;
|
||||
|
||||
ch = '\0';
|
@ -1,24 +0,0 @@
|
||||
--- lockdev-1.0.1/src/lockdev.c.subdir 2005-02-23 12:57:52.253199688 +0100
|
||||
+++ lockdev-1.0.1/src/lockdev.c 2005-02-23 13:08:27.193674064 +0100
|
||||
@@ -245,10 +245,19 @@
|
||||
char * name;
|
||||
const char * dev;
|
||||
{
|
||||
- int l;
|
||||
- _debug( 3, "_dl_filename_2 (dev=%s)\n", dev);
|
||||
+ int l, x;
|
||||
+ char *p;
|
||||
+
|
||||
/* lockfile of type /var/lock/LCK..ttyS2 */
|
||||
+ _debug( 3, "_dl_filename_2 (dev=%s)\n", dev);
|
||||
+ x = strlen(LOCK_PATH) + 6; /* 6= strlen("/LCK..") */
|
||||
l = sprintf( name, "%s/LCK..%s", LOCK_PATH, dev);
|
||||
+
|
||||
+ /* replace '/' by '_' for /dev sub-dirs (like pppd does it)
|
||||
+ */
|
||||
+ while ((p = strchr(name+x, '/')) != NULL) {
|
||||
+ *p = '_';
|
||||
+ }
|
||||
_debug( 2, "_dl_filename_2 () -> len=%d, name=%s<\n", l, name);
|
||||
return l;
|
||||
}
|
30
lockdev-1.0.3-checkname.patch
Executable file
30
lockdev-1.0.3-checkname.patch
Executable file
@ -0,0 +1,30 @@
|
||||
diff -up lockdev-1.0.3/src/lockdev.c.checkname lockdev-1.0.3/src/lockdev.c
|
||||
--- lockdev-1.0.3/src/lockdev.c.checkname 2009-12-05 15:40:16.000000000 +0100
|
||||
+++ lockdev-1.0.3/src/lockdev.c 2009-12-05 15:55:29.000000000 +0100
|
||||
@@ -487,18 +487,19 @@ _dl_check_devname (const char *devname)
|
||||
_debug( 3, "_dl_check_devname(%s) stripped name = %s\n", devname, p);
|
||||
} else {
|
||||
/* Otherwise, strip off everything but the device name. */
|
||||
- while ( (m=strrchr( p, '/')) != 0 ) {
|
||||
- p = m+1; /* was pointing to the slash */
|
||||
+ p += strspn(p, " \t\r\n\v\f\a"); /* skip leading whitespace */
|
||||
+ if (strncmp(p, DEV_PATH, strlen(DEV_PATH)) == 0) {
|
||||
+ p += strlen(DEV_PATH); /* 1st char after slash */
|
||||
_debug( 3, "_dl_check_devname(%s) name = %s\n", devname, p);
|
||||
}
|
||||
}
|
||||
if ( strcmp( p, "tty") == 0 )
|
||||
p = ttyname( 0); /* this terminal, if it exists */
|
||||
- if ( ((l=strlen( p)) == 0 ) || ( l > (MAXPATHLEN - strlen(LOCK_PATH)) ))
|
||||
- return 0;
|
||||
- if ( ! (m = malloc( 1 + l)) )
|
||||
- return 0;
|
||||
- return strcpy( m, p);
|
||||
+ if (((l = strlen(p)) == 0) || (l > (MAXPATHLEN - strlen(LOCK_PATH))))
|
||||
+ return NULL;
|
||||
+ if ((m = malloc(++l)) == NULL)
|
||||
+ return NULL;
|
||||
+ return strcpy(m, p);
|
||||
}
|
||||
|
||||
|
12
lockdev-1.0.3-cli.patch
Executable file
12
lockdev-1.0.3-cli.patch
Executable file
@ -0,0 +1,12 @@
|
||||
diff -up lockdev-1.0.3/src/sample.c.cli lockdev-1.0.3/src/sample.c
|
||||
--- lockdev-1.0.3/src/sample.c.cli 2009-12-05 15:40:16.000000000 +0100
|
||||
+++ lockdev-1.0.3/src/sample.c 2009-12-05 15:48:39.000000000 +0100
|
||||
@@ -32,6 +32,8 @@ main (int argc,
|
||||
}
|
||||
else dev = p;
|
||||
}
|
||||
+ if (dev == NULL)
|
||||
+ usage();
|
||||
i = 0;
|
||||
(void) dev_setpid(getppid());
|
||||
switch( ch ) {
|
20
lockdev-1.0.3-gccwarn.patch
Executable file
20
lockdev-1.0.3-gccwarn.patch
Executable file
@ -0,0 +1,20 @@
|
||||
diff -up lockdev-1.0.3/src/sample.c.gccwarn lockdev-1.0.3/src/sample.c
|
||||
--- lockdev-1.0.3/src/sample.c.gccwarn 2009-12-05 15:50:04.000000000 +0100
|
||||
+++ lockdev-1.0.3/src/sample.c 2009-12-05 16:49:40.000000000 +0100
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <unistd.h>
|
||||
#include "lockdev.h"
|
||||
|
||||
void
|
||||
@@ -14,7 +16,7 @@ int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
- int i, chld;
|
||||
+ int i;
|
||||
char *p = NULL, *dev = NULL, ch;
|
||||
|
||||
ch = '\0';
|
8
lockdev-1.0.1-man8.patch → lockdev-1.0.3-man8.patch
Normal file → Executable file
8
lockdev-1.0.1-man8.patch → lockdev-1.0.3-man8.patch
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
diff -up lockdev-1.0.1/Makefile.man8 lockdev-1.0.1/Makefile
|
||||
--- lockdev-1.0.1/Makefile.man8 2009-09-25 18:36:19.000000000 +0200
|
||||
+++ lockdev-1.0.1/Makefile 2009-09-25 18:37:00.000000000 +0200
|
||||
@@ -72,7 +72,9 @@ install_profile: ${static} ${shared}
|
||||
diff -up lockdev-1.0.3/Makefile.man8 lockdev-1.0.3/Makefile
|
||||
--- lockdev-1.0.3/Makefile.man8 2009-12-05 15:43:47.000000000 +0100
|
||||
+++ lockdev-1.0.3/Makefile 2009-12-05 16:52:13.000000000 +0100
|
||||
@@ -75,7 +75,9 @@ install_profile: ${static} ${shared}
|
||||
|
||||
install_doc: docs/lockdev.3
|
||||
install -m755 -d ${mandir}/man3
|
25
lockdev-1.0.1-pidexists.patch → lockdev-1.0.3-pidexists.patch
Normal file → Executable file
25
lockdev-1.0.1-pidexists.patch → lockdev-1.0.3-pidexists.patch
Normal file → Executable file
@ -1,42 +1,41 @@
|
||||
diff -Nru lockdev-1.0.1.orig/src/lockdev.c lockdev-1.0.1/src/lockdev.c
|
||||
--- lockdev-1.0.1.orig/src/lockdev.c 2004-07-17 19:17:48.000000000 +0300
|
||||
+++ lockdev-1.0.1/src/lockdev.c 2004-07-17 19:19:07.000000000 +0300
|
||||
@@ -147,7 +147,7 @@
|
||||
diff -up lockdev-1.0.3/src/lockdev.c.pidexists lockdev-1.0.3/src/lockdev.c
|
||||
--- lockdev-1.0.3/src/lockdev.c.pidexists 2009-12-05 15:56:46.000000000 +0100
|
||||
+++ lockdev-1.0.3/src/lockdev.c 2009-12-05 16:05:46.000000000 +0100
|
||||
@@ -148,7 +148,7 @@ static inline int _dl_lock_semaphore ( v
|
||||
static inline int _dl_block_semaphore ( void);
|
||||
static pid_t _dl_check_lock ( const char * lockname);
|
||||
static char * _dl_check_devname ( const char * devname);
|
||||
-
|
||||
+static inline int _dl_pid_exists ( pid_t pid );
|
||||
+static inline int _dl_pid_exists ( pid_t pid );
|
||||
|
||||
#define SEMAPHORE "LOCKDEV"
|
||||
#define close_n_return( v) return( _dl_unlock_semaphore( v))
|
||||
@@ -400,7 +400,7 @@
|
||||
@@ -394,7 +394,7 @@ _dl_check_lock(const char *lockname)
|
||||
/* checks content's format */
|
||||
if ( j == 1 ) {
|
||||
/* checks process existence */
|
||||
- if ( kill( pid_read, 0) == 0 ) {
|
||||
+ if ( _dl_pid_exists( pid_read)) {
|
||||
- if ( ( kill( pid_read, 0) == 0 ) || (errno == EPERM) ) {
|
||||
+ if ( _dl_pid_exists( pid_read) || (errno == EPERM) ) {
|
||||
_debug( 2, "_dl_check_lock() locked by %d\n", (int)pid_read);
|
||||
return pid_read;
|
||||
}
|
||||
@@ -449,7 +449,7 @@
|
||||
@@ -443,7 +443,7 @@ _dl_check_lock(const char *lockname)
|
||||
return -1;
|
||||
}
|
||||
fscanf( fd, "%d", &pid2);
|
||||
- if ( pid2 && (pid2 != pid_read) && ( kill( pid2, 0) == 0 )) {
|
||||
+ if ( pid2 && (pid2 != pid_read) && ( _dl_pid_exists( pid2))) {
|
||||
+ if ( pid2 && (pid2 != pid_read) && _dl_pid_exists(pid2) ) {
|
||||
/* lock file was changed! let us quickly
|
||||
* put it back again
|
||||
*/
|
||||
@@ -501,6 +501,18 @@
|
||||
@@ -502,6 +502,17 @@ _dl_check_devname (const char *devname)
|
||||
return strcpy(m, p);
|
||||
}
|
||||
|
||||
+/* for internal use */
|
||||
+/* correctly check if a process with a given pid exists */
|
||||
+static inline int
|
||||
+_dl_pid_exists( pid)
|
||||
+ pid_t pid;
|
||||
+_dl_pid_exists(pid_t pid)
|
||||
+{
|
||||
+ if ( !kill( pid, 0))
|
||||
+ return 1;
|
159
lockdev-1.0.0-rh.patch → lockdev-1.0.3-rh.patch
Normal file → Executable file
159
lockdev-1.0.0-rh.patch → lockdev-1.0.3-rh.patch
Normal file → Executable file
@ -1,17 +1,15 @@
|
||||
Index: lockdev-1.0.1/Makefile
|
||||
===================================================================
|
||||
--- lockdev-1.0.1.orig/Makefile
|
||||
+++ lockdev-1.0.1/Makefile
|
||||
@@ -5,6 +5,8 @@ pkgname = lockdev
|
||||
|
||||
diff -up lockdev-1.0.3/Makefile.redhat lockdev-1.0.3/Makefile
|
||||
--- lockdev-1.0.3/Makefile.redhat 2005-10-03 20:51:53.000000000 +0200
|
||||
+++ lockdev-1.0.3/Makefile 2009-12-05 17:42:41.000000000 +0100
|
||||
@@ -6,6 +6,7 @@ pkgname = lockdev
|
||||
objs = src/lockdev.o
|
||||
shobjs = src/lockdev.z
|
||||
|
||||
+lockdev = src/sample.c
|
||||
+
|
||||
|
||||
VER = $(shell expr `pwd` : '.*-\([0-9.]*\)')
|
||||
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'}
|
||||
@@ -17,17 +19,18 @@ soname = ${libname}.so.${MVER}
|
||||
@@ -18,17 +19,18 @@ soname = ${libname}.so.${MVER}
|
||||
basedir = /usr/local
|
||||
srcdir=.
|
||||
|
||||
@ -24,7 +22,7 @@ Index: lockdev-1.0.1/Makefile
|
||||
-LCFLAGS = -g -O2 -fPIC -Wall -pipe -D_REENTRANT
|
||||
-CFLAGS = -g
|
||||
+CFLAGS = -g -O2 -Wall -pipe
|
||||
+LCFLAGS = ${CFLAGS} -fPIC -D_REENTRANT
|
||||
+LCFLAGS = ${CFLAGS} -fPIC -D_REENTRANT
|
||||
LDLIBS = -llockdev
|
||||
|
||||
.PHONY: shared static perl-lib
|
||||
@ -33,8 +31,8 @@ Index: lockdev-1.0.1/Makefile
|
||||
|
||||
static ${static}: ${objs}
|
||||
$(AR) $(ARFLAGS) ${static} $^
|
||||
@@ -35,6 +38,11 @@ static ${static}: ${objs}
|
||||
shared ${shared}: ${objs}
|
||||
@@ -36,6 +38,12 @@ static ${static}: ${objs}
|
||||
shared ${shared}: ${shobjs}
|
||||
${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared}
|
||||
|
||||
+lockdev.o: ${lockdev}
|
||||
@ -42,10 +40,11 @@ Index: lockdev-1.0.1/Makefile
|
||||
+
|
||||
+lockdev: lockdev.o ${static}
|
||||
+ ${CC} -o $@ $^
|
||||
+
|
||||
src/lockdev.z: src/lockdev.c
|
||||
${CC} ${CFLAGS} -c -fPIC -o $@ $?
|
||||
|
||||
perl-lib: static
|
||||
cd LockDev && perl Makefile.PL INSTALLDIRS=vendor
|
||||
@@ -50,6 +58,7 @@ install_dev: ${static} src/lockdev.h
|
||||
@@ -54,6 +62,7 @@ install_dev: ${static} src/lockdev.h
|
||||
install -m755 -d ${incdir}
|
||||
install -m644 src/lockdev.h ${incdir}
|
||||
install -m644 src/ttylock.h ${incdir}
|
||||
@ -53,7 +52,7 @@ Index: lockdev-1.0.1/Makefile
|
||||
|
||||
install_debug: ${static} ${shared}
|
||||
install -m755 -d ${libdir}/debug
|
||||
@@ -67,7 +76,9 @@ install_doc: docs/lockdev.3
|
||||
@@ -71,7 +80,9 @@ install_doc: docs/lockdev.3
|
||||
|
||||
install_run: ${shared}
|
||||
install -m755 -d ${libdir}
|
||||
@ -64,11 +63,10 @@ Index: lockdev-1.0.1/Makefile
|
||||
|
||||
.PHONY: clean distclean perl-clean mostyclean
|
||||
perl-clean: clean
|
||||
Index: lockdev-1.0.1/src/baudboy.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ lockdev-1.0.1/src/baudboy.h
|
||||
@@ -0,0 +1,136 @@
|
||||
diff -up /dev/null lockdev-1.0.3/src/baudboy.h
|
||||
--- /dev/null 2009-12-05 11:05:54.692858210 +0100
|
||||
+++ lockdev-1.0.3/src/baudboy.h 2009-12-05 17:38:03.000000000 +0100
|
||||
@@ -0,0 +1,137 @@
|
||||
+/* Copyright (C) 2001 Red Hat, Inc.
|
||||
+
|
||||
+ This library is free software; you can redistribute it and/or
|
||||
@ -98,6 +96,7 @@ Index: lockdev-1.0.1/src/baudboy.h
|
||||
+#include <sys/types.h>
|
||||
+#include <errno.h>
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
@ -105,11 +104,11 @@ Index: lockdev-1.0.1/src/baudboy.h
|
||||
+
|
||||
+#define LOCKDEV_PATH "/usr/sbin/lockdev"
|
||||
+
|
||||
+static inline int doit(const char * argv[])
|
||||
+static inline int _doit(const char * argv[])
|
||||
+{
|
||||
+ pid_t child;
|
||||
+ int status;
|
||||
+ void (*osig) (int) = signal(SIGCHLD, SIG_IGN);
|
||||
+ void (*osig) (int) = signal(SIGCHLD, SIG_DFL);
|
||||
+ int rc;
|
||||
+
|
||||
+ if (!(child = fork())) {
|
||||
@ -175,21 +174,21 @@ Index: lockdev-1.0.1/src/baudboy.h
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, "-l", NULL, NULL};
|
||||
+ argv[2] = devname;
|
||||
+ return doit(argv);
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttyunlock(const char * devname)
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, "-u", NULL, NULL};
|
||||
+ argv[2] = devname;
|
||||
+ return doit(argv);
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttylocked(const char * devname)
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, NULL, NULL};
|
||||
+ argv[1] = devname;
|
||||
+ return doit(argv);
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttywait(const char * devname)
|
||||
@ -205,11 +204,10 @@ Index: lockdev-1.0.1/src/baudboy.h
|
||||
+#endif
|
||||
+
|
||||
+#endif /* _BAUDBOY_H_ */
|
||||
Index: lockdev-1.0.1/src/lockdev.c
|
||||
===================================================================
|
||||
--- lockdev-1.0.1.orig/src/lockdev.c
|
||||
+++ lockdev-1.0.1/src/lockdev.c
|
||||
@@ -176,6 +176,19 @@ liblockdev_reset_debug()
|
||||
diff -up lockdev-1.0.3/src/lockdev.c.redhat lockdev-1.0.3/src/lockdev.c
|
||||
--- lockdev-1.0.3/src/lockdev.c.redhat 2006-04-20 21:11:08.000000000 +0200
|
||||
+++ lockdev-1.0.3/src/lockdev.c 2009-12-05 17:38:03.000000000 +0100
|
||||
@@ -177,6 +177,19 @@ liblockdev_reset_debug (void)
|
||||
liblockdev_debug = 0;
|
||||
}
|
||||
|
||||
@ -229,7 +227,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
|
||||
/*
|
||||
* for internal use *
|
||||
@@ -429,7 +442,7 @@ _dl_check_lock( lockname)
|
||||
@@ -423,7 +436,7 @@ _dl_check_lock(const char *lockname)
|
||||
* maybe also this sprintf should be added to the
|
||||
* conditional part, as the others
|
||||
*/
|
||||
@ -238,16 +236,16 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
unlink( tpname); /* in case there was */
|
||||
rename( lockname, tpname);
|
||||
if ( ! (fd=fopen( tpname, "r")) ) {
|
||||
@@ -520,7 +533,7 @@ dev_testlock( devname)
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(-errno);
|
||||
}
|
||||
|
||||
/* first check for the FSSTND-1.2 lock, get the pid of the
|
||||
@@ -586,7 +599,7 @@ dev_lock( devname)
|
||||
@@ -511,7 +524,7 @@ dev_testlock(const char *devname)
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_testlock(%s)\n", devname);
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
- close_n_return( -1);
|
||||
+ close_n_return( -errno);
|
||||
strcpy( device, DEV_PATH);
|
||||
strcat( device, p); /* now device has a copy of the pathname */
|
||||
_debug( 2, "dev_testlock() device = %s\n", device);
|
||||
@@ -585,7 +598,7 @@ dev_lock (const char *devname)
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_lock(%s)\n", devname);
|
||||
if (oldmask == -1 )
|
||||
@ -256,7 +254,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -597,11 +610,14 @@ dev_lock( devname)
|
||||
@@ -596,11 +609,14 @@ dev_lock (const char *devname)
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
@ -273,7 +271,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
_debug( 2, "dev_lock() our own pid = %d\n", (int)our_pid);
|
||||
|
||||
/* We will use this algorithm:
|
||||
@@ -642,8 +658,9 @@ dev_lock( devname)
|
||||
@@ -641,8 +657,9 @@ dev_lock (const char *devname)
|
||||
_dl_filename_1( lock1, &statbuf);
|
||||
while ( ! (pid=_dl_check_lock( lock1)) ) {
|
||||
if (( link( lock0, lock1) == -1 ) && ( errno != EEXIST )) {
|
||||
@ -284,7 +282,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
}
|
||||
}
|
||||
if ( pid != our_pid ) {
|
||||
@@ -660,9 +677,10 @@ dev_lock( devname)
|
||||
@@ -659,9 +676,10 @@ dev_lock (const char *devname)
|
||||
/* lockfile of type /var/lock/LCK..ttyS2 */
|
||||
while ( ! (pid=_dl_check_lock( lock2)) ) {
|
||||
if (( link( lock0, lock2) == -1 ) && ( errno != EEXIST )) {
|
||||
@ -296,7 +294,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
}
|
||||
}
|
||||
if ( pid != our_pid ) {
|
||||
@@ -742,7 +760,7 @@ dev_relock( devname, old_pid)
|
||||
@@ -740,7 +758,7 @@ dev_relock (const char *devname,
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_relock(%s, %d)\n", devname, (int)old_pid);
|
||||
if (oldmask == -1 )
|
||||
@ -305,7 +303,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -753,11 +771,14 @@ dev_relock( devname, old_pid)
|
||||
@@ -751,11 +769,14 @@ dev_relock (const char *devname,
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
@ -322,7 +320,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
_debug( 2, "dev_relock() our own pid = %d\n", (int)our_pid);
|
||||
|
||||
/* first check for the FSSTND-1.2 lock, get the pid of the
|
||||
@@ -828,7 +849,7 @@ dev_unlock( devname, pid)
|
||||
@@ -825,7 +846,7 @@ dev_unlock (const char *devname,
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_unlock(%s, %d)\n", devname, (int)pid);
|
||||
if (oldmask == -1 )
|
||||
@ -331,7 +329,7 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -839,7 +860,10 @@ dev_unlock( devname, pid)
|
||||
@@ -836,7 +857,10 @@ dev_unlock (const char *devname,
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
@ -343,80 +341,69 @@ Index: lockdev-1.0.1/src/lockdev.c
|
||||
}
|
||||
|
||||
/* first remove the FSSTND-1.2 lock, get the pid of the
|
||||
Index: lockdev-1.0.1/src/lockdev.h
|
||||
===================================================================
|
||||
--- lockdev-1.0.1.orig/src/lockdev.h
|
||||
+++ lockdev-1.0.1/src/lockdev.h
|
||||
@@ -53,6 +53,7 @@ extern "C" {
|
||||
diff -up lockdev-1.0.3/src/lockdev.h.redhat lockdev-1.0.3/src/lockdev.h
|
||||
--- lockdev-1.0.3/src/lockdev.h.redhat 2005-10-03 19:44:33.000000000 +0200
|
||||
+++ lockdev-1.0.3/src/lockdev.h 2009-12-05 17:38:03.000000000 +0100
|
||||
@@ -43,12 +43,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
+#include <errno.h>
|
||||
|
||||
|
||||
/* API of the library */
|
||||
@@ -60,6 +61,9 @@ extern "C" {
|
||||
void liblockdev_incr_debug __P(());
|
||||
void liblockdev_reset_debug __P(());
|
||||
|
||||
+pid_t dev_getpid __P(( void ));
|
||||
+pid_t dev_setpid __P(( pid_t pid ));
|
||||
void liblockdev_incr_debug (void);
|
||||
void liblockdev_reset_debug (void);
|
||||
|
||||
+pid_t dev_getpid (void);
|
||||
+pid_t dev_setpid (pid_t pid);
|
||||
+
|
||||
pid_t dev_testlock __P(( const char * devname));
|
||||
|
||||
pid_t dev_lock __P(( const char * devname));
|
||||
Index: lockdev-1.0.1/src/sample.c
|
||||
===================================================================
|
||||
--- lockdev-1.0.1.orig/src/sample.c
|
||||
+++ lockdev-1.0.1/src/sample.c
|
||||
@@ -3,27 +3,26 @@
|
||||
pid_t dev_testlock (const char *devname);
|
||||
|
||||
pid_t dev_lock (const char *devname);
|
||||
diff -up lockdev-1.0.3/src/sample.c.redhat lockdev-1.0.3/src/sample.c
|
||||
--- lockdev-1.0.3/src/sample.c.redhat 2005-10-03 19:51:17.000000000 +0200
|
||||
+++ lockdev-1.0.3/src/sample.c 2009-12-05 17:38:03.000000000 +0100
|
||||
@@ -5,8 +5,8 @@
|
||||
void
|
||||
usage() {
|
||||
usage (void)
|
||||
{
|
||||
- fprintf( stderr, "Usage: sample [-lurd] <device>\n" );
|
||||
- exit( -1 );
|
||||
+ fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev");
|
||||
+ exit(-1);
|
||||
}
|
||||
|
||||
int debug;
|
||||
|
||||
|
||||
int
|
||||
-main( int argc, char *argv[] )
|
||||
+main(int argc, char *argv[])
|
||||
@@ -15,7 +15,7 @@ main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
int i, chld;
|
||||
- char *p, *dev, ch;
|
||||
+ char *p = NULL, *dev = NULL, ch;
|
||||
|
||||
ch = '\0';
|
||||
- for( i = argc - 1; i > 0; i-- ) {
|
||||
+ for (i = argc - 1; i > 0; i--) {
|
||||
p = argv[i];
|
||||
- if( *p == '-' ) {
|
||||
- switch( *++p ) {
|
||||
+ if (*p == '-') {
|
||||
+ switch(*++p) {
|
||||
for( i = argc - 1; i > 0; i-- ) {
|
||||
@@ -23,8 +23,7 @@ main (int argc,
|
||||
if( *p == '-' ) {
|
||||
switch( *++p ) {
|
||||
case 'l':
|
||||
- case 'u':
|
||||
- case 'r': ch = *p; break;
|
||||
+ case 'u': ch = *p; break;
|
||||
case 'd':
|
||||
debug = atoi(++p);
|
||||
liblockdev_incr_debug();
|
||||
break;
|
||||
@@ -32,31 +31,52 @@ main( int argc, char *argv[] )
|
||||
@@ -33,31 +32,52 @@ main (int argc,
|
||||
}
|
||||
else dev = p;
|
||||
}
|
||||
- fprintf( stderr, "option %c, device %s\n", ch, dev );
|
||||
i = 0;
|
||||
- switch( ch ) {
|
||||
+ (void) dev_setpid(getppid());
|
||||
+ switch(ch) {
|
||||
switch( ch ) {
|
||||
case 'l':
|
||||
- i = dev_lock( dev);
|
||||
+ i = dev_lock(dev);
|
||||
i = dev_lock( dev);
|
||||
break;
|
||||
case 'u':
|
||||
- i = dev_unlock( dev, 0);
|
9
lockdev-1.0.0-shared.patch → lockdev-1.0.3-shared.patch
Normal file → Executable file
9
lockdev-1.0.0-shared.patch → lockdev-1.0.3-shared.patch
Normal file → Executable file
@ -1,7 +1,6 @@
|
||||
Index: lockdev-1.0.1/Makefile
|
||||
===================================================================
|
||||
--- lockdev-1.0.1.orig/Makefile
|
||||
+++ lockdev-1.0.1/Makefile
|
||||
diff -up lockdev-1.0.3/Makefile.shared lockdev-1.0.3/Makefile
|
||||
--- lockdev-1.0.3/Makefile.shared 2009-12-05 15:40:16.000000000 +0100
|
||||
+++ lockdev-1.0.3/Makefile 2009-12-05 15:41:58.000000000 +0100
|
||||
@@ -12,7 +12,7 @@ VER = $(shell expr `pwd` : '.*-\([0-9.]*
|
||||
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'}
|
||||
|
||||
@ -11,7 +10,7 @@ Index: lockdev-1.0.1/Makefile
|
||||
soname = ${libname}.so.${MVER}
|
||||
|
||||
# overwritten by caller (e.g.: debian/rules)
|
||||
@@ -77,6 +77,7 @@ install_doc: docs/lockdev.3
|
||||
@@ -80,6 +80,7 @@ install_doc: docs/lockdev.3
|
||||
install_run: ${shared}
|
||||
install -m755 -d ${libdir}
|
||||
install -m755 ${shared} ${libdir}
|
40
lockdev.spec
40
lockdev.spec
@ -1,24 +1,20 @@
|
||||
Summary: A library for locking devices
|
||||
Name: lockdev
|
||||
Version: 1.0.1
|
||||
Release: 20%{?dist}
|
||||
Version: 1.0.3
|
||||
Release: 1%{?dist}
|
||||
License: LGPLv2
|
||||
Group: System Environment/Libraries
|
||||
URL: http://packages.debian.org/unstable/source/lockdev
|
||||
Source0: http://ftp.debian.org/debian/pool/main/l/lockdev/%{name}_%{version}.orig.tar.gz
|
||||
Source1: lockdev.8
|
||||
|
||||
Patch0: lockdev-1.0.0-rh.patch
|
||||
Patch1: lockdev-1.0.0-shared.patch
|
||||
Patch2: lockdev-1.0.0-signal.patch
|
||||
Patch3: lockdev-1.0.0-cli.patch
|
||||
Patch4: lockdev-1.0.1-checkname.patch
|
||||
Patch5: lockdev-1.0.1-pidexists.patch
|
||||
Patch6: lockdev-1.0.1-subdir.patch
|
||||
Patch7: lockdev-1.0.1-fcntl.patch
|
||||
Patch8: lockdev-1.0.1-32bit.patch
|
||||
Patch9: lockdev-1.0.1-gccwarn.patch
|
||||
Patch10: lockdev-1.0.1-man8.patch
|
||||
Patch0: lockdev-1.0.3-rh.patch
|
||||
Patch1: lockdev-1.0.3-shared.patch
|
||||
Patch2: lockdev-1.0.3-cli.patch
|
||||
Patch3: lockdev-1.0.3-checkname.patch
|
||||
Patch4: lockdev-1.0.3-pidexists.patch
|
||||
Patch5: lockdev-1.0.3-gccwarn.patch
|
||||
Patch6: lockdev-1.0.3-man8.patch
|
||||
|
||||
Requires(pre): shadow-utils
|
||||
Requires(post): glibc
|
||||
@ -46,15 +42,11 @@ package contains the development headers and a static library.
|
||||
%setup -q
|
||||
%patch0 -p1 -b .redhat
|
||||
%patch1 -p1 -b .shared
|
||||
%patch2 -p1 -b .signal
|
||||
%patch3 -p1 -b .jbj
|
||||
%patch4 -p1 -b .checkname
|
||||
%patch5 -p1 -b .pidexists
|
||||
%patch6 -p1 -b .subdir
|
||||
%patch7 -p1 -b .fcntl
|
||||
%patch8 -p1 -b .32bit
|
||||
%patch9 -p1 -b .warn
|
||||
%patch10 -p1 -b .man8
|
||||
%patch2 -p1 -b .cli
|
||||
%patch3 -p1 -b .checkname
|
||||
%patch4 -p1 -b .pidexists
|
||||
%patch5 -p1 -b .warn
|
||||
%patch6 -p1 -b .man8
|
||||
|
||||
cp %SOURCE1 ./docs
|
||||
|
||||
@ -98,6 +90,10 @@ rm -fr $RPM_BUILD_ROOT
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Mon Dec 07 2009 Jiri Popelka <jpopelka@redhat.com> - 1.0.3-1
|
||||
- 1.0.3. No longer need 1.0.0-signal, 1.0.1-subdir, 1.0.1-fcntl, 1.0.1-32bit patches.
|
||||
- Renumbered patches and sources.
|
||||
|
||||
* Thu Dec 03 2009 Jiri Popelka <jpopelka@redhat.com> - 1.0.1-20
|
||||
- Fixed pre section (http://fedoraproject.org/wiki/Packaging/UsersAndGroups)
|
||||
- Added back Buildroot to silence rpmlint's false positive
|
||||
|
Loading…
Reference in New Issue
Block a user