LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2008, 06:06 AM   #1
bodhankaryogesh
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
Read Directory Entries ?


Hi,

I have read the directory entries.
readdir(3) is used for it.
Now, I am jumping to next record by just adding (dirent+d_reclen).
d_reclen is multiple of 8 bytes.

The Problem is "Some records are being skipped."
e.g.
dirent{
d_ino = 100884
d_off = 17100
d_reclen = 112
d_nnames = 1
dirname {
dn_reclen = 72
dn_namlen = 19
dn_name = tc-cbq-details.8.gz
}
}
dirent {
d_ino = 100873
d_off = 17128
d_reclen = 96
d_nnames = 1
dirname {
dn_reclen = 56
dn_namlen = 13
dn_name = auditctl.8.gz
}
}
dirent {
d_ino = 102032
d_off = 17152
d_reclen = 96
d_nnames = 1
vfm_dirname_t {
dn_reclen = 56
dn_namlen = 12
dn_name = MAKEDEV.8.gz
}
}


There is no connection between record's offset and my calculation(dirent+d_reclen). i.e. 17100 + 112 != 17128 Therefore some records(files) are being skipped.
I only know the directory ! From that I need to get hte records !

Does Directory has discontiguous allocation?
How do I can read it ?
 
Old 04-03-2008, 12:28 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
From man 3 readdir
Code:
         struct dirent {
             ino_t          d_ino;       /* inode number */
             off_t          d_off;       /* offset to the next dirent */
             unsigned short d_reclen;    /* length of this record */
             unsigned char  d_type;      /* type of file */
             char           d_name[256]; /* filename */
         };
This does not seem to match your dirent.

Further it might help if you post some code (and please use code tags).

By the way, there is a dedicated programming section where you might have more luck with this question. I will report your post so a moderator can move it.
 
Old 04-03-2008, 03:01 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



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
anon svn read-only over apache: '.svn/entries': No such file hedpe Linux - Software 2 04-29-2009 05:31 AM
In Linux, How to read and modify Kernel IP routing table entries from a c program sakthivelbatusai Linux - Networking 1 03-29-2007 06:36 AM
LXer: Free Software Directory Nears 5000 Entries LXer Syndicated Linux News 0 08-23-2006 12:54 PM
mtime/ctime changed on directory entries stardot Linux - Security 2 11-29-2004 10:44 PM
Maximum Number of Directory Entries & Performance aig Linux - General 1 07-09-2004 07:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:55 PM.

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