Beispiel #1
0
static void trace_file(const char *path, int fd) {
    debug("trace_file %s %d", path, fd);

    Descriptor *f = get_descriptor(fd);
    if (f == NULL) {
        return;
    }

    if (!should_trace(path)) {
        return;
    }

    struct stat s;
    if (fstat(fd, &s) != 0) {
        printerr("fstat: %s\n", strerror(errno));
        return;
    }

    /* Skip directories */
    if (s.st_mode & S_IFDIR) {
        return;
    }

    char *temp = strdup(path);
    if (temp == NULL) {
        printerr("strdup: %s\n", strerror(errno));
        return;
    }

    f->type = DTYPE_FILE;
    f->path = temp;
    f->bread = 0;
    f->bwrite = 0;
    f->nread = 0;
    f->nwrite = 0;
    f->bseek = 0;
    f->nseek = 0;
}
Beispiel #2
0
			void trace(const std::string &module, const char* file, const int line, const std::string &message) {
				if (should_trace())
					do_log(log_message_factory::create_trace(module, file, line, message));
			}