LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-15-2011, 09:53 PM   #1
whossa
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Rep: Reputation: Disabled
rename and ctime


Can any big guru explain why rename operation could affect the ctime of a file(affect the mtime/ctime of its parent directory is reasonable, you could see inode structure from here Much thanks
 
Old 11-16-2011, 12:51 AM   #2
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 158

Rep: Reputation: 44
Because rename is making a new hardlink to the file, then deleting the old hardlink.
This is how any move of a file happens within a UNIX filesystem, whether it is to the same directory or not.

The action causes a change in the 'link count', which is used by the system when the last link has been closed such that the file can be removed. However this is stored in the 'inode' of the file, thus the inode is changed and you get a 'change time' modification.

Note that this will effect the mtime of the directories involve but not their ctime as the inode data for the directory does not change.
 
Old 11-16-2011, 07:55 AM   #3
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Where are you usng it? on which server?
it does not affect the mtime. The modified time is the creating time of file.
I have tried it on line linux server.
 
Old 11-16-2011, 08:10 PM   #4
whossa
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for you reply

To A.Thyssen
Thanks A.Thyssen, your reply is quite helpful, i forget about the link, right! But also, I've noticed that the mtime of parent directory as the filename changed because the filename belongs one part of the parent directory's content. I'm using Linux Fedora 10

To pavi_kanetkar
Thanks for the reply, but here the mtime I've mentioned is that of parent directory, certainly the mtime of file itself doesn't change as the filename doesn't belongs to the file content
 
Old 11-16-2011, 08:54 PM   #5
whossa
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for you reply

To A.Thyssen
Thanks A.Thyssen, your reply is quite helpful, i forget about the link, right! But also, I've noticed that the ctime of parent directory changed as the filename changed, why? this should be an implement specific behavior!

To pavi_kanetkar
Thanks for the reply, but here the mtime I've mentioned is that of parent directory, certainly the mtime of file itself doesn't change as the filename doesn't belongs to the file content

So here we could conclude that once a filename got changed
file parent dir
mtime N Y
ctime Y Y(why?)

file ctime changed due to hardlink counts changed, while file name doesn't belong to its content, mtime doesn't change
parent directory mtime changed due to the file name belongs to parent content, and as inode doesn't changed, the ctime of parent dir shouldn't have got changed, yet, it changed indeed! Why? I'm using mv command in Solaris10 x86, and the inode of file doesn't change
ls -l --show mtime
ls -lc --show ctime
ls -lu --show atime
ls -inum --show inode

Last edited by whossa; 11-16-2011 at 09:03 PM.
 
Old 11-16-2011, 11:51 PM   #6
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 158

Rep: Reputation: 44
Quote:
Originally Posted by whossa View Post
To A.Thyssen
Thanks A.Thyssen, your reply is quite helpful, i forget about the link, right! But also, I've noticed that the ctime of parent directory changed as the filename changed, why? this should be an implement specific behavior!
Any time a file content changes, ctime also changes. The c-time is change of inode, which hold link count, file size, file data links, etc, etc.

The directory content changed so both mtime and ctime change, and possibly file size too.
mtime remember is only file content. ctime is meta-data change.
 
1 members found this post helpful.
Old 11-17-2011, 01:52 AM   #7
whossa
LQ Newbie
 
Registered: Nov 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks

Quote:
Originally Posted by A.Thyssen View Post
Any time a file content changes, ctime also changes. The c-time is change of inode, which hold link count, file size, file data links, etc, etc.

The directory content changed so both mtime and ctime change, and possibly file size too.
mtime remember is only file content. ctime is meta-data change.
Thanks for the explanation!
 
  


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
ctime() on ut_tv.tv_sec of utmp structure? hppyhjh Programming 8 08-02-2010 12:50 PM
How to use ctime(time.h) tnjones Programming 3 09-22-2008 08:29 PM
Printf and ctime question about output when used together. shadow5277 Programming 2 06-22-2007 02:46 AM
ctime of /etc/samba/smbpasswd different ddaas Linux - Security 0 07-04-2005 01:42 AM
Weired ctime() asctime() output azi Programming 1 07-01-2004 04:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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