コード例 #1
0
/*
 * Loads the address of the returned object into a list of "locators"
 * associated to the name of the file which is opened and then
 * executes the original fopen.
 */
FILE * fopen(const char * filename, const char * mode)
{
	// original fopen function
	FILE * (*original_fopen) (const char *, const char *) = NULL;

	// execute the previous function
    original_fopen = dlsym(RTLD_NEXT, "fopen");

    // call the original fopen with the same arugments
    FILE* f = original_fopen(filename, mode);

    // ---------------------------
	// saves the location of the file just open
    loadFile(filename, (long)f);
	// ---------------------------

	// return the result
    return f;
}
コード例 #2
0
ファイル: rmonitor_helper.c プロジェクト: brenden/cctools
FILE *fopen(const char *path, const char *mode)
{
	FILE *file;
	typeof(fopen) *original_fopen = dlsym(RTLD_NEXT, "fopen");

	debug(D_DEBUG, "fopen from %d.\n", getpid());
	file = original_fopen(path, mode);

	if(file)
	{
		struct monitor_msg msg;

		msg.type   = OPEN;
		msg.origin = getpid();
		strcpy(msg.data.s, path);

		send_monitor_msg(&msg);
	}

	return file;
}