English 中文(简体)
如何辨别一个特定进程是否打开了 O_Direct 的文件?
原标题:How to tell if a given process opened files with O_DIRECT?

我想告诉您一个程序是否已经打开了使用 O_Direct 的任何文件, 但我只能检查它是否“ 坚固” / 坚固( 也就是说, Strace 不是一个选项 ) 。 我试图在 / proc/$pid/ fd/ 中查看是否有有用的文件, 但是没有。 我的目标是追踪一个系统中的几百个用户中是否有人已经与 O_ Direct 打开了文件。 这是否可行?

最佳回答

由于内核2.6.22, /proc/$pid/fdinfo/$fd 含有一个国旗字段,以八进制。见http://www.kernel.org/doc/man-pages/online/pages/man5/proc.5.html

问题回答

我不认为它在/proc 或用户空间其他地方可见。

With kernel code, it s possible:
1. Get the process s task_struct (use find_task_by_pid).
2. Go over files - use task->files->count and task->files->fd_array. 3. Look for file->f_flags & O_DIRECT.





相关问题
Can POSIX message queues be used cross user on Linux?

I have implemented a POSIX message queue. On the listener side, I am opening the queue like this: mqdes = mq_open(s_mailbox_name.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO, NULL); On ...

eregi_replace problem!

now i have an eregi_replace Problem: I have this $subject = "This is for @codeworxx - you have to try first!"; $text = eregi_replace( (((@))[-a-zA-Z0-9]+) , <a href="http://www.google.de/\1">...

What is the meaning of "POSIX"?

What is POSIX? I have read the Wikipedia article and I read it every time I encounter the term. The fact is that I never really understood what it is. Can anyone please explain it to me by explaining ...

How do I check if a thread is terminated when using pthread?

How do I check if a thread is terminated? In my case, I have my_pthread[5] and I want to check if any of 5 threads has finished its job (is terminated? - I m not sure) then I can give them more work ...

How do you get the terminal size in Go?

How do I get the terminal size in Go. In C it would look like this: struct ttysize ts; ioctl(0, TIOCGWINSZ, &ts); But how to i access TIOCGWINSZ in Go

热门标签