LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-15-2018, 10:43 PM   #1
ekstrah
LQ Newbie
 
Registered: Nov 2018
Posts: 6

Rep: Reputation: Disabled
how to count how many times does .so been used


I have created/wrote ld.so.preload and fopen.so to see which applications/processes are using fopen library. However, i want to count how many processors have used fopen function during the boot. I have tried using environment variable and echoing out to the file and both didn't work out.

Here is my fopen.so code
#define _GNU_SOURCE


#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <stdlib.h>

FILE *fopen(const char *path, const char *mode) {
//system("echo "hi\n" >> /home/parallels/Desktop/hi.txt");
FILE *(*original_fopen)(const char*, const char*);
original_fopen = dlsym(RTLD_NEXT, "fopen");
return (*original_fopen)(path, mode);
}

******

Thank you
 
Old 11-17-2018, 08:32 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,951

Rep: Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146Reputation: 2146
I have n idea how to do what you're wanting to, but I know that code looks really screwed up.
this is your function call
Code:
FILE *fopen(const char *path, const char *mode) 
{

//system("echo "hi\n" >> /home/parallels/Desktop/hi.txt");

FILE *(*original_fopen)(const char*, const char*);

original_fopen = dlsym(RTLD_NEXT, "fopen");

return (*original_fopen)(path, mode);
}
first off what is FILE for?

what does it do?

So how can you expect it to do everything you are telling it to do within that function all, if anything at all?

You might have to take one more step back and use code that it written for FILE and fopen to get what you want done, done.

Last edited by BW-userx; 11-17-2018 at 08:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How would I see how many times a file has been written to? anon02 Linux - Software 6 09-23-2011 01:34 AM
Been here so many times, just reg, Kewl, my first box in 84 ran CPM !!! MotherDawg LinuxQuestions.org Member Intro 0 08-06-2010 08:10 PM
How to tell how many times a dvd rw disc has been written to? Mountain Man Linux - General 9 09-18-2009 03:01 AM
how to show how many times a pic have been viewed or clicked on? tzouse Programming 6 10-09-2008 07:34 AM
module.ko: make, install & used many times. Suddenly modprobe=invalid module format?? GrapefruiTgirl Linux - General 16 08-04-2007 05:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration