From: Reg Clemens Date: Sun, 10 Aug 2008 22:31:13 +0000 (-0400) Subject: [BUG 1052] Modify ONCORE driver for linuxPPS which uses a line discipline for the X-Git-Tag: NTP_4_2_5P125~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0581d96a11515fa5825a76cc4cb5fd8e3d92101a;p=thirdparty%2Fntp.git [BUG 1052] Modify ONCORE driver for linuxPPS which uses a line discipline for the PPS source. bk: 489f6c316jafg4ckXF2wWucUyeyrNw --- diff --git a/ntpd/refclock_oncore.c b/ntpd/refclock_oncore.c index 0244b50af..115e70297 100644 --- a/ntpd/refclock_oncore.c +++ b/ntpd/refclock_oncore.c @@ -594,24 +594,39 @@ oncore_start( Since things ALWAYS work if we only open the device once, we check to see if the two devices are in fact the same, then proceed to do one open or two. + + For use with linuxPPS we assume that the N_TTY file has been opened + and that the line discipline has been changed to N_PPS by another + program (say ppsldisc) so that the two files expected by the oncore + driver can be opened. + + Note that the linuxPPS N_PPS file is just like a N_TTY, so we can do + the stat below without error even though the file has already had its + line discipline changed by another process. */ + stat1.st_dev = stat1.st_ino = -1; if (stat(device1, &stat1)) { sprintf(Msg, "Can't stat fd1 (%s)\n", device1); record_clock_stats(&(instance->peer->srcadr), Msg); - exit(1); } - if (stat(device2, &stat2)) { - sprintf(Msg, "Can't stat fd2 (%s)\n", device2); + if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) { + sprintf(Msg, "Can't open fd1 (%s)\n", device1); record_clock_stats(&(instance->peer->srcadr), Msg); exit(1); } - if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) { - sprintf(Msg, "Can't open fd1 (%s)\n", device1); + /* for LINUX the PPS device is the result of a line discipline. + It seems simplest to let an external program create the appropriate + /dev/pps file, and only check (carefully) for its existance here + */ + + stat2.st_dev = stat2.st_ino = -2; + if (stat(device2, &stat2)) { + sprintf(Msg, "Can't stat fd2 (%s) errno = %d\n", device2, errno); record_clock_stats(&(instance->peer->srcadr), Msg); - exit(1); + record_clock_stats(&(instance->peer->srcadr), "May be line discipline, see if we can open it."); } if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino)) /* same device here */