Hi,

I recently got access to an other IBM ThinkPad 770, and so I tried to set
up a IrLAN connection betwen them two, and had success.

Till yesterday I was using a stock 2.2.10 kernel, so I won't bother you
with some notes what was working how good and so on. I've upgradet to the
recent stable kernel and I'm looking forward to test the current IrDA
support in the next couple of days.

Never the less, as I set up the IrLAN conection I had a look at the source
code of irmanager and irattach (from the irda-utils-0.9.3-pre8 source,
which seem to me to be still the current release), and some lines of the
code seems to me a littel bit strange. I did some hacking, and here is the
result.

I've included the /etc/irda/{drivers,network} files, I use.

Changes I made:

* removed the secend fork() in the function fork_now(), util.c. (why was
it there?)

* removed the close all files part in the function fork_now(), util.c. The
result was, that the syslog() calls began to work properly (prior to that
the first syslog() call after fork_now() got lost)

* after the change above the start_service("drivers"...) didn't terminate
correctly (the irmanager hang at the 'while (fgets(line, 255, f))' line
in the execute() function, util.c). I added a close all files part to the
irattach code after the fork_now() call, and it worked again.

* finally I added some code to close the IrDA device (in cleanup(),
irmanager.c) so that the call stop_service("drivers","") (which allso was
added, therefore some changes in /etc/irda/drivers) can now remove all
loaded modules...

Martin 

-- 
For public PGP-key:  finger [EMAIL PROTECTED]

some config-stuff

Common subdirectories: irda-utils.orig/CVS and irda-utils/CVS
diff -u irda-utils.orig/Makefile irda-utils/Makefile
--- irda-utils.orig/Makefile    Mon May 17 23:30:34 1999
+++ irda-utils/Makefile Tue Aug 31 07:53:15 1999
@@ -82,7 +82,54 @@
 
 # DO NOT DELETE
 
-
-
-
-
+irmanager.o: /usr/include/unistd.h /usr/include/features.h
+irmanager.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+irmanager.o: /usr/include/posix_opt.h /usr/include/gnu/types.h
+irmanager.o: /usr/lib/gcc-lib/i486-linux/2.7.2.3/include/stddef.h
+irmanager.o: /usr/include/confname.h /usr/include/stdlib.h
+irmanager.o: /usr/include/sys/types.h /usr/include/time.h
+irmanager.o: /usr/include/endian.h /usr/include/bytesex.h
+irmanager.o: /usr/include/sys/select.h /usr/include/selectbits.h
+irmanager.o: /usr/include/alloca.h /usr/include/string.h /usr/include/fcntl.h
+irmanager.o: /usr/include/fcntlbits.h /usr/include/stdio.h
+irmanager.o: /usr/include/libio.h /usr/include/_G_config.h
+irmanager.o: /usr/lib/gcc-lib/i486-linux/2.7.2.3/include/stdarg.h
+irmanager.o: /usr/include/stdio_lim.h /usr/include/errno.h
+irmanager.o: /usr/include/errnos.h /usr/include/linux/errno.h
+irmanager.o: /usr/include/asm/errno.h /usr/include/assert.h
+irmanager.o: /usr/include/signal.h /usr/include/sigset.h
+irmanager.o: /usr/include/signum.h /usr/include/sigaction.h
+irmanager.o: /usr/include/sigcontext.h /usr/include/asm/sigcontext.h
+irmanager.o: /usr/include/sigstack.h /usr/include/syslog.h
+irmanager.o: /usr/include/sys/syslog.h /usr/include/sys/stat.h
+irmanager.o: /usr/include/statbuf.h /usr/include/sys/ioctl.h
+irmanager.o: /usr/include/ioctls.h /usr/include/asm/ioctls.h
+irmanager.o: /usr/include/asm/ioctl.h /usr/include/ioctl-types.h
+irmanager.o: /usr/include/sys/ttydefaults.h /usr/include/sys/utsname.h
+irmanager.o: /usr/include/utsnamelen.h irmanager.h
+util.o: /usr/include/sys/types.h /usr/include/features.h
+util.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+util.o: /usr/include/gnu/types.h /usr/include/time.h
+util.o: /usr/lib/gcc-lib/i486-linux/2.7.2.3/include/stddef.h
+util.o: /usr/include/endian.h /usr/include/bytesex.h
+util.o: /usr/include/sys/select.h /usr/include/selectbits.h
+util.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
+util.o: /usr/lib/gcc-lib/i486-linux/2.7.2.3/include/stdarg.h
+util.o: /usr/include/stdio_lim.h /usr/include/stdlib.h /usr/include/alloca.h
+util.o: /usr/include/string.h /usr/include/unistd.h /usr/include/posix_opt.h
+util.o: /usr/include/confname.h /usr/include/fcntl.h /usr/include/fcntlbits.h
+util.o: /usr/include/errno.h /usr/include/errnos.h /usr/include/linux/errno.h
+util.o: /usr/include/asm/errno.h /usr/include/syslog.h
+util.o: /usr/include/sys/syslog.h /usr/include/getopt.h /usr/include/signal.h
+util.o: /usr/include/sigset.h /usr/include/signum.h /usr/include/sigaction.h
+util.o: /usr/include/sigcontext.h /usr/include/asm/sigcontext.h
+util.o: /usr/include/sigstack.h /usr/include/sys/time.h
+util.o: /usr/include/timebits.h /usr/include/sys/ioctl.h
+util.o: /usr/include/ioctls.h /usr/include/asm/ioctls.h
+util.o: /usr/include/asm/ioctl.h /usr/include/ioctl-types.h
+util.o: /usr/include/sys/ttydefaults.h /usr/include/sys/wait.h
+util.o: /usr/include/waitflags.h /usr/include/waitstatus.h
+util.o: /usr/include/sys/stat.h /usr/include/statbuf.h
+util.o: /usr/include/sys/utsname.h /usr/include/utsnamelen.h
+util.o: /usr/include/sys/file.h /usr/include/sys/kd.h /usr/include/linux/kd.h
+util.o: /usr/include/linux/types.h
Common subdirectories: irda-utils.orig/etc and irda-utils/etc
Common subdirectories: irda-utils.orig/gnobex and irda-utils/gnobex
diff -u irda-utils.orig/irattach.c irda-utils/irattach.c
--- irda-utils.orig/irattach.c  Mon May 17 23:30:36 1999
+++ irda-utils/irattach.c       Tue Aug 31 07:53:15 1999
@@ -138,6 +138,7 @@
        int fd = -1;
        int c;
        int dongle = -1;
+       int i;
 
 
        printf("%s\n", VERSION);
@@ -148,9 +149,15 @@
        
        fork_now();
 
+       /* Close all open inherited files! */
+
+       for(i=0;i<64;i++) 
+               close(i);
+
        /*
         * Open the serial device and set it up to be the irda interface.
         */
+
        if ((fd = open(argv[1], O_NONBLOCK | O_RDWR, 0)) < 0) {
                syslog(LOG_ERR, "Failed to open %s: %m", argv[1]);
                exit(1);
Common subdirectories: irda-utils.orig/irdadump and irda-utils/irdadump
Common subdirectories: irda-utils.orig/irdalib and irda-utils/irdalib
Common subdirectories: irda-utils.orig/irdaping and irda-utils/irdaping
Common subdirectories: irda-utils.orig/irkbd and irda-utils/irkbd
diff -u irda-utils.orig/irmanager.c irda-utils/irmanager.c
--- irda-utils.orig/irmanager.c Mon May 17 23:30:37 1999
+++ irda-utils/irmanager.c      Tue Aug 31 07:53:15 1999
@@ -52,6 +52,8 @@
 extern int caught_signal;
 extern int be_quiet;
 
+int dev_fd=-1;
+
 static char *configpath = "/etc/irda";
 
 /* Default path for pid file */
@@ -141,10 +143,14 @@
        case SIGTERM:
        case SIGINT:
                syslog(LOG_INFO, "got SIGTERM or SIGINT\n");
+               close(dev_fd);
+               stop_service("drivers","");
                exit(0);
                break;
        case SIGHUP:
                syslog(LOG_INFO, "got SIGHUP\n");
+               close(dev_fd);
+               stop_service("drivers","");
                exit(0);
                break;
        default:
@@ -169,6 +175,9 @@
        int ret;
        int c;
 
+       be_quiet = FALSE;
+
+
        minor = lookup_dev("irda");
        if (minor < 0 ) {
                load_module("irda");
@@ -194,6 +203,9 @@
                        if (strcmp(optarg, "1") == 0) {
                                be_quiet = FALSE;
                        }
+                       else {
+                               be_quiet = TRUE;
+                       }
                        break;
                default:
                        break;
@@ -203,9 +215,9 @@
        /* Use hostname as device name */
        if (uname(&buf) == 0) {
                set_sysctl_param("devname", strtok(buf.nodename, "."));
-       }
-       
-       fork_now();
+       }       
+
+       fork_now();
 
        if (signal(SIGHUP, cleanup) == SIG_ERR)
                syslog(LOG_INFO, "signal(SIGHUP): %m");
@@ -217,7 +229,7 @@
        if (chdir(configpath) != 0)
                syslog(LOG_INFO, "chdir to %s failed: %m", configpath);
 
-       fd = open_dev((10 << 8)+minor,S_IREAD|S_IFCHR);
+       dev_fd = fd = open_dev((10 << 8)+minor,S_IREAD|S_IFCHR);
        if (fd == -1) {
                syslog(LOG_INFO, "Unable to open IrDA device!\n");
                exit(-1); 
Common subdirectories: irda-utils.orig/irsockets and irda-utils/irsockets
Common subdirectories: irda-utils.orig/obex and irda-utils/obex
Common subdirectories: irda-utils.orig/psion and irda-utils/psion
diff -u irda-utils.orig/util.c irda-utils/util.c
--- irda-utils.orig/util.c      Mon May 17 23:30:37 1999
+++ irda-utils/util.c   Tue Aug 31 07:53:15 1999
@@ -128,10 +128,10 @@
        syslog(LOG_INFO, "executing: '%s'", cmd);
        strcat(cmd, " 2>&1");
        f = popen(cmd, "r");
-       while (fgets(line, 255, f)) {
+               while (fgets(line, 255, f)) {
                line[strlen(line)-1] = '\0';
                syslog(LOG_INFO, "+ %s", line);
-       }
+               }       
        ret = pclose(f);
        if (WIFEXITED(ret)) {
                if (WEXITSTATUS(ret))
@@ -157,7 +157,6 @@
 void fork_now(void)
 {
        int ret;
-       int i;
 
        if ((ret = fork()) > 0)
                exit(0);
@@ -166,15 +165,6 @@
                syslog(LOG_INFO, "forking: %m");
        if (setsid() < 0)
                syslog(LOG_INFO, "detaching from tty: %m");
-
-       if ((ret = fork()) > 0) {
-               /* cleanup_files = 0; */
-               exit(0);
-       }
-
-       /* Close all open inherited files! */
-       for (i=0;i<64;i++)
-               close(i);
 } 
 
 

Reply via email to