?
Solved

how to change last modification time of a symlink

Posted on 2001-09-09
6
Medium Priority
?
578 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6468913
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
ID: 6470598
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
ID: 6470841
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Accepted Solution

by:
chris_calabrese earned 400 total points
ID: 6472176
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 21

Expert Comment

by:tfewster
ID: 8191635
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
ID: 8241253
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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