This might help to identify bugs/misbehaving systems
or attempts to mess with timestamp files.
if (n < 0 || n >= (int)sizeof path)
return -1;
if (n < 0 || n >= (int)sizeof path)
return -1;
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY)) == -1) {
+ warn("failed to open: %s", path);
while ((n = read(fd, p, buf + sizeof buf - p)) != 0) {
if (n == -1) {
if (errno == EAGAIN || errno == EINTR)
continue;
while ((n = read(fd, p, buf + sizeof buf - p)) != 0) {
if (n == -1) {
if (errno == EAGAIN || errno == EINTR)
continue;
+ warn("read: %s", path);
close(fd);
/* error if it contains NULL bytes */
close(fd);
/* error if it contains NULL bytes */
- if (n != 0 || memchr(buf, '\0', p - buf))
+ if (n != 0 || memchr(buf, '\0', p - buf)) {
+ warn("NUL in: %s", path);
return -1;
/* Get the 7th field, 5 fields after the last ')',
return -1;
/* Get the 7th field, 5 fields after the last ')',
struct stat st;
if (fstat(fd, &st) == -1)
struct stat st;
if (fstat(fd, &st) == -1)
- if (!timespecisset(&st.st_atim) || !timespecisset(&st.st_mtim))
+ if (!timespecisset(&st.st_atim) || !timespecisset(&st.st_mtim)) {
+ warnx("timestamp atim or mtime not set");
if (clock_gettime(CLOCK_BOOTTIME, &ts[0]) == -1 ||
if (clock_gettime(CLOCK_BOOTTIME, &ts[0]) == -1 ||
- clock_gettime(CLOCK_REALTIME, &ts[1]) == -1)
+ clock_gettime(CLOCK_REALTIME, &ts[1]) == -1) {
+ warn("clock_gettime");
/* check if timestamp is too old */
if (timespeccmp(&st.st_atim, &ts[0], <) ||
/* check if timestamp is too old */
if (timespeccmp(&st.st_atim, &ts[0], <) ||
timespecadd(&ts[0], &timeout, &ts[0]);
timespecadd(&ts[1], &timeout, &ts[1]);
if (timespeccmp(&st.st_atim, &ts[0], >) ||
timespecadd(&ts[0], &timeout, &ts[0]);
timespecadd(&ts[1], &timeout, &ts[1]);
if (timespeccmp(&st.st_atim, &ts[0], >) ||
- timespeccmp(&st.st_mtim, &ts[1], >))
+ timespeccmp(&st.st_mtim, &ts[1], >)) {
+ warnx("timestamp too far in the future");
+ if (errno != ENOENT)
+ err(1, "open: %s", path);
+
n = snprintf(tmp, sizeof tmp, TIMESTAMP_DIR "/.tmp-%d", getpid());
if (n < 0 || n >= (int)sizeof tmp)
return -1;
n = snprintf(tmp, sizeof tmp, TIMESTAMP_DIR "/.tmp-%d", getpid());
if (n < 0 || n >= (int)sizeof tmp)
return -1;