LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-21-2015, 01:54 PM   #1
dlevy022
LQ Newbie
 
Registered: Nov 2015
Posts: 10

Rep: Reputation: Disabled
Does the qstr struct in a kernel dentry hold the filename of a Linux file?


Below is a snippet of the Linux dentry struct from http://lxr.free-electrons.com/source.../dcache.h#L150. The struct contains a member struct qstr d_name - definition below. I would like to know if this is the name of the particular file that would correspond to this dentry at runtime. What confuses me is that proc/PID/maps uses struct dentry_operations -> d_name (another member of dentry) to generate the file name...so then waht is the purpose of struct qstr d_name? Please note, I am approaching this from a pure memory introspection point of view (libvmi) and thus I will be "walking memory" for these structures and retrieval using C/C++ code is not so straightforward.

struct dentry {

/* RCU lookup touched fields */
unsigned int d_flags; /* protected by d_lock */
seqcount_t d_seq; /* per dentry seqlock */
struct hlist_bl_node d_hash; /* lookup hash list */
struct dentry *d_parent; /* parent directory */
struct qstr d_name;

....

struct qstr {
union {
struct {
HASH_LEN_DECLARE;
};
u64 hash_len;
};
const unsigned char *name;
};
 
Old 12-24-2015, 07:54 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Perhaps I do not fully understand your question. It would superficially appear that this is a structure which contains a pointer to a file-name while also containing or being a part of a hash-table.

Generally speaking, the best thing to do is to download the kernel source packages, go into that directory with the command line, and use "grep -rlw qstr ." to find the names of all files which contain the case-sensitive isolated "word," qstr. These are likely to be all the source files which refer to this structure. Examine each of them to see how the structure is used.

That's an "old school" approach and there might be a more "webby" way to do it nowadays, but it works.

Last edited by sundialsvcs; 12-24-2015 at 07:55 AM.
 
  


Reply

Tags
file operators, kernel headers, memory



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 to find the complete file path using struct file in linux kernel modules prabhurajreddy Linux - Kernel 2 04-17-2014 01:45 PM
Some questions about struct dentry involved with list ao.yuan.young Linux - Kernel 1 05-31-2009 08:08 PM
Some questions about struct dentry involved with list ao.yuan.young Linux - Kernel 1 05-31-2009 02:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:27 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
Open Source Consulting | Domain Registration