From: Russell Coker Date: Fri, 11 Jan 2002 18:27:17 +0000 (+0000) Subject: Fix for locking on Linux and related systems, particularly for devfs. X-Git-Tag: ppp-2.4.7~459 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=58d58e6be99ed13fbfe222cb15af7db75154d6c9;hp=e635acbbac0a7f27d110c4ad4d10c71f26b708f4 Fix for locking on Linux and related systems, particularly for devfs. Also include to avoid some warnings. --- diff --git a/pppd/utils.c b/pppd/utils.c index 8b83e34..43ed317 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -17,7 +17,7 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define RCSID "$Id: utils.c,v 1.15 2001/11/09 10:33:04 paulus Exp $" +#define RCSID "$Id: utils.c,v 1.16 2002/01/11 18:27:17 etbe Exp $" #include #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -851,9 +852,20 @@ lock(dev) major(sbuf.st_rdev), minor(sbuf.st_rdev)); #else char *p; + char lockdev[MAXPATHLEN]; + + if ((p = strstr(dev, "dev/")) != NULL) { + dev = p + 4; + strncpy(lockdev, dev, MAXPATHLEN-1); + lockdev[MAXPATHLEN-1] = 0; + while ((p = strrchr(lockdev, '/')) != NULL) { + *p = '_'; + } + dev = lockdev; + } else + if ((p = strrchr(dev, '/')) != NULL) + dev = p + 1; - if ((p = strrchr(dev, '/')) != NULL) - dev = p + 1; slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev); #endif