Projects STRLCPY criu Commits c83a0aae
🤬
  • proc: parse clock symbolic names in /proc/pid/timens_offsets

    Clock IDs in this file has been replaced by clock symbolic names.
    
    Now it looks like this:
        $ cat /proc/774/timens_offsets
        monotonic      864000         0
        boottime      1728000         0
    
    Signed-off-by: Andrei Vagin <[email protected]>
  • Loading...
  • Andrei Vagin committed 4 years ago
    c83a0aae
    1 parent 7dc89376
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    criu/proc_parse.c
    skipped 1483 lines
    1484 1484   }
    1485 1485   while (fgets(buf, BUF_SIZE, f)) {
    1486 1486   int64_t sec, nsec;
    1487  - int clockid;
     1487 + char clockid[10];
    1488 1488   
    1489  - if (sscanf(buf, "%d %"PRId64" %"PRId64"\n", &clockid, &sec, &nsec) != 3) {
     1489 + if (sscanf(buf, "%9s %"PRId64" %"PRId64"\n", clockid, &sec, &nsec) != 3) {
    1490 1490   pr_err("Unable to parse: %s\n", buf);
    1491 1491   goto out;
    1492 1492   }
    1493  - switch (clockid) {
    1494  - case CLOCK_MONOTONIC:
     1493 + clockid[sizeof(clockid) - 1] = 0;
     1494 + if (strcmp(clockid, "monotonic") == 0 ||
     1495 + strcmp(clockid, __stringify(CLOCK_MONOTONIC)) == 0) {
    1495 1496   moff->tv_sec = sec;
    1496 1497   moff->tv_nsec = nsec;
    1497  - break;
    1498  - case CLOCK_BOOTTIME:
     1498 + continue;
     1499 + }
     1500 + if (strcmp(clockid, "boottime") == 0 ||
     1501 + strcmp(clockid, __stringify(CLOCK_BOOTTIME)) == 0) {
    1499 1502   boff->tv_sec = sec;
    1500 1503   boff->tv_nsec = nsec;
    1501  - break;
    1502  - default:
    1503  - pr_err("Unknown clockid: %d\n", clockid);
    1504  - goto out;
     1504 + continue;
    1505 1505   }
     1506 + pr_err("Unknown clockid: %s\n", clockid);
     1507 + goto out;
    1506 1508   }
    1507 1509   exit_code = 0;
    1508 1510  out:
    skipped 1225 lines
  • ■ ■ ■ ■ ■ ■
    criu/timens.c
    skipped 91 lines
    92 92   ts.tv_nsec = te->monotonic->tv_nsec - ts.tv_nsec;
    93 93   normalize_timespec(&ts);
    94 94   
    95  - pr_debug("timens: %d %ld %ld\n",
    96  - CLOCK_MONOTONIC, ts.tv_sec, ts.tv_nsec);
     95 + pr_debug("timens: monotonic %ld %ld\n", ts.tv_sec, ts.tv_nsec);
    97 96   if (dprintf(fd, "%d %ld %ld\n",
    98 97   CLOCK_MONOTONIC, ts.tv_sec, ts.tv_nsec) < 0) {
    99 98   pr_perror("Unable to set a monotonic clock offset");
    skipped 9 lines
    109 108   ts.tv_nsec = te->boottime->tv_nsec - ts.tv_nsec;
    110 109   normalize_timespec(&ts);
    111 110   
    112  - pr_debug("timens: %d %ld %ld\n",
    113  - CLOCK_BOOTTIME, ts.tv_sec, ts.tv_nsec);
     111 + pr_debug("timens: boottime %ld %ld\n", ts.tv_sec, ts.tv_nsec);
    114 112   if (dprintf(fd, "%d %ld %ld\n",
    115 113   CLOCK_BOOTTIME, ts.tv_sec, ts.tv_nsec) < 0) {
    116 114   pr_perror("Unable to set a boottime clock offset");
    skipped 22 lines
Please wait...
Page is in error, reload to recover