File creation time
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > File creation time




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    File creation time  
Generic Usenet Account


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-29-07 12:23 AM

Hi,

As per my man pages, the stat structure contains the following fields:
struct stat {
dev_t         st_dev;      /* device */
ino_t         st_ino;      /* inode */
mode_t        st_mode;     /* protection */
nlink_t       st_nlink;    /* number of hard links
*/
uid_t         st_uid;      /* user ID of owner */
gid_t         st_gid;      /* group ID of owner */
dev_t         st_rdev;     /* device type (if inode
device) */
off_t         st_size;     /* total size, in bytes
*/
blksize_t     st_blksize;  /* blocksize for
filesystem I/O */
blkcnt_t      st_blocks;   /* number of blocks
allocated */
time_t        st_atime;    /* time of last access */
time_t        st_mtime;    /* time of last
modification */
time_t        st_ctime;    /* time of last change */
};

I am interested in the file creation time.  What field should I use?
Should I go with some other system call?  Also, what is the difference
between the time of last modification and the time of last change?

Thanks,
Gus





[ Post a follow-up to this message ]



    Re: File creation time  
fjblurt@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-29-07 12:23 AM

On Dec 28, 4:21 pm, Generic Usenet Account <use...@sta.samsung.com>
wrote:
> Hi,
>
> As per my man pages, the stat structure contains the following fields:
>               struct stat {
>                   dev_t         st_dev;      /* device */
>                   ino_t         st_ino;      /* inode */
>                   mode_t        st_mode;     /* protection */
>                   nlink_t       st_nlink;    /* number of hard links
> */
>                   uid_t         st_uid;      /* user ID of owner */
>                   gid_t         st_gid;      /* group ID of owner */
>                   dev_t         st_rdev;     /* device type (if inode
> device) */
>                   off_t         st_size;     /* total size, in bytes
> */
>                   blksize_t     st_blksize;  /* blocksize for
> filesystem I/O */
>                   blkcnt_t      st_blocks;   /* number of blocks
> allocated */
>                   time_t        st_atime;    /* time of last access */
>                   time_t        st_mtime;    /* time of last
> modification */
>                   time_t        st_ctime;    /* time of last change */
>               };
>
> I am interested in the file creation time.  What field should I use?

None of these tell you the file creation time.  That information is
only kept for a few filesystems.  For example, ufs2 on FreeBSD fills
in an st_birthtime field.  But in general it's not available via
stat(2) or any other system call.

> Should I go with some other system call?  Also, what is the difference
> between the time of last modification and the time of last change?

The FreeBSD man page describes them as follows:

st_atime      Time when file data last accessed.  Changed by the
mknod(2), utimes(2), read(2) and readv(2) system
calls.

st_mtime      Time when file data last modified.  Changed by the
mkdir(2), mkfifo(2), mknod(2), utimes(2), write(2)
and
writev(2) system calls.

st_ctime      Time when file status was last changed (inode data
modifi-
cation).  Changed by the chflags(2), chmod(2),
chown(2),
creat(2), link(2), mkdir(2), mkfifo(2), mknod(2),
rename(2), rmdir(2), symlink(2), truncate(2),
unlink(2),
utimes(2), write(2) and writev(2) system calls.

st_birthtime  Time when the inode was created.

Hope this helps.





[ Post a follow-up to this message ]



    Re: File creation time  
Gordon Burditt


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-01-08 12:23 AM

>              struct stat {
...
>                  time_t        st_atime;    /* time of last access */
>                  time_t        st_mtime;    /* time of last
>modification */
>                  time_t        st_ctime;    /* time of last change */
>
>I am interested in the file creation time.

There is no file creation time here.  I don't even think there is a
coherent definition of "file creation time".  For example, should the
shell command:
echo foo > file
update the so-called "creation time" if file "file" existed before
running this command?

>What field should I use?

st_mtime is probably pretty close for files which are written once
and not modified later.  For write-frequently database files, you're
out of luck.

>Should I go with some other system call?

What makes you think a file creation time is stored anywhere?

>Also, what is the difference
>between the time of last modification and the time of last change?

Operations such as chown and chmod change st_ctime but not st_mtime.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:57 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register