Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-04-2007, 11:56 AM   #1
Registered: Aug 2006
Location: Allahabad,India
Distribution: Fedora Core 5
Posts: 41

Rep: Reputation: 15
how is stat() implemented?

hi all,
i was just having a look at this stat() sys call n i have got some doubts in its implentation on my system . i use fedora-5 with 2.6.20 as my kernel n my gcc is 4.1

1) I just printed the "st_mtime" field as an inetger for "/" n i got 1183536218 i then created a new file n its field provided me "1183540753", a difference of 4535s ( assuming the time is in seconds ). Now as i am working on this OS
for more than an year,i thought time for "/" mightn't be the time when it was
created,since if it is , "file" is a newly created one n this difference should
have been much more than 4535s,my system was up for just more than an hour n the figure 4535s goes with this so thought all inodes will be updated every reboot with reference to a fixed time,
This time i printed the same field for my "/home" (as a integer) and i got 1182615460 , to my surprise this was much ahead than "/" time around 10 days earlier , here i got struck up unable to justify my earlier stand. could anyone help me plzz..

2) Here is a similar problem with "st_mode" field i.e the permission field two
outputs in octal format for this field are as follows:
                /      : 40755
                /home  : 40755
                file   : 100664
the last four digits go with the owner's umask but what does that "4" and "10"
( for "file") indicate ??

3) Here is a output of "ls -ld" for various directories :
        $ ls -ld / ~vijay /mnt /sbin
         drwxr-xr-x 32 root  root   4096 Jul  4 13:33 /
         drwx------ 68 vijay vijay 12288 Jul  4 15:50 /home/vijay
         drwxrwxrwx  2 root  root   4096 Jun 17 21:07 /mnt
         drwxr-xr-x  2 root  root  12288 Jun 29 03:09 /sbin
why does the 5th field i.e size in bytes field a multiple of
4096 ? I learnt that directory is a file with names n inode numbers
listed but does this have any relation with that ??

4) Do anybody have the idea of what is there in the structure "FILE" which we use for file access in C ??

thanks for ur replies,
Old 07-04-2007, 12:42 PM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680
              time_t    st_atime   Time of last access.
              time_t    st_mtime   Time of last data modification.
              time_t    st_ctime   Time of last status change.
From the "man p stat.h" man page.
There isn't an entry for creation time. If you change the permissions on a file or directory, the ctime will change. To the kernel, a directory is just a file. When you add or remove or rename files in the directory, the kernel edits this (special) file and the mtime and ctime change as a result.

If you rename a file leaving it in the same directory, the ctime changes. The ctime and mtime on the containing directory both change. If you move it to the parent directory for example, again the ctime changes. The ctime and mtime of the original directory and the parent directory change.

The (/) root directory may be different in some ways. There is no parent directory, and it's charactoristics may be determined by the mount command when it is mounted. The /home directory may also be different. The permissions are stored with the filesystem. The directory special file is changed by the mount command when it is mounted. I think it may get the information from the superblock to rewrite the directory after the filesystem is mounted.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
QM_MODULES function not implemented kamran_pro Linux - General 2 03-27-2006 07:11 AM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 04:07 PM
Kernel 2.6.3 QM_MODULES not implemented rajan_kanwar Linux - Software 1 04-28-2004 10:11 AM
2.6.3 swapon - function not implemented Sammy2ooo Linux - General 3 03-10-2004 07:08 AM
How this can be implemented? JIV Linux - Networking 2 11-13-2003 11:00 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration