[LinuxPPS] [PATCH] time_pps_findpath()
Rodolfo Giometti
giometti at linux.it
Tue Jun 20 09:58:22 CEST 2006
On Mon, Jun 19, 2006 at 10:25:35PM +0200, Rodolfo Giometti wrote:
>
> +#ifdef PPS_HAVE_FINDPATH
> + /* Get the PPS source's real name */
> + fd = readlink(link, path, STRING_LEN-1);
> + if (fd <= 0) {
> + msyslog(LOG_ERR, "refclock: PPS source \"%s\" is not a valid link", PPS_DEVI\CE);
> + return (1);
> + }
> + path[fd] = '\0';
> +
> + /* Try to find the source */
> + fd = time_pps_findpath(path, STRING_LEN, id, STRING_LEN);
> + if (fd < 0) {
> + msyslog(LOG_ERR, "refclock: cannot find PPS source \"%s\" in the system", PPS_DEVICE);
> + return (1);
> + }
> + msyslog(LOG_INFO, "refclock: found PPS source \"%s\" at id #%d on \"%s\"", PPS_DEVICE, fd, id);
> +#endif /* PPS_HAVE_FINDPATH */
> +
> +
> if (time_pps_create(fd, &pps_handle) < 0) {
> - pps_handle = 0;
> msyslog(LOG_ERR,
> "refclock: time_pps_create failed: %m");
> }
Smarter programs may also test the link and returns the link itself in
case of error, so the user may address a specific filename also.
fd = readlink(link, path, STRING_LEN-1);
if (fd <= 0)
strncpy(path, link, STRING_LEN);
else
path[fd] = '\0';
In this manner the user may refere directly to device
"/dev/ttyS0"... this evening I'll do some tests about it.
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti at enneenne.com
Linux Device Driver giometti at gnudd.com
Embedded Systems giometti at linux.it
UNIX programming phone: +39 349 2432127
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://ml.enneenne.com/pipermail/linuxpps/attachments/20060620/df405782/attachment.pgp
More information about the LinuxPPS
mailing list