Results 1 to 5 of 5
Greetings,
i am newbie to linux programming..i want to find the sizeof directory with C program..i used stat()system call and got the size of directory...but the problem is if I ...
- 04-06-2007 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 23
finding directory size
Greetings,
i am newbie to linux programming..i want to find the sizeof directory with C program..i used stat()system call and got the size of directory...but the problem is if I create some files or deleted some files in that directory its still showing the same size.....there is no increasing or decrease in the directory size...
please help me with tips to find the real size of the directory
Thanks in advance...
- 04-06-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
I don't know how your code looks like.
It might be helpfull for others to understand the complete context of your situation if you post some snippet of your code but in the meantime, try to call stat() again.
Regards
- 04-06-2007 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
In most *nix systems, directories are allocated in blocks. That saves time. When you add or delete a file, the names just take up an empty slot, or a slot is cleared. You can see this by listing the directory before and after an operation.
If the time comes when the block is full, another is allocated, and the first slot in the new block will be filled, the rest waiting for another new item. As far as I know, directory sizes are never decreased.
If this has changed in recent systems, a pointer to the documentation would helpful from someone who knows ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 04-10-2007 #4
Hi,
I'll agree with drl...
what's the size it says?
if it's says 1024 or 2048 or 4096 or 8192 - (same as block size)
i'm 100% sure the directory size remains same..
to count no.of files in a directory i hope following link will help you.
here
Thank.
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 04-10-2007 #5
nice one man....i would say 99% can be sloved by man pages
Originally Posted by drl
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------


Reply With Quote