File: logfsync.cpp

package info (click to toggle)
dlt-daemon 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,296 kB
  • sloc: ansic: 58,041; cpp: 16,199; sh: 1,769; xml: 1,440; python: 376; makefile: 31
file content (16 lines) | stat: -rw-r--r-- 426 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>

typedef int (*orig_fsync_t)(int);

extern "C" int fsync(int fd)
{
    static orig_fsync_t orig_fsync = (orig_fsync_t)dlsym(RTLD_NEXT, "fsync");

    // Could also track fd-name mappings by wrapping open/close
    // Maybe also print current filesize to know exactly when the sync occured
    fprintf(stderr, "%s: fd=%d\n", __func__, fd);

    return orig_fsync(fd);
}