auto-import changelog data from lockdev-1.0.0-15.src.rpm

Fri Oct 26 2001 Trond Eivind Glomsrd <teg@redhat.com> 1.0.0-15
- Add copyright/license info to baudboy.h (#54321)
This commit is contained in:
cvsdist 2004-09-09 07:58:46 +00:00
parent 7394653a58
commit 92a8dd8141
2 changed files with 288 additions and 262 deletions

View File

@ -1,79 +1,133 @@
--- lockdev-1.0.0/src/sample.c.rh Wed Dec 1 06:50:09 1999 diff -uNr lockdev-1.0.0.orig/Makefile lockdev-1.0.0/Makefile
+++ lockdev-1.0.0/src/sample.c Tue Sep 4 13:39:00 2001 --- lockdev-1.0.0.orig/Makefile Wed Dec 1 05:56:22 1999
@@ -3,27 +3,26 @@ +++ lockdev-1.0.0/Makefile Fri Oct 26 11:40:18 2001
@@ -6,6 +6,8 @@
void objs = src/lockdev.o
usage() {
- fprintf( stderr, "Usage: sample [-lurd] <device>\n" ); +lockdev = src/sample.c
- exit( -1 ); +
+ fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev");
VER = $(shell expr `pwd` : '.*-\([0-9.]*\)')
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'}
@@ -18,17 +20,18 @@
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} $^
@@ -36,6 +39,11 @@
shared ${shared}: ${objs}
${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared}
+lockdev.o: ${lockdev}
+ ${CC} ${CFLAGS} -I./src -o $@ -c $^
+
+lockdev: lockdev.o ${static}
+ ${CC} -o $@ $^
perl-lib: static
cd LockDev && perl Makefile.PL INSTALLDIRS=perl
@@ -51,6 +59,7 @@
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
@@ -68,7 +77,9 @@
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 -uNr lockdev-1.0.0.orig/src/baudboy.h lockdev-1.0.0/src/baudboy.h
--- lockdev-1.0.0.orig/src/baudboy.h Wed Dec 31 19:00:00 1969
+++ lockdev-1.0.0/src/baudboy.h Fri Oct 26 11:40:26 2001
@@ -0,0 +1,136 @@
+/* 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>
+
+#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_IGN);
+ int rc;
+
+ if (!(child = fork())) {
+ int fd;
+ /* these have to be open to something */
+ if ((fd = open("/dev/null", 2)) < 0)
+ exit(-1); + exit(-1);
} + dup2(fd, 0);
+ dup2(fd, 1);
int debug; + dup2(fd, 2);
+ close(fd);
+ /* Swap egid and gid for lockdev's access(2) device check. */
int + setregid(getegid(), getgid());
-main( int argc, char *argv[] ) + execv(argv[0], (char *const *)argv);
+main(int argc, char *argv[]) + exit(-1);
{ + }
int i, chld; +
- char *p, *dev, ch; + rc = (int) waitpid(child, &status, 0);
+ char *p = NULL, *dev = NULL, ch; + signal(SIGCHLD, osig);
+ if (rc == child && WIFEXITED(status)) {
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) {
case 'l':
- case 'u':
- case 'r': ch = *p; break;
+ case 'u': ch = *p; break;
case 'd':
debug = atoi(++p);
break;
@@ -32,31 +31,52 @@
}
else dev = p;
}
- fprintf( stderr, "option %c, device %s\n", ch, dev );
i = 0;
- switch( ch ) {
+ (void) dev_setpid(getppid());
+ switch(ch) {
case 'l':
- i = dev_lock( dev);
+ 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 + * Exit dev_lock dev_unlock dev_testlock
+ * 0 OK OK not locked + * 0 OK OK not locked
@ -90,26 +144,68 @@
+ * 11 EIO + * 11 EIO
+ * 255 error error error + * 255 error error error
+ */ + */
+ switch (i) { + rc = WEXITSTATUS(status);
+ case -EACCES: i = 2; break; + switch(rc) {
+ case -EROFS: i = 3; break; + case 0: rc = 0; 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: + default:
+ if (i < 0) i = 255; + case 1: rc = -EPERM; break;
+ else if (i > 0) i = 1; + case 2: rc = -EACCES; break;
+ 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;
+ } + }
+ exit(i); + } else if (rc == -1)
+ rc = -errno;
+ else
+ rc = -ECHILD;
+
+ return rc;
+
+} +}
--- lockdev-1.0.0/src/lockdev.c.rh Wed Dec 1 06:43:47 1999 +
+++ lockdev-1.0.0/src/lockdev.c Tue Sep 4 13:39:00 2001 +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 -uNr lockdev-1.0.0.orig/src/lockdev.c lockdev-1.0.0/src/lockdev.c
--- lockdev-1.0.0.orig/src/lockdev.c Wed Dec 1 06:43:47 1999
+++ lockdev-1.0.0/src/lockdev.c Fri Oct 26 11:40:18 2001
@@ -176,6 +176,19 @@ @@ -176,6 +176,19 @@
liblockdev_debug = 0; liblockdev_debug = 0;
} }
@ -244,8 +340,9 @@
} }
/* first remove the FSSTND-1.2 lock, get the pid of the /* first remove the FSSTND-1.2 lock, get the pid of the
--- lockdev-1.0.0/src/lockdev.h.rh Wed Dec 1 06:39:42 1999 diff -uNr lockdev-1.0.0.orig/src/lockdev.h lockdev-1.0.0/src/lockdev.h
+++ lockdev-1.0.0/src/lockdev.h Tue Sep 4 13:39:00 2001 --- lockdev-1.0.0.orig/src/lockdev.h Wed Dec 1 06:39:42 1999
+++ lockdev-1.0.0/src/lockdev.h Fri Oct 26 11:40:18 2001
@@ -53,6 +53,7 @@ @@ -53,6 +53,7 @@
#endif #endif
@ -264,52 +361,83 @@
pid_t dev_testlock __P(( const char * devname)); pid_t dev_testlock __P(( const char * devname));
pid_t dev_lock __P(( const char * devname)); pid_t dev_lock __P(( const char * devname));
--- lockdev-1.0.0/src/baudboy.h.rh Tue Sep 4 13:39:00 2001 diff -uNr lockdev-1.0.0.orig/src/sample.c lockdev-1.0.0/src/sample.c
+++ lockdev-1.0.0/src/baudboy.h Tue Sep 4 13:44:47 2001 --- lockdev-1.0.0.orig/src/sample.c Wed Dec 1 06:50:09 1999
@@ -0,0 +1,118 @@ +++ lockdev-1.0.0/src/sample.c Fri Oct 26 11:40:18 2001
+#ifndef _BAUDBOY_H_ @@ -3,27 +3,26 @@
+#define _BAUDBOY_H_
+ void
+#include <stdio.h> usage() {
+#include <stdlib.h> - fprintf( stderr, "Usage: sample [-lurd] <device>\n" );
+#include <string.h> - exit( -1 );
+#include <signal.h> + fprintf(stderr, "Usage: %s [-lud] <device>\n", "lockdev");
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.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_IGN);
+ int rc;
+
+ if (!(child = fork())) {
+ int fd;
+ /* these have to be open to something */
+ if ((fd = open("/dev/null", 2)) < 0)
+ exit(-1); + exit(-1);
+ dup2(fd, 0); }
+ dup2(fd, 1);
+ dup2(fd, 2); int debug;
+ close(fd);
+ /* Swap egid and gid for lockdev's access(2) device check. */
+ setregid(getegid(), getgid()); int
+ execv(argv[0], (char *const *)argv); -main( int argc, char *argv[] )
+ exit(-1); +main(int argc, char *argv[])
+ } {
+ int i, chld;
+ rc = (int) waitpid(child, &status, 0); - char *p, *dev, ch;
+ signal(SIGCHLD, osig); + char *p = NULL, *dev = NULL, ch;
+ if (rc == child && WIFEXITED(status)) {
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) {
case 'l':
- case 'u':
- case 'r': ch = *p; break;
+ case 'u': ch = *p; break;
case 'd':
debug = atoi(++p);
break;
@@ -32,31 +31,52 @@
}
else dev = p;
}
- fprintf( stderr, "option %c, device %s\n", ch, dev );
i = 0;
- switch( ch ) {
+ (void) dev_setpid(getppid());
+ switch(ch) {
case 'l':
- i = dev_lock( dev);
+ 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 + * Exit dev_lock dev_unlock dev_testlock
+ * 0 OK OK not locked + * 0 OK OK not locked
@ -326,126 +454,21 @@
+ * 11 EIO + * 11 EIO
+ * 255 error error error + * 255 error error error
+ */ + */
+ rc = WEXITSTATUS(status); + switch (i) {
+ switch(rc) { + case -EACCES: i = 2; break;
+ case 0: rc = 0; 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: + default:
+ case 1: rc = -EPERM; break; + if (i < 0) i = 255;
+ case 2: rc = -EACCES; break; + else if (i > 0) i = 1;
+ case 3: rc = -EROFS; break; + 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) + exit(i);
+ 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_ */
--- lockdev-1.0.0/Makefile.rh Wed Dec 1 05:56:22 1999
+++ lockdev-1.0.0/Makefile Tue Sep 4 13:39:00 2001
@@ -6,6 +6,8 @@
objs = src/lockdev.o
+lockdev = src/sample.c
+
VER = $(shell expr `pwd` : '.*-\([0-9.]*\)')
MVER = ${shell expr `pwd` : '.*-\([0-9]*\).[0-9]*'}
@@ -18,17 +20,18 @@
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} $^
@@ -36,6 +39,11 @@
shared ${shared}: ${objs}
${CC} ${LCFLAGS} -shared -Wl,-soname,${soname} $^ -lc -o ${shared}
+lockdev.o: ${lockdev}
+ ${CC} ${CFLAGS} -I./src -o $@ -c $^
+
+lockdev: lockdev.o ${static}
+ ${CC} -o $@ $^
perl-lib: static
cd LockDev && perl Makefile.PL INSTALLDIRS=perl
@@ -51,6 +59,7 @@
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
@@ -68,7 +77,9 @@
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

View File

@ -1,8 +1,8 @@
Summary: A library for locking devices. Summary: A library for locking devices.
Name: lockdev Name: lockdev
Version: 1.0.0 Version: 1.0.0
Release: 14 Release: 15
Copyright: LGPL License: LGPL
Group: System Environment/Libraries Group: System Environment/Libraries
Source: ftp://ftp.debian.org/debian/dists/woody/main/source/libs/lockdev_1.0.0.tar.gz Source: ftp://ftp.debian.org/debian/dists/woody/main/source/libs/lockdev_1.0.0.tar.gz
Patch0: lockdev-1.0.0-rh.patch Patch0: lockdev-1.0.0-rh.patch
@ -25,10 +25,10 @@ package contains the development headers and a static library.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .rh %patch0 -p1
%build %build
make "CFLAGS=${RPM_OPT_FLAGS}" make "CFLAGS=${RPM_OPT_FLAGS} -fPIC"
%install %install
rm -fr $RPM_BUILD_ROOT rm -fr $RPM_BUILD_ROOT
@ -63,6 +63,9 @@ rm -fr $RPM_BUILD_ROOT
%{_includedir}/* %{_includedir}/*
%changelog %changelog
* Fri Oct 26 2001 Trond Eivind Glomsrød <teg@redhat.com> 1.0.0-15
- Add copyright/license info to baudboy.h (#54321)
* Tue Sep 4 2001 Jeff Johnson <jbj@redhat.com> * Tue Sep 4 2001 Jeff Johnson <jbj@redhat.com>
- swap egid and gid for lockdev's access(2) device check (#52029). - swap egid and gid for lockdev's access(2) device check (#52029).