Solved

how to change last modification time of a symlink

Posted on 2001-09-09
6
531 Views
Last Modified: 2013-12-26
I need to change last modification time of a symlink. I tried with 'utime' library call, but it follows symbolic link and change the inode.st_mtime field of the file the link is referring to.

Is there another call to change that field to the symlink itself?
If not, does anybody known a trick to do it?

I also read 'touch' man page. It does not have such a functionality.

thank you for your support.
0
Comment
Question by:mliberi
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
touch can do it, but only as user root (not shure for links, this probably also depends on the underlaying shell)
0
 
LVL 14

Expert Comment

by:chris_calabrese
Comment Utility
touch sits on top of utime, so if utime can't do it, then touch can't do it either.

What exactly is the problem you're trying to solve?  utime follows links because the folks who did links couldn't imagine a situation where anyone would care what the modification time of a link was.

The only way I know of to change the mod time of a link is to delete the link and recreate it.
0
 
LVL 3

Author Comment

by:mliberi
Comment Utility
I'm trying to restore a saved symlink. I use lchown to restore uid and gid and I would expect a system call or C library call exist to set last modification time too.

Removing and recreating the link is not a solution because it sets current time, not a generic timestamp. Change current time for the time necessary to do that operation is not an accepted solution.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 14

Accepted Solution

by:
chris_calabrese earned 100 total points
Comment Utility
Like I said, the creators of the sym-link stuff assumed that mod times for a link aren't important, so there's no way to do this.  You'd need an lutime or an futime, which don't exist.
0
 
LVL 20

Expert Comment

by:tfewster
Comment Utility
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by chris_calabrese

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Expert Comment

by:modulo
Comment Utility
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now