2 * Copyright (c) 2020 Yubico AB. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
21 fido_hid_unix_open(const char *path)
26 if ((fd = open(path, O_RDWR)) == -1) {
27 if (errno != ENOENT && errno != ENXIO)
28 fido_log_error(errno, "%s: open %s", __func__, path);
32 if (fstat(fd, &st) == -1) {
33 fido_log_error(errno, "%s: fstat %s", __func__, path);
35 fido_log_error(errno, "%s: close", __func__);
39 if (S_ISCHR(st.st_mode) == 0) {
40 fido_log_debug("%s: S_ISCHR %s", __func__, path);
42 fido_log_error(errno, "%s: close", __func__);
50 fido_hid_unix_wait(int fd, int ms, const fido_sigset_t *sigmask)
56 memset(&pfd, 0, sizeof(pfd));
65 ts.tv_sec = ms / 1000;
66 ts.tv_nsec = (ms % 1000) * 1000000;
69 if ((r = ppoll(&pfd, 1, ms > -1 ? &ts : NULL, sigmask)) < 1) {
71 fido_log_error(errno, "%s: ppoll", __func__);