Fixed URL & Removed unused patches
This commit is contained in:
parent
6ba2defeec
commit
74271d7ff5
@ -1,30 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
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 ) {
|
@ -1,20 +0,0 @@
|
||||
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';
|
@ -1,13 +0,0 @@
|
||||
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
|
||||
+ install -m755 -d ${mandir}/man8
|
||||
install -m644 docs/lockdev.3 ${mandir}/man3
|
||||
+ install -m644 docs/lockdev.8 ${mandir}/man8
|
||||
|
||||
install_run: ${shared}
|
||||
install -m755 -d ${libdir}
|
@ -1,48 +0,0 @@
|
||||
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 );
|
||||
|
||||
#define SEMAPHORE "LOCKDEV"
|
||||
#define close_n_return( v) return( _dl_unlock_semaphore( v))
|
||||
@@ -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 ) || (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;
|
||||
}
|
||||
@@ -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) ) {
|
||||
/* lock file was changed! let us quickly
|
||||
* put it back again
|
||||
*/
|
||||
@@ -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_t pid)
|
||||
+{
|
||||
+ if ( !kill( pid, 0))
|
||||
+ return 1;
|
||||
+ if ( errno == ESRCH)
|
||||
+ return 0;
|
||||
+ return 1;
|
||||
+}
|
||||
|
||||
/* exported by the interface file lockdev.h */
|
||||
/* ZERO means that the device wasn't locked, but could have been locked later */
|
@ -1,482 +0,0 @@
|
||||
diff -up lockdev-1.0.3/LockDev/Makefile.PL.redhat lockdev-1.0.3/LockDev/Makefile.PL
|
||||
--- lockdev-1.0.3/LockDev/Makefile.PL.redhat 2005-10-03 19:49:17.000000000 +0200
|
||||
+++ lockdev-1.0.3/LockDev/Makefile.PL 2009-12-10 17:07:42.000000000 +0100
|
||||
@@ -7,7 +7,7 @@ WriteMakefile(
|
||||
'LIBS' => [''],
|
||||
'DEFINE' => '',
|
||||
'INC' => '-I../src',
|
||||
- 'MYEXTLIB' => '../src/lockdev.z',
|
||||
+ 'MYEXTLIB' => '../liblockdev.a',
|
||||
);
|
||||
|
||||
sub MY::postamble {
|
||||
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
|
||||
@@ -4,8 +4,8 @@ libname = liblockdev
|
||||
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]*'}
|
||||
@@ -18,27 +18,30 @@ soname = ${libname}.so.${MVER}
|
||||
basedir = /usr/local
|
||||
srcdir=.
|
||||
|
||||
+sbindir = ${basedir}/sbin
|
||||
libdir = ${basedir}/lib
|
||||
incdir = ${basedir}/include
|
||||
mandir = ${basedir}/share/man
|
||||
|
||||
CC = gcc
|
||||
-LCFLAGS = -g -O2 -fPIC -Wall -pipe -D_REENTRANT
|
||||
-CFLAGS = -g
|
||||
+CFLAGS = -g -O2 -Wall -pipe
|
||||
+LCFLAGS = ${CFLAGS} -fPIC -D_REENTRANT
|
||||
LDLIBS = -llockdev
|
||||
|
||||
.PHONY: shared static perl-lib
|
||||
-ALL: shared static perl-lib
|
||||
+ALL: shared static lockdev perl-lib
|
||||
|
||||
static ${static}: ${objs}
|
||||
$(AR) $(ARFLAGS) ${static} $^
|
||||
|
||||
-shared ${shared}: ${shobjs}
|
||||
+shared ${shared}: ${objs}
|
||||
${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared}
|
||||
|
||||
-src/lockdev.z: src/lockdev.c
|
||||
- ${CC} ${CFLAGS} -c -fPIC -o $@ $?
|
||||
+lockdev.o: ${lockdev}
|
||||
+ ${CC} ${CFLAGS} -I./src -o $@ -c $^
|
||||
|
||||
+lockdev: lockdev.o ${static}
|
||||
+ ${CC} -o $@ $^
|
||||
|
||||
perl-lib: static
|
||||
cd LockDev && perl Makefile.PL INSTALLDIRS=vendor
|
||||
@@ -54,6 +57,7 @@ install_dev: ${static} src/lockdev.h
|
||||
install -m755 -d ${incdir}
|
||||
install -m644 src/lockdev.h ${incdir}
|
||||
install -m644 src/ttylock.h ${incdir}
|
||||
+ install -m644 src/baudboy.h ${incdir}
|
||||
|
||||
install_debug: ${static} ${shared}
|
||||
install -m755 -d ${libdir}/debug
|
||||
@@ -71,7 +75,9 @@ install_doc: docs/lockdev.3
|
||||
|
||||
install_run: ${shared}
|
||||
install -m755 -d ${libdir}
|
||||
- install -m644 ${shared} ${libdir}
|
||||
+ install -m755 ${shared} ${libdir}
|
||||
+ install -m755 -d ${sbindir}
|
||||
+ install -m755 lockdev ${sbindir}
|
||||
|
||||
.PHONY: clean distclean perl-clean mostyclean
|
||||
perl-clean: clean
|
||||
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
|
||||
+ modify it under the terms of the GNU Lesser General Public License
|
||||
+ as published by the Free Software Foundation; either version 2 of
|
||||
+ the License, or (at your option) any later version.
|
||||
+
|
||||
+ It is distributed in the hope that it will be useful, but WITHOUT
|
||||
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
+ Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with this software; if not, write to the Free
|
||||
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
+ 02111-1307 USA. */
|
||||
+
|
||||
+
|
||||
+#ifndef _BAUDBOY_H_
|
||||
+#define _BAUDBOY_H_
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <signal.h>
|
||||
+#include <sys/wait.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <errno.h>
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
+#define LOCKDEV_PATH "/usr/sbin/lockdev"
|
||||
+
|
||||
+static inline int _doit(const char * argv[])
|
||||
+{
|
||||
+ pid_t child;
|
||||
+ int status;
|
||||
+ void (*osig) (int) = signal(SIGCHLD, SIG_DFL);
|
||||
+ int rc;
|
||||
+
|
||||
+ if (!(child = fork())) {
|
||||
+ int fd;
|
||||
+ /* these have to be open to something */
|
||||
+ if ((fd = open("/dev/null", 2)) < 0)
|
||||
+ exit(-1);
|
||||
+ dup2(fd, 0);
|
||||
+ dup2(fd, 1);
|
||||
+ dup2(fd, 2);
|
||||
+ close(fd);
|
||||
+ /* Swap egid and gid for lockdev's access(2) device check. */
|
||||
+ setregid(getegid(), getgid());
|
||||
+ execv(argv[0], (char *const *)argv);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ rc = (int) waitpid(child, &status, 0);
|
||||
+ signal(SIGCHLD, osig);
|
||||
+ if (rc == child && WIFEXITED(status)) {
|
||||
+ /*
|
||||
+ * Exit dev_lock dev_unlock dev_testlock
|
||||
+ * 0 OK OK not locked
|
||||
+ * 1 locked other locked other locked
|
||||
+ * 2 EACCES
|
||||
+ * 3 EROFS
|
||||
+ * 4 EFAULT
|
||||
+ * 5 EINVAL
|
||||
+ * 6 ENAMETOOLONG
|
||||
+ * 7 ENOENT
|
||||
+ * 8 ENOTDIR
|
||||
+ * 9 ENOMEM
|
||||
+ * 10 ELOOP
|
||||
+ * 11 EIO
|
||||
+ * 255 error error error
|
||||
+ */
|
||||
+ rc = WEXITSTATUS(status);
|
||||
+ switch(rc) {
|
||||
+ case 0: rc = 0; break;
|
||||
+ default:
|
||||
+ case 1: rc = -EPERM; break;
|
||||
+ case 2: rc = -EACCES; break;
|
||||
+ case 3: rc = -EROFS; break;
|
||||
+ case 4: rc = -EFAULT; break;
|
||||
+ case 5: rc = -EINVAL; break;
|
||||
+ case 6: rc = -ENAMETOOLONG; break;
|
||||
+ case 7: rc = -ENOENT; break;
|
||||
+ case 8: rc = -ENOTDIR; break;
|
||||
+ case 9: rc = -ENOMEM; break;
|
||||
+ case 10: rc = -ELOOP; break;
|
||||
+ case 11: rc = -EIO; break;
|
||||
+ }
|
||||
+ } else if (rc == -1)
|
||||
+ rc = -errno;
|
||||
+ else
|
||||
+ rc = -ECHILD;
|
||||
+
|
||||
+ return rc;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static inline int ttylock(const char * devname)
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, "-l", NULL, NULL};
|
||||
+ argv[2] = devname;
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttyunlock(const char * devname)
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, "-u", NULL, NULL};
|
||||
+ argv[2] = devname;
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttylocked(const char * devname)
|
||||
+{
|
||||
+ const char * argv[] = { LOCKDEV_PATH, NULL, NULL};
|
||||
+ argv[1] = devname;
|
||||
+ return _doit(argv);
|
||||
+}
|
||||
+
|
||||
+static inline int ttywait(const char * devname)
|
||||
+{
|
||||
+ int rc;
|
||||
+ while((rc = ttylocked(devname)) == 0)
|
||||
+ sleep(1);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
+#endif /* _BAUDBOY_H_ */
|
||||
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;
|
||||
}
|
||||
|
||||
+static pid_t dev_pid = 0;
|
||||
+
|
||||
+pid_t dev_getpid(void)
|
||||
+{
|
||||
+ return (dev_pid ? dev_pid : getpid());
|
||||
+}
|
||||
+
|
||||
+pid_t dev_setpid(pid_t newpid)
|
||||
+{
|
||||
+ pid_t oldpid = dev_pid;
|
||||
+ dev_pid = newpid;
|
||||
+ return oldpid;
|
||||
+}
|
||||
|
||||
/*
|
||||
* for internal use *
|
||||
@@ -423,7 +436,7 @@ _dl_check_lock(const char *lockname)
|
||||
* maybe also this sprintf should be added to the
|
||||
* conditional part, as the others
|
||||
*/
|
||||
- sprintf( tpname, "%s/.%d", LOCK_PATH, (int)getpid());
|
||||
+ sprintf( tpname, "%s/.%d", LOCK_PATH, (int)dev_getpid());
|
||||
unlink( tpname); /* in case there was */
|
||||
rename( lockname, tpname);
|
||||
if ( ! (fd=fopen( tpname, "r")) ) {
|
||||
@@ -520,7 +533,7 @@ dev_testlock(const char *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
|
||||
@@ -585,7 +598,7 @@ dev_lock (const char *devname)
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_lock(%s)\n", devname);
|
||||
if (oldmask == -1 )
|
||||
- oldmask = umask( 0); /* give full permissions to files created */
|
||||
+ oldmask = umask( 002); /* apply o-w to files created */
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -596,11 +609,14 @@ dev_lock (const char *devname)
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(-errno);
|
||||
+ }
|
||||
+ if ( access( device, W_OK ) == -1 ) {
|
||||
+ close_n_return(-errno);
|
||||
}
|
||||
|
||||
/* now get our own pid */
|
||||
- our_pid = getpid();
|
||||
+ our_pid = dev_getpid();
|
||||
_debug( 2, "dev_lock() our own pid = %d\n", (int)our_pid);
|
||||
|
||||
/* We will use this algorithm:
|
||||
@@ -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 )) {
|
||||
+ int rc = -errno;
|
||||
unlink( lock0);
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(rc);
|
||||
}
|
||||
}
|
||||
if ( pid != our_pid ) {
|
||||
@@ -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 )) {
|
||||
+ int rc = -errno;
|
||||
unlink( lock0);
|
||||
unlink( lock1);
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(rc);
|
||||
}
|
||||
}
|
||||
if ( pid != our_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 )
|
||||
- oldmask = umask( 0); /* give full permissions to files created */
|
||||
+ oldmask = umask( 002); /* apply o-w to files created */
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -751,11 +769,14 @@ dev_relock (const char *devname,
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(-errno);
|
||||
+ }
|
||||
+ if ( access( device, W_OK ) == -1 ) {
|
||||
+ close_n_return(-errno);
|
||||
}
|
||||
|
||||
/* now get our own pid */
|
||||
- our_pid = getpid();
|
||||
+ our_pid = dev_getpid();
|
||||
_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
|
||||
@@ -825,7 +846,7 @@ dev_unlock (const char *devname,
|
||||
#endif /* DEBUG */
|
||||
_debug( 3, "dev_unlock(%s, %d)\n", devname, (int)pid);
|
||||
if (oldmask == -1 )
|
||||
- oldmask = umask( 0); /* give full permissions to files created */
|
||||
+ oldmask = umask( 002); /* apply o-w to files created */
|
||||
if ( ! (p=_dl_check_devname( devname)) )
|
||||
close_n_return( -1);
|
||||
strcpy( device, DEV_PATH);
|
||||
@@ -836,7 +857,10 @@ dev_unlock (const char *devname,
|
||||
* and minor numbers
|
||||
*/
|
||||
if ( stat( device, &statbuf) == -1 ) {
|
||||
- close_n_return( -1);
|
||||
+ close_n_return(-errno);
|
||||
+ }
|
||||
+ if ( access( device, W_OK ) == -1 ) {
|
||||
+ close_n_return(-errno);
|
||||
}
|
||||
|
||||
/* first remove the FSSTND-1.2 lock, get the pid of the
|
||||
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 */
|
||||
|
||||
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 (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 (void)
|
||||
{
|
||||
- fprintf( stderr, "Usage: sample [-lurd] <device>\n" );
|
||||
- exit( -1 );
|
||||
+ fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev");
|
||||
+ exit(-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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-- ) {
|
||||
@@ -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':
|
||||
liblockdev_incr_debug();
|
||||
break;
|
||||
@@ -33,31 +32,52 @@ main (int argc,
|
||||
}
|
||||
else dev = p;
|
||||
}
|
||||
- fprintf( stderr, "option %c, device %s\n", ch, dev );
|
||||
i = 0;
|
||||
+ (void) dev_setpid(getppid());
|
||||
switch( ch ) {
|
||||
case 'l':
|
||||
i = dev_lock( dev);
|
||||
break;
|
||||
case 'u':
|
||||
- i = dev_unlock( dev, 0);
|
||||
- break;
|
||||
- case 'r':
|
||||
- dev_lock( dev);
|
||||
- if(( chld = fork()) == 0 ) {
|
||||
- sleep(5);
|
||||
- }
|
||||
- else {
|
||||
- sleep( 1);
|
||||
- if (( i = dev_relock( dev, chld)) < 0 ) {
|
||||
- fprintf( stderr, "Relock failed in parent.\n" );
|
||||
- }
|
||||
- }
|
||||
+ i = dev_unlock(dev, 0);
|
||||
break;
|
||||
default:
|
||||
- i = dev_testlock( dev);
|
||||
+ if (dev)
|
||||
+ i = dev_testlock(dev);
|
||||
break;
|
||||
}
|
||||
- exit( i);
|
||||
-}
|
||||
|
||||
+ /*
|
||||
+ * Exit dev_lock dev_unlock dev_testlock
|
||||
+ * 0 OK OK not locked
|
||||
+ * 1 locked other locked other locked
|
||||
+ * 2 EACCES
|
||||
+ * 3 EROFS
|
||||
+ * 4 EFAULT
|
||||
+ * 5 EINVAL
|
||||
+ * 6 ENAMETOOLONG
|
||||
+ * 7 ENOENT
|
||||
+ * 8 ENOTDIR
|
||||
+ * 9 ENOMEM
|
||||
+ * 10 ELOOP
|
||||
+ * 11 EIO
|
||||
+ * 255 error error error
|
||||
+ */
|
||||
+ switch (i) {
|
||||
+ case -EACCES: i = 2; break;
|
||||
+ case -EROFS: i = 3; break;
|
||||
+ case -EFAULT: i = 4; break;
|
||||
+ case -EINVAL: i = 5; break;
|
||||
+ case -ENAMETOOLONG: i = 6; break;
|
||||
+ case -ENOENT: i = 7; break;
|
||||
+ case -ENOTDIR: i = 8; break;
|
||||
+ case -ENOMEM: i = 9; break;
|
||||
+ case -ELOOP: i = 10; break;
|
||||
+ case -EIO: i = 11; break;
|
||||
+ default:
|
||||
+ if (i < 0) i = 255;
|
||||
+ else if (i > 0) i = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ exit(i);
|
||||
+}
|
@ -1,20 +0,0 @@
|
||||
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]*'}
|
||||
|
||||
static = ${libname}.a
|
||||
-shared = ${libname}.${VER}.so
|
||||
+shared = ${libname}.so.${VER}
|
||||
soname = ${libname}.so.${MVER}
|
||||
|
||||
# overwritten by caller (e.g.: debian/rules)
|
||||
@@ -80,6 +80,7 @@ install_doc: docs/lockdev.3
|
||||
install_run: ${shared}
|
||||
install -m755 -d ${libdir}
|
||||
install -m755 ${shared} ${libdir}
|
||||
+ ln -s ${shared} ${libdir}/liblockdev.so
|
||||
install -m755 -d ${sbindir}
|
||||
install -m755 lockdev ${sbindir}
|
||||
|
45
lockdev.8
45
lockdev.8
@ -1,45 +0,0 @@
|
||||
.\"
|
||||
.TH LOCKDEV 8 "SEPTEMBER 2009" "" ""
|
||||
.\"
|
||||
.\" Man page written by Jiri Popelka <jpopelka AT redhat DOT com>
|
||||
.\"
|
||||
.SH NAME
|
||||
\fBLockdev\fR is a setgid binary,
|
||||
which provides a reliable way to put an exclusive lock
|
||||
in /var/lock to devices (e.g. ttyS0) using both FSSTND and SVr4 methods,
|
||||
so regular users don't need write access there.
|
||||
|
||||
This task is achieved through calls to the liblockdev(3) API.
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B /usr/sbin/lockdev
|
||||
.RB [< operation >]
|
||||
.RB < device >
|
||||
|
||||
.SH DESCRIPTION
|
||||
The \fBlockdev\fR command can perform one of the following operations (calls to liblockdev(3) API):
|
||||
|
||||
\fB-l\fR - lock device with \fBdev_lock()\fR function
|
||||
|
||||
\fB-u\fR - unlock device with \fBdev_unlock()\fR function
|
||||
|
||||
\fBno operation\fR - test lock with \fBdev_testlock()\fR function
|
||||
|
||||
.SH RETURN VALUES
|
||||
Value dev_lock dev_unlock dev_testlock
|
||||
0 OK OK not locked
|
||||
1 locked other locked other locked
|
||||
2 EACCES
|
||||
3 EROFS
|
||||
4 EFAULT
|
||||
5 EINVAL
|
||||
6 ENAMETOOLONG
|
||||
7 ENOENT
|
||||
8 ENOTDIR
|
||||
9 ENOMEM
|
||||
10 ELOOP
|
||||
11 EIO
|
||||
255 error error error
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR lockdev (3).
|
@ -7,10 +7,10 @@
|
||||
Summary: A library for locking devices
|
||||
Name: lockdev
|
||||
Version: 1.0.4
|
||||
Release: 0.1.%{checkout}%{?dist}
|
||||
Release: 0.2.%{checkout}%{?dist}
|
||||
License: LGPLv2
|
||||
Group: System Environment/Libraries
|
||||
URL: http://packages.debian.org/unstable/source/lockdev
|
||||
URL: https://alioth.debian.org/projects/lockdev/
|
||||
|
||||
# This is a nightly snapshot downloaded via
|
||||
# https://alioth.debian.org/snapshots.php?group_id=100443
|
||||
@ -89,6 +89,10 @@ exit 0
|
||||
%{_includedir}/*
|
||||
|
||||
%changelog
|
||||
* Wed Oct 19 2011 Jiri Popelka <jpopelka@redhat.com> - 1.0.4-0.2.20111007git
|
||||
- Fixed URL
|
||||
- Removed unused patches
|
||||
|
||||
* Fri Oct 07 2011 Jiri Popelka <jpopelka@redhat.com> - 1.0.4-0.1.20111007git
|
||||
- pre 1.0.4 nightly snapshot
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user