Operating System - HP-UX
1837979 Members
2909 Online
110124 Solutions
New Discussion

Re: is it possible to set/restore the timestamp of a soft link ?

 
SOLVED
Go to solution
Jdamian
Respected Contributor

is it possible to set/restore the timestamp of a soft link ?

Hi.

I'm interested in copying some soft links from a directory/system to another directory/system. But their timestamp are modified as time they are created, not the original soft links.

For instance, LA is a soft link to file A. LA timestamp is 1 Jan 2002. A timestamp is 31 Dec 2002.

I run tar command to archive and restore in other system/location. But timestamp of LA in new location is not 1 Jan 2002, but the actual date.

I also tried using HP OmniBack-II but I obtained the same results.

is it possible to set/restore the timestamp of a soft link ?

Thanx in advance
3 REPLIES 3
Dietmar Konermann
Honored Contributor
Solution

Re: is it possible to set/restore the timestamp of a soft link ?

New symbolic links are always created with the current time as timestamp. Looks like the only way to change that could be the utime(2) syscall... however, that syscall always follows symbolic links.

...
u.u_error = namesetattr(uap->fname, FOLLOW_LINK, &vattr,
uap->tptr == NULL);
...

So I'm afraid, the answer is no.

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Sanjay Kumar Suri
Honored Contributor

Re: is it possible to set/restore the timestamp of a soft link ?

Seems to be difficult. As in case of tar the soft link is created afresh as the following message displayed during a sample tar -xvf proves

x file13 symbolic link to file12

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Muthukumar_5
Honored Contributor

Re: is it possible to set/restore the timestamp of a soft link ?

hai,

Link file access,modification,.. informations are stored in the file stat structure. stat() will modify the access informations of a link file.

Normal files will be with the same time stamp. tar will archieve the link files with the same time stamp. During the extraction,link will try to access the source file. That access time will be modified in the file status structure by the stat() call.

Timestamp is changed,because the link file is trying to access the source file at that time to renew the link on the new location.

see stat.2 man page more.

Regards,
Muthukumar.
Easy to suggest when don't know about the problem!