Lines Matching +full:ouput +full:- +full:only

2  * ntp_ppsdev.c - PPS-device support
6 * ---------------------------------------------------------------------
19 * ---------------------------------------------------------------------
40 /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
43 /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
67 /* ------------------------------------------------------------------ */
79 if (NULL != pxdir->dir) in xdirClose()
80 closedir(pxdir->dir); /* closes the internal FD, too! */ in xdirClose()
81 else if (-1 != pxdir->dfd) in xdirClose()
82 close(pxdir->dfd); /* otherwise _we_ have to do it */ in xdirClose()
83 pxdir->dfd = -1; in xdirClose()
84 pxdir->dir = NULL; in xdirClose()
95 * it's ok to keep the value around -- even if we should do in xdirOpenAt()
99 pxdir->dir = NULL; in xdirOpenAt()
100 if (-1 == (pxdir->dfd = openat(fdo, path, OModeD))) in xdirOpenAt()
102 if (NULL == (pxdir->dir = fdopendir(pxdir->dfd))) in xdirOpenAt()
111 /* --------------------------------------------------------------------
116 * of 4096 bytes when you 'stat' them -- but reading gives EOF after a
130 if (-1 == (dfd = openat(rfd, path, OModeF)) || -1 == fstat(dfd, &sb)) in readFileAt()
138 while (rdlen > 0 && ret[rdlen - 1] <= ' ') in readFileAt()
139 --rdlen; in readFileAt()
145 if (-1 != dfd) in readFileAt()
150 /* --------------------------------------------------------------------
167 if (-1 == fstatat(xdir.dfd, dent->d_name, in findDevByDevId()
173 if (-1 == asprintf(&name, "/dev/%s", dent->d_name)) in findDevByDevId()
183 /* --------------------------------------------------------------------
197 if (-1 != fstat(fd, psb)) { in getCharDevId()
198 rc = S_ISCHR(psb->st_mode); in getCharDevId()
200 *out = psb->st_rdev; in getCharDevId()
207 /* --------------------------------------------------------------------
208 * given the dir-fd of a pps instance dir in the linux sysfs tree, get
227 if ((-1 == stat(bufp, &sb)) || !S_ISCHR(sb.st_mode)) in getPpsTuple()
252 /* --------------------------------------------------------------------
256 * ouput parameter to the PPS dev id and return true...
277 if (strncmp("pps", dent->d_name, 3)) in findPpsDevId()
279 fdDevDir = openat(ClassDir.dfd, dent->d_name, OModeD); in findPpsDevId()
280 if (-1 == fdDevDir) in findPpsDevId()
299 /* --------------------------------------------------------------------
328 /* 'magic' PPS support -- try to instantiate missing PPS devices in findMatchingPpsDev()
329 * on-the-fly. Our mileage may vary -- running as root at that in findMatchingPpsDev()
337 if ((0 != geteuid()) || (-1 == ioctl(fdtty, TIOCSETD, &ldisc))) in findMatchingPpsDev()
339 msyslog(LOG_INFO, "auto-instantiated PPS device for device %u:%u", in findMatchingPpsDev()
355 if (-1 == (fdpps = open(dpath, OModeF))) { in findMatchingPpsDev()
356 msyslog(LOG_ERR, "could not open auto-created '%s': %m", dpath); in findMatchingPpsDev()
359 if (-1 == fchmod(fdpps, sb.st_mode)) { in findMatchingPpsDev()
360 msyslog(LOG_ERR, "could not chmod auto-created '%s': %m", dpath); in findMatchingPpsDev()
362 if (-1 == fchown(fdpps, sb.st_uid, sb.st_gid)) { in findMatchingPpsDev()
363 msyslog(LOG_ERR, "could not chown auto-created '%s': %m", dpath); in findMatchingPpsDev()
375 /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
377 /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
384 int ttyfd , /* current tty FD, or -1 */ in ppsdev_reopen()
385 int ppsfd , /* current pps FD, or -1 */ in ppsdev_reopen()
390 int retfd = -1; in ppsdev_reopen()
404 if (-1 == retfd) { in ppsdev_reopen()
408 ppspath, (retfd != -1 ? "succeeded" : "failed")); in ppsdev_reopen()
414 if ((-1 == retfd) && (-1 != ttyfd)) { in ppsdev_reopen()
419 xpath, (retfd != -1 ? "succeeded" : "failed")); in ppsdev_reopen()
431 if (-1 == retfd) in ppsdev_reopen()
433 if (-1 == retfd) in ppsdev_reopen()
436 /* Close the old pps FD, but only if the new pps FD is neither in ppsdev_reopen()
447 int ttyfd, /* current tty FD, or -1 */ in ppsdev_close()
448 int ppsfd) /* current pps FD, or -1 */ in ppsdev_close()
451 * channel only if it's valid and _NOT_ the tty itself: in ppsdev_close()
453 if ((-1 != ppsfd) && (ttyfd != ppsfd)) in ppsdev_close()
456 /* --*-- that's all folks --*-- */