- 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:
Jiří Popelka 2009-12-07 09:28:58 +00:00
parent 801ff01a7e
commit 649b6dcfed
17 changed files with 175 additions and 287 deletions

View File

@ -1 +1 @@
lockdev_1.0.1.orig.tar.gz lockdev_1.0.3.orig.tar.gz

View File

@ -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) {

View File

@ -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)

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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" {

View File

@ -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';

View File

@ -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
View 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
View 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
View 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
View File

@ -1,7 +1,7 @@
diff -up lockdev-1.0.1/Makefile.man8 lockdev-1.0.1/Makefile diff -up lockdev-1.0.3/Makefile.man8 lockdev-1.0.3/Makefile
--- lockdev-1.0.1/Makefile.man8 2009-09-25 18:36:19.000000000 +0200 --- lockdev-1.0.3/Makefile.man8 2009-12-05 15:43:47.000000000 +0100
+++ lockdev-1.0.1/Makefile 2009-09-25 18:37:00.000000000 +0200 +++ lockdev-1.0.3/Makefile 2009-12-05 16:52:13.000000000 +0100
@@ -72,7 +72,9 @@ install_profile: ${static} ${shared} @@ -75,7 +75,9 @@ install_profile: ${static} ${shared}
install_doc: docs/lockdev.3 install_doc: docs/lockdev.3
install -m755 -d ${mandir}/man3 install -m755 -d ${mandir}/man3

View File

@ -1,7 +1,7 @@
diff -Nru lockdev-1.0.1.orig/src/lockdev.c lockdev-1.0.1/src/lockdev.c diff -up lockdev-1.0.3/src/lockdev.c.pidexists lockdev-1.0.3/src/lockdev.c
--- lockdev-1.0.1.orig/src/lockdev.c 2004-07-17 19:17:48.000000000 +0300 --- lockdev-1.0.3/src/lockdev.c.pidexists 2009-12-05 15:56:46.000000000 +0100
+++ lockdev-1.0.1/src/lockdev.c 2004-07-17 19:19:07.000000000 +0300 +++ lockdev-1.0.3/src/lockdev.c 2009-12-05 16:05:46.000000000 +0100
@@ -147,7 +147,7 @@ @@ -148,7 +148,7 @@ static inline int _dl_lock_semaphore ( v
static inline int _dl_block_semaphore ( void); static inline int _dl_block_semaphore ( void);
static pid_t _dl_check_lock ( const char * lockname); static pid_t _dl_check_lock ( const char * lockname);
static char * _dl_check_devname ( const char * devname); static char * _dl_check_devname ( const char * devname);
@ -10,33 +10,32 @@ diff -Nru lockdev-1.0.1.orig/src/lockdev.c lockdev-1.0.1/src/lockdev.c
#define SEMAPHORE "LOCKDEV" #define SEMAPHORE "LOCKDEV"
#define close_n_return( v) return( _dl_unlock_semaphore( v)) #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 */ /* checks content's format */
if ( j == 1 ) { if ( j == 1 ) {
/* checks process existence */ /* checks process existence */
- if ( kill( pid_read, 0) == 0 ) { - if ( ( kill( pid_read, 0) == 0 ) || (errno == EPERM) ) {
+ if ( _dl_pid_exists( pid_read)) { + if ( _dl_pid_exists( pid_read) || (errno == EPERM) ) {
_debug( 2, "_dl_check_lock() locked by %d\n", (int)pid_read); _debug( 2, "_dl_check_lock() locked by %d\n", (int)pid_read);
return pid_read; return pid_read;
} }
@@ -449,7 +449,7 @@ @@ -443,7 +443,7 @@ _dl_check_lock(const char *lockname)
return -1; return -1;
} }
fscanf( fd, "%d", &pid2); fscanf( fd, "%d", &pid2);
- if ( pid2 && (pid2 != pid_read) && ( kill( pid2, 0) == 0 )) { - 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 /* lock file was changed! let us quickly
* put it back again * put it back again
*/ */
@@ -501,6 +501,18 @@ @@ -502,6 +502,17 @@ _dl_check_devname (const char *devname)
return strcpy(m, p); return strcpy(m, p);
} }
+/* for internal use */ +/* for internal use */
+/* correctly check if a process with a given pid exists */ +/* correctly check if a process with a given pid exists */
+static inline int +static inline int
+_dl_pid_exists( pid) +_dl_pid_exists(pid_t pid)
+ pid_t pid;
+{ +{
+ if ( !kill( pid, 0)) + if ( !kill( pid, 0))
+ return 1; + return 1;

155
lockdev-1.0.0-rh.patch → lockdev-1.0.3-rh.patch Normal file → Executable file
View File

@ -1,17 +1,15 @@
Index: lockdev-1.0.1/Makefile 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.1.orig/Makefile +++ lockdev-1.0.3/Makefile 2009-12-05 17:42:41.000000000 +0100
+++ lockdev-1.0.1/Makefile @@ -6,6 +6,7 @@ pkgname = lockdev
@@ -5,6 +5,8 @@ pkgname = lockdev
objs = src/lockdev.o objs = src/lockdev.o
shobjs = src/lockdev.z
+lockdev = src/sample.c +lockdev = src/sample.c
+
VER = $(shell expr `pwd` : '.*-\([0-9.]*\)') VER = $(shell expr `pwd` : '.*-\([0-9.]*\)')
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[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 basedir = /usr/local
srcdir=. srcdir=.
@ -33,8 +31,8 @@ Index: lockdev-1.0.1/Makefile
static ${static}: ${objs} static ${static}: ${objs}
$(AR) $(ARFLAGS) ${static} $^ $(AR) $(ARFLAGS) ${static} $^
@@ -35,6 +38,11 @@ static ${static}: ${objs} @@ -36,6 +38,12 @@ static ${static}: ${objs}
shared ${shared}: ${objs} shared ${shared}: ${shobjs}
${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared} ${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared}
+lockdev.o: ${lockdev} +lockdev.o: ${lockdev}
@ -42,10 +40,11 @@ Index: lockdev-1.0.1/Makefile
+ +
+lockdev: lockdev.o ${static} +lockdev: lockdev.o ${static}
+ ${CC} -o $@ $^ + ${CC} -o $@ $^
+
src/lockdev.z: src/lockdev.c
${CC} ${CFLAGS} -c -fPIC -o $@ $?
perl-lib: static @@ -54,6 +62,7 @@ install_dev: ${static} src/lockdev.h
cd LockDev && perl Makefile.PL INSTALLDIRS=vendor
@@ -50,6 +58,7 @@ install_dev: ${static} src/lockdev.h
install -m755 -d ${incdir} install -m755 -d ${incdir}
install -m644 src/lockdev.h ${incdir} install -m644 src/lockdev.h ${incdir}
install -m644 src/ttylock.h ${incdir} install -m644 src/ttylock.h ${incdir}
@ -53,7 +52,7 @@ Index: lockdev-1.0.1/Makefile
install_debug: ${static} ${shared} install_debug: ${static} ${shared}
install -m755 -d ${libdir}/debug 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_run: ${shared}
install -m755 -d ${libdir} install -m755 -d ${libdir}
@ -64,11 +63,10 @@ Index: lockdev-1.0.1/Makefile
.PHONY: clean distclean perl-clean mostyclean .PHONY: clean distclean perl-clean mostyclean
perl-clean: clean perl-clean: clean
Index: lockdev-1.0.1/src/baudboy.h diff -up /dev/null lockdev-1.0.3/src/baudboy.h
=================================================================== --- /dev/null 2009-12-05 11:05:54.692858210 +0100
--- /dev/null +++ lockdev-1.0.3/src/baudboy.h 2009-12-05 17:38:03.000000000 +0100
+++ lockdev-1.0.1/src/baudboy.h @@ -0,0 +1,137 @@
@@ -0,0 +1,136 @@
+/* Copyright (C) 2001 Red Hat, Inc. +/* Copyright (C) 2001 Red Hat, Inc.
+ +
+ This library is free software; you can redistribute it and/or + 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 <sys/types.h>
+#include <errno.h> +#include <errno.h>
+#include <unistd.h> +#include <unistd.h>
+#include <fcntl.h>
+ +
+#ifdef __cplusplus +#ifdef __cplusplus
+extern "C" { +extern "C" {
@ -105,11 +104,11 @@ Index: lockdev-1.0.1/src/baudboy.h
+ +
+#define LOCKDEV_PATH "/usr/sbin/lockdev" +#define LOCKDEV_PATH "/usr/sbin/lockdev"
+ +
+static inline int doit(const char * argv[]) +static inline int _doit(const char * argv[])
+{ +{
+ pid_t child; + pid_t child;
+ int status; + int status;
+ void (*osig) (int) = signal(SIGCHLD, SIG_IGN); + void (*osig) (int) = signal(SIGCHLD, SIG_DFL);
+ int rc; + int rc;
+ +
+ if (!(child = fork())) { + if (!(child = fork())) {
@ -175,21 +174,21 @@ Index: lockdev-1.0.1/src/baudboy.h
+{ +{
+ const char * argv[] = { LOCKDEV_PATH, "-l", NULL, NULL}; + const char * argv[] = { LOCKDEV_PATH, "-l", NULL, NULL};
+ argv[2] = devname; + argv[2] = devname;
+ return doit(argv); + return _doit(argv);
+} +}
+ +
+static inline int ttyunlock(const char * devname) +static inline int ttyunlock(const char * devname)
+{ +{
+ const char * argv[] = { LOCKDEV_PATH, "-u", NULL, NULL}; + const char * argv[] = { LOCKDEV_PATH, "-u", NULL, NULL};
+ argv[2] = devname; + argv[2] = devname;
+ return doit(argv); + return _doit(argv);
+} +}
+ +
+static inline int ttylocked(const char * devname) +static inline int ttylocked(const char * devname)
+{ +{
+ const char * argv[] = { LOCKDEV_PATH, NULL, NULL}; + const char * argv[] = { LOCKDEV_PATH, NULL, NULL};
+ argv[1] = devname; + argv[1] = devname;
+ return doit(argv); + return _doit(argv);
+} +}
+ +
+static inline int ttywait(const char * devname) +static inline int ttywait(const char * devname)
@ -205,11 +204,10 @@ Index: lockdev-1.0.1/src/baudboy.h
+#endif +#endif
+ +
+#endif /* _BAUDBOY_H_ */ +#endif /* _BAUDBOY_H_ */
Index: lockdev-1.0.1/src/lockdev.c 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.1.orig/src/lockdev.c +++ lockdev-1.0.3/src/lockdev.c 2009-12-05 17:38:03.000000000 +0100
+++ lockdev-1.0.1/src/lockdev.c @@ -177,6 +177,19 @@ liblockdev_reset_debug (void)
@@ -176,6 +176,19 @@ liblockdev_reset_debug()
liblockdev_debug = 0; liblockdev_debug = 0;
} }
@ -229,7 +227,7 @@ Index: lockdev-1.0.1/src/lockdev.c
/* /*
* for internal use * * 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 * maybe also this sprintf should be added to the
* conditional part, as the others * conditional part, as the others
*/ */
@ -238,16 +236,16 @@ Index: lockdev-1.0.1/src/lockdev.c
unlink( tpname); /* in case there was */ unlink( tpname); /* in case there was */
rename( lockname, tpname); rename( lockname, tpname);
if ( ! (fd=fopen( tpname, "r")) ) { if ( ! (fd=fopen( tpname, "r")) ) {
@@ -520,7 +533,7 @@ dev_testlock( devname) @@ -511,7 +524,7 @@ dev_testlock(const char *devname)
* and minor numbers #endif /* DEBUG */
*/ _debug( 3, "dev_testlock(%s)\n", devname);
if ( stat( device, &statbuf) == -1 ) { if ( ! (p=_dl_check_devname( devname)) )
- close_n_return( -1); - close_n_return( -1);
+ close_n_return(-errno); + close_n_return( -errno);
} strcpy( device, DEV_PATH);
strcat( device, p); /* now device has a copy of the pathname */
/* first check for the FSSTND-1.2 lock, get the pid of the _debug( 2, "dev_testlock() device = %s\n", device);
@@ -586,7 +599,7 @@ dev_lock( devname) @@ -585,7 +598,7 @@ dev_lock (const char *devname)
#endif /* DEBUG */ #endif /* DEBUG */
_debug( 3, "dev_lock(%s)\n", devname); _debug( 3, "dev_lock(%s)\n", devname);
if (oldmask == -1 ) if (oldmask == -1 )
@ -256,7 +254,7 @@ Index: lockdev-1.0.1/src/lockdev.c
if ( ! (p=_dl_check_devname( devname)) ) if ( ! (p=_dl_check_devname( devname)) )
close_n_return( -1); close_n_return( -1);
strcpy( device, DEV_PATH); strcpy( device, DEV_PATH);
@@ -597,11 +610,14 @@ dev_lock( devname) @@ -596,11 +609,14 @@ dev_lock (const char *devname)
* and minor numbers * and minor numbers
*/ */
if ( stat( device, &statbuf) == -1 ) { 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); _debug( 2, "dev_lock() our own pid = %d\n", (int)our_pid);
/* We will use this algorithm: /* 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); _dl_filename_1( lock1, &statbuf);
while ( ! (pid=_dl_check_lock( lock1)) ) { while ( ! (pid=_dl_check_lock( lock1)) ) {
if (( link( lock0, lock1) == -1 ) && ( errno != EEXIST )) { if (( link( lock0, lock1) == -1 ) && ( errno != EEXIST )) {
@ -284,7 +282,7 @@ Index: lockdev-1.0.1/src/lockdev.c
} }
} }
if ( pid != our_pid ) { 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 */ /* lockfile of type /var/lock/LCK..ttyS2 */
while ( ! (pid=_dl_check_lock( lock2)) ) { while ( ! (pid=_dl_check_lock( lock2)) ) {
if (( link( lock0, lock2) == -1 ) && ( errno != EEXIST )) { if (( link( lock0, lock2) == -1 ) && ( errno != EEXIST )) {
@ -296,7 +294,7 @@ Index: lockdev-1.0.1/src/lockdev.c
} }
} }
if ( pid != our_pid ) { if ( pid != our_pid ) {
@@ -742,7 +760,7 @@ dev_relock( devname, old_pid) @@ -740,7 +758,7 @@ dev_relock (const char *devname,
#endif /* DEBUG */ #endif /* DEBUG */
_debug( 3, "dev_relock(%s, %d)\n", devname, (int)old_pid); _debug( 3, "dev_relock(%s, %d)\n", devname, (int)old_pid);
if (oldmask == -1 ) if (oldmask == -1 )
@ -305,7 +303,7 @@ Index: lockdev-1.0.1/src/lockdev.c
if ( ! (p=_dl_check_devname( devname)) ) if ( ! (p=_dl_check_devname( devname)) )
close_n_return( -1); close_n_return( -1);
strcpy( device, DEV_PATH); 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 * and minor numbers
*/ */
if ( stat( device, &statbuf) == -1 ) { 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); _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 /* 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 */ #endif /* DEBUG */
_debug( 3, "dev_unlock(%s, %d)\n", devname, (int)pid); _debug( 3, "dev_unlock(%s, %d)\n", devname, (int)pid);
if (oldmask == -1 ) if (oldmask == -1 )
@ -331,7 +329,7 @@ Index: lockdev-1.0.1/src/lockdev.c
if ( ! (p=_dl_check_devname( devname)) ) if ( ! (p=_dl_check_devname( devname)) )
close_n_return( -1); close_n_return( -1);
strcpy( device, DEV_PATH); strcpy( device, DEV_PATH);
@@ -839,7 +860,10 @@ dev_unlock( devname, pid) @@ -836,7 +857,10 @@ dev_unlock (const char *devname,
* and minor numbers * and minor numbers
*/ */
if ( stat( device, &statbuf) == -1 ) { 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 /* first remove the FSSTND-1.2 lock, get the pid of the
Index: lockdev-1.0.1/src/lockdev.h 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.1.orig/src/lockdev.h +++ lockdev-1.0.3/src/lockdev.h 2009-12-05 17:38:03.000000000 +0100
+++ lockdev-1.0.1/src/lockdev.h @@ -43,12 +43,16 @@ extern "C" {
@@ -53,6 +53,7 @@ extern "C" {
#endif #endif
#include <sys/types.h> #include <sys/types.h>
+#include <errno.h> +#include <errno.h>
/* API of the library */ /* 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 )); void liblockdev_incr_debug (void);
+pid_t dev_setpid __P(( pid_t pid )); 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_testlock (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_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 void
usage() { usage (void)
{
- fprintf( stderr, "Usage: sample [-lurd] <device>\n" ); - fprintf( stderr, "Usage: sample [-lurd] <device>\n" );
- exit( -1 ); - exit( -1 );
+ fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev"); + fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev");
+ exit(-1); + exit(-1);
} }
int debug;
@@ -15,7 +15,7 @@ main (int argc,
int char *argv[])
-main( int argc, char *argv[] )
+main(int argc, char *argv[])
{ {
int i, chld; int i, chld;
- char *p, *dev, ch; - char *p, *dev, ch;
+ char *p = NULL, *dev = NULL, ch; + char *p = NULL, *dev = NULL, ch;
ch = '\0'; ch = '\0';
- for( i = argc - 1; i > 0; i-- ) { for( i = argc - 1; i > 0; i-- ) {
+ for (i = argc - 1; i > 0; i--) { @@ -23,8 +23,7 @@ main (int argc,
p = argv[i]; if( *p == '-' ) {
- if( *p == '-' ) { switch( *++p ) {
- switch( *++p ) {
+ if (*p == '-') {
+ switch(*++p) {
case 'l': case 'l':
- case 'u': - case 'u':
- case 'r': ch = *p; break; - case 'r': ch = *p; break;
+ case 'u': ch = *p; break; + case 'u': ch = *p; break;
case 'd': case 'd':
debug = atoi(++p); liblockdev_incr_debug();
break; break;
@@ -32,31 +31,52 @@ main( int argc, char *argv[] ) @@ -33,31 +32,52 @@ main (int argc,
} }
else dev = p; else dev = p;
} }
- fprintf( stderr, "option %c, device %s\n", ch, dev ); - fprintf( stderr, "option %c, device %s\n", ch, dev );
i = 0; i = 0;
- switch( ch ) {
+ (void) dev_setpid(getppid()); + (void) dev_setpid(getppid());
+ switch(ch) { switch( ch ) {
case 'l': case 'l':
- i = dev_lock( dev); i = dev_lock( dev);
+ i = dev_lock(dev);
break; break;
case 'u': case 'u':
- i = dev_unlock( dev, 0); - i = dev_unlock( dev, 0);

View File

@ -1,7 +1,6 @@
Index: 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.1.orig/Makefile +++ lockdev-1.0.3/Makefile 2009-12-05 15:41:58.000000000 +0100
+++ lockdev-1.0.1/Makefile
@@ -12,7 +12,7 @@ VER = $(shell expr `pwd` : '.*-\([0-9.]* @@ -12,7 +12,7 @@ VER = $(shell expr `pwd` : '.*-\([0-9.]*
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'} MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'}
@ -11,7 +10,7 @@ Index: lockdev-1.0.1/Makefile
soname = ${libname}.so.${MVER} soname = ${libname}.so.${MVER}
# overwritten by caller (e.g.: debian/rules) # 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_run: ${shared}
install -m755 -d ${libdir} install -m755 -d ${libdir}
install -m755 ${shared} ${libdir} install -m755 ${shared} ${libdir}

View File

@ -1,24 +1,20 @@
Summary: A library for locking devices Summary: A library for locking devices
Name: lockdev Name: lockdev
Version: 1.0.1 Version: 1.0.3
Release: 20%{?dist} Release: 1%{?dist}
License: LGPLv2 License: LGPLv2
Group: System Environment/Libraries Group: System Environment/Libraries
URL: http://packages.debian.org/unstable/source/lockdev URL: http://packages.debian.org/unstable/source/lockdev
Source0: http://ftp.debian.org/debian/pool/main/l/lockdev/%{name}_%{version}.orig.tar.gz Source0: http://ftp.debian.org/debian/pool/main/l/lockdev/%{name}_%{version}.orig.tar.gz
Source1: lockdev.8 Source1: lockdev.8
Patch0: lockdev-1.0.0-rh.patch Patch0: lockdev-1.0.3-rh.patch
Patch1: lockdev-1.0.0-shared.patch Patch1: lockdev-1.0.3-shared.patch
Patch2: lockdev-1.0.0-signal.patch Patch2: lockdev-1.0.3-cli.patch
Patch3: lockdev-1.0.0-cli.patch Patch3: lockdev-1.0.3-checkname.patch
Patch4: lockdev-1.0.1-checkname.patch Patch4: lockdev-1.0.3-pidexists.patch
Patch5: lockdev-1.0.1-pidexists.patch Patch5: lockdev-1.0.3-gccwarn.patch
Patch6: lockdev-1.0.1-subdir.patch Patch6: lockdev-1.0.3-man8.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
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires(post): glibc Requires(post): glibc
@ -46,15 +42,11 @@ package contains the development headers and a static library.
%setup -q %setup -q
%patch0 -p1 -b .redhat %patch0 -p1 -b .redhat
%patch1 -p1 -b .shared %patch1 -p1 -b .shared
%patch2 -p1 -b .signal %patch2 -p1 -b .cli
%patch3 -p1 -b .jbj %patch3 -p1 -b .checkname
%patch4 -p1 -b .checkname %patch4 -p1 -b .pidexists
%patch5 -p1 -b .pidexists %patch5 -p1 -b .warn
%patch6 -p1 -b .subdir %patch6 -p1 -b .man8
%patch7 -p1 -b .fcntl
%patch8 -p1 -b .32bit
%patch9 -p1 -b .warn
%patch10 -p1 -b .man8
cp %SOURCE1 ./docs cp %SOURCE1 ./docs
@ -98,6 +90,10 @@ rm -fr $RPM_BUILD_ROOT
%{_includedir}/* %{_includedir}/*
%changelog %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 * Thu Dec 03 2009 Jiri Popelka <jpopelka@redhat.com> - 1.0.1-20
- Fixed pre section (http://fedoraproject.org/wiki/Packaging/UsersAndGroups) - Fixed pre section (http://fedoraproject.org/wiki/Packaging/UsersAndGroups)
- Added back Buildroot to silence rpmlint's false positive - Added back Buildroot to silence rpmlint's false positive

View File

@ -1 +1 @@
3deda988583172b673f984b0d1cdeb0d lockdev_1.0.1.orig.tar.gz 64b9c1b87b125fc348e892e24625524a lockdev_1.0.3.orig.tar.gz