[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Locking of serial devices and devfs



Here is a bug report that I have just filed against ppp.  I think that 
the same issue also affects other programs that lock serial ports.  What 
do you think of my suggested solution?

----------  Forwarded Message  ----------
Subject: ppp: Locking mechanism has problems
Date: Thu, 21 Jun 2001 08:40:17 +0200 (CEST)
From: russell@coker.com.au
To: submit@bugs.debian.org


Package: ppp
Version: 2.4.1-2
Severity: normal

When creating a lock file under /var/lock ppp does the following:
    if ((p = strrchr(dev, '/')) != NULL)
        dev = p + 1;
    slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);

Now on devfs systems this results in /var/lock/LCK..0 for device
 /dev/tts/0 and the same lock file name for /dev/tte/0 and /dev/ttr/0! 
 So if you have a devfs system with Stallion (tte) and Rocketport (ttr)
 serial ports as well as standard PC serial ports (tts) then you have
 three devices which get /var/lock/LCK..0 as the lock file!

This is a serious issue!

I think that we should use /var/lock/LCK..tts/0 and /var/lock/LCK..tte/0
 etc. It will require the ppp code to be changed to something like the
 following:

if (( p = strstr(dev, "dev/")) != NULL)
    dev = p + 4; /* point to first byte after "dev/" */
slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);
if(strchr(dev, '/'))
{
  char *dir = strdup(dev);
  *(strchr(dir, '/')) = '\0';
  mkdir(dir);
}

I expect that not many people will want to run 100+ instances of the
 regular pppd with several types of serial port on a single machine.  But
 that type of operation is the usual operation of Portslave and I need to
 make it compatible with the locking of the regular pppd.

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page



Reply to: