LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to determine name of file which owns a block number on a FS? (https://www.linuxquestions.org/questions/linux-software-2/how-to-determine-name-of-file-which-owns-a-block-number-on-a-fs-803940/)

10110111 04-24-2010 09:23 AM

How to determine name of file which owns a block number on a FS?
 
I need to monitor file reads&writes by all the apps. I have found a kernel feature /proc/sys/vm/block_dump. But it only gives me block numbers while i would like to know file names. How can i convert these block numbers to file names (if the blocks belong to a file, of course)?

unSpawn 04-25-2010 04:03 AM

Quote:

Originally Posted by 10110111 (Post 3946311)
How can i convert these block numbers to file names (if the blocks belong to a file, of course)?

Code:

# asserting ext file-system:
# for b_block
BLOCKNR="4000001"
# the inode is
INODE=$(echo "icheck ${BLOCKNR}"|debugfs /dev/devicename 2>/dev/null| awk '/^[0-9]/ {print $2}')
# which translates to file
FILENAME=$(find /mountpoint -inum "${INODE}" 2>/dev/null)


Quote:

Originally Posted by 10110111 (Post 3946311)
I need to monitor file reads&writes by all the apps.

Using the above kludge is WAY SLOW. To be able to suggest possible other methods please tell us: why do you need to track all reads and writes? And why for all applications?

10110111 04-26-2010 09:30 AM

Quote:

why do you need to track all reads and writes? And why for all applications?
I'm trying to understand why my desktop starts so slow. As i see, all the time hard drive is busy while startup. So, i decided to look what files access needs to be optimised.
strace will not suffice for this (and it would be even more hard to convert file handles in read()/write() to file names).

unSpawn 04-27-2010 02:27 AM

Why not try ready-made tools like http://www.bootchart.org/ first?


All times are GMT -5. The time now is 06:42 AM.