LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-16-2009, 09:51 AM   #1
HeartBeat
LQ Newbie
 
Registered: May 2009
Posts: 5

Rep: Reputation: 0
Finding Directroy size using system call


All,

My application needs to find out a directory size. As running system command du may slow down the performance of my application I dont want to use it. But I am interested in using the system call which may return the directory size.

I went through the man page of system calls such as statfs and stat but they are not say anything about the size of the directory. Probably they may be used for finding out the file size in a directory.
Please suggest me on how to get the size of a directory.

Regrads,
HeartBeat
 
Old 06-16-2009, 09:57 AM   #2
BeacoN
Member
 
Registered: Nov 2008
Distribution: Linux Mint
Posts: 56

Rep: Reputation: 17
what exact command do you run that slows it down?

whenever I want to find the size of a directory I use

du -sch *directory*

normally I just put a * in there to get all the files and dirs in the folder-doesn't seem to be slow at all. But like I did above you can ask just for one file, that would be faster.

I don't believe the ext3 filesystem (I may be wrong) keeps directory size with the inode information in the file-hence you can't just read a part of the disk in the file to get the directory size. I believe the system has to poll and find all the files in it and add it up before it tells you. It does this very fast, you won't even notice a lag unless there double digit gigs in the directory.
 
Old 06-17-2009, 05:04 AM   #3
HeartBeat
LQ Newbie
 
Registered: May 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Many thanks to BeacoN,

I am interested in using the system call instead the system commands which would print the directory size on the console.

As you said ext3 inode doesn't keep the directory size. So to find out the directory size we just need to sum up all the files size with in that directory. Please correct me if am wrong.

Thanks,
HeartBeat
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
OSE system call functions to Linux Sytem Call functions required roshantraj30 Linux - General 0 06-08-2009 03:06 AM
How to call system call from usb driver's code Mr.J Linux - Kernel 4 09-29-2008 04:47 AM
How can i make centos 4.5's system call using vDSO(call *%gs:0x10) instead of int80 tclwp Red Hat 3 08-06-2007 01:07 AM
size of call stack? vkmgeek Programming 11 11-06-2006 10:42 AM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 05:21 PM


All times are GMT -5. The time now is 02:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration