Changing Modification Time for a Symbolic Link

Changing Modification Time for a Symbolic Link

Post by Prasanna Parthasarath » Sun, 05 Nov 1995 04:00:00



Hi,

I recently came across a situation wherein an effort has to be made
to change the modification time  of the symbolic link (NOT the file
that it points to!) to a different time other than the current time.

utimes() / touch changes the file being pointed to ...

Any hints ? ?

Thanks

--

Prasanna

 
 
 

Changing Modification Time for a Symbolic Link

Post by Dana Frenc » Mon, 06 Nov 1995 04:00:00



>Hi,

>I recently came across a situation wherein an effort has to be made
>to change the modification time  of the symbolic link (NOT the file
>that it points to!) to a different time other than the current time.

>utimes() / touch changes the file being pointed to ...

The problem with what you are trying to do is that a symbolic link shares
an inode with the original link. and the inode contains the date
information.  In order to change the modification time of a link, the
link must have its own inode.  This translates into a "hard" link.

Sorry but you cannot change the modification time on a symbolic link
without changing the inode, which changes all links to that inode.

------------------------------------------------------------------------
Greatest Movie Quote of all time:

I love the smell of Napalm in the morning.  It smells like .... VICTORY!

------------------------------------------------------------------------

Applied Intelligence Group                    Phone: (405) 341-7700
501 East 15th Street, Suite 202                 Fax: (405) 341-8898
Edmond, OK  73013
------------------------------------------------------------------------

 
 
 

Changing Modification Time for a Symbolic Link

Post by Dana Frenc » Mon, 06 Nov 1995 04:00:00



>Hi,

>I recently came across a situation wherein an effort has to be made
>to change the modification time  of the symbolic link (NOT the file
>that it points to!) to a different time other than the current time.

>utimes() / touch changes the file being pointed to ...

The problem with what you are trying to do is that a symbolic link shares
an inode with the original link. and the inode contains the date
information.  In order to change the modification time of a link, the
link must have its own inode.  This translates into a "hard" link.

Sorry but you cannot change the modification time on a symbolic link
without changing the inode, which changes all links to that inode.

------------------------------------------------------------------------
Greatest Movie Quote of all time:

I love the smell of Napalm in the morning.  It smells like .... VICTORY!

------------------------------------------------------------------------

Applied Intelligence Group                    Phone: (405) 341-7700
501 East 15th Street, Suite 202                 Fax: (405) 341-8898
Edmond, OK  73013
------------------------------------------------------------------------

 
 
 

Changing Modification Time for a Symbolic Link

Post by Dana Frenc » Tue, 07 Nov 1995 04:00:00



>The problem with what you are trying to do is that a symbolic link shares
>an inode with the original link. and the inode contains the date
>information.  In order to change the modification time of a link, the
>link must have its own inode.  This translates into a "hard" link.

>Sorry but you cannot change the modification time on a symbolic link
>without changing the inode, which changes all links to that inode.

I must have been DRUNK when I wrote this!!!  Everything I said in the previous post,
should be exactly the opposite.

-------------------------------------------------------------------

Applied Intelligence Group                      Voice:  405-341-7700
501 East 15th Street, Suite 202                 FAX:    405-341-8898
Edmond, OK  73013

 
 
 

Changing Modification Time for a Symbolic Link

Post by Logan Sh » Thu, 09 Nov 1995 04:00:00




>>Hi,

>>I recently came across a situation wherein an effort has to be made
>>to change the modification time  of the symbolic link (NOT the file
>>that it points to!) to a different time other than the current time.

>>utimes() / touch changes the file being pointed to ...

>The problem with what you are trying to do is that a symbolic link shares
>an inode with the original link. and the inode contains the date
>information.  In order to change the modification time of a link, the
>link must have its own inode.  This translates into a "hard" link.

>Sorry but you cannot change the modification time on a symbolic link
>without changing the inode, which changes all links to that inode.

Actually, that's not true -- you've got the definition of symbolic link
and hard link confused.  In a hard link, the same inode is linked into
more than one directory on the filesystem.  In a symbolic link, a new
special file (with its own i-node of type S_IFLNK) is created, and that
special file gives a (partial or complete) pathname to another file,
which most system calls (except lstat()) automagically interpret as the
file linked to, not the link itself.

For example, witness the following sequence of commands, typed on
SunOS 4.1.3:

        $ cd /tmp
        $ date > foo
        $ ln -s foo bar
        $ ls -li
        total 6
         33809 lrwxrwxrwx  1 logan           3 Nov  7 20:25 bar -> foo
         33808 -rw-r--r--  1 logan          29 Nov  7 20:25 foo
        $ cat bar
        Tue Nov  7 20:25:02 PST 1995
        $ cat foo
        Tue Nov  7 20:25:02 PST 1995
        $ exit

Notice that "bar" and "foo" have separate i-node numbers.  (See the
first column in the output of "ls -li".)

Anyway, the reason you can't change stuff about the symbolic link is
that the functions which operate on the file automagically expand the
symbolic link into the file to which it refers before doing the
requested operation.  So, in the above example, if you want to set the
modification date of "bar", you do a 'utimes ("/tmp/bar", NULL)'.  The
utimes() call (or some other system thingy) translates the "/tmp/bar"
into (effectively) "/tmp/foo" and blithely does the operation on it.

In other words, what you need is an lutimes() call, just like there
is an lstat() call in addition to stat().

Incidentally, I think I remember coming across a Unix which behaves the
other way by default -- it changes the link's time rather than the file
linked to.  However, I don't remember which kind of Unix that was.

Hope this helps...

   - Logan
--
                   =-- do not send me any junk e-mail --=

 
 
 

Changing Modification Time for a Symbolic Link

Post by Randal L. Schwar » Fri, 10 Nov 1995 04:00:00


Bill> From looking at my home directory, apparently it's possible to have a
Bill> symbolic link to a file which doesn't even exist (I've got a .homepage,
Bill> but I haven't put anything in it yet).

Yes, in fact, I knew someone who was considering using that to
manage his to-do list:

        ln -s "take out the trash" 1 (priority 1)
        ln -s "feed the dog" 2 (priority 2)
        ls -l (shows the current listing)
        mv 1 3 (change priority)
        ls -l (new listing)
        rm 3 (been there, did that!)

Truly, truly, an abuse of the Unix filesystem.  But hey, cool!

Just another Unix hacker,
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

 
 
 

Changing Modification Time for a Symbolic Link

Post by David W. Tamk » Fri, 10 Nov 1995 04:00:00



| Yes, in fact, I knew someone who was considering using that to
| manage his to-do list:
|
|       ln -s "take out the trash" 1 (priority 1)
|       ln -s "feed the dog" 2 (priority 2)
|       ls -l (shows the current listing)
|       mv 1 3 (change priority)
|       ls -l (new listing)
|       rm 3 (been there, did that!)
|
| Truly, truly, an abuse of the Unix filesystem.  But hey, cool!

It works for only a maximum of nine tasks at a time, though, unless
you pipe ls -l to sort -n with the appropriate keyfield.

Well, ten tasks if you start numbering from zero.

 
 
 

Changing Modification Time for a Symbolic Link

Post by Joe Nardo » Fri, 10 Nov 1995 04:00:00





: >  ln -s "take out the trash" 1 (priority 1)
: >  ln -s "feed the dog" 2 (priority 2)
: >  ls -l (shows the current listing)
: >  mv 1 3 (change priority)
: >  ls -l (new listing)
: >  rm 3 (been there, did that!)
: >
: >Truly, truly, an abuse of the Unix filesystem.  But hey, cool!
:
: I don't get what your are trying to show here. What is the effect
: of "rm 3"? On my machine it simply removes the the link and the
: bogus file.

Exactly.

He's using symbolic links as a quick list.  By creating bogus links
to ascii text he'll see the text any time he does an ls -l, which
would be a pretty good reminder.  By rm'ing one of them, in all
likelihood he/she remembered to do that thing.

By numbering 1,2,3,... they'll show up in the ls listing in that order.

Joe

--

=---------------------------------------------------------------------------=

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQBtAzCg5QoAAAEDANvEmc4OAT8wntnCv8UPjyD2kohKVGa1CU21PLpYljzl3AE7
pldpNNscKSoE//aVMKYBO+tRFTTsPNi0qZ6CDlEBXTgJAiszoHh1qCzZyYj7FTBL
YoUr+3sk9rU8Pma6AQAFEbQiSm9lIE5hcmRvbmUgPGpvZUBhY2Nlc3MuZGlnZXgu
bmV0Pg==
=1ocE
-----END PGP PUBLIC KEY BLOCK-----

 
 
 

Changing Modification Time for a Symbolic Link

Post by James C. Weisbe » Fri, 10 Nov 1995 04:00:00




>: I don't get what your are trying to show here. What is the effect
>: of "rm 3"? On my machine it simply removes the the link and the
>: bogus file.

>Exactly.

WOOOOOOOOOOOOOOOSHHHHHHHHHHH!!
[sound of point flying over my head].

okay, I finally arrived at the gate now. Next time, I'll check
my ticket more closely.

 
 
 

Changing Modification Time for a Symbolic Link

Post by Bill Marc » Fri, 10 Nov 1995 04:00:00



Quote:>The problem with what you are trying to do is that a symbolic link shares
>an inode with the original link. and the inode contains the date
>information.  In order to change the modification time of a link, the
>link must have its own inode.  This translates into a "hard" link.

>Sorry but you cannot change the modification time on a symbolic link
>without changing the inode, which changes all links to that inode.

Sorry, but you've got hard links and symbolic links backward.  A symbolic
link is the one that can point to a file or directory on another
filesystem; therefore, the symbolic link cannot share an inode with the
"original" file.  With hard links there is no way to distinguish which
link is the "original" one; an ls -l listing will NOT show
"this.filename ->some.other.filename".
From looking at my home directory, apparently it's possible to have a
symbolic link to a file which doesn't even exist (I've got a .homepage,
but I haven't put anything in it yet).

--
"Goodness me, could this be industrial disease?"  Dire Straits

 
 
 

Changing Modification Time for a Symbolic Link

Post by Logan Sh » Tue, 14 Nov 1995 04:00:00




Quote:>Yes, in fact, I knew someone who was considering using that to
>manage his to-do list:

So was that Larry or Tom?  I'm guessing Tom.

Quote:>    ln -s "take out the trash" 1 (priority 1)
>    ln -s "feed the dog" 2 (priority 2)
>    ls -l (shows the current listing)
>    mv 1 3 (change priority)
>    ls -l (new listing)
>    rm 3 (been there, did that!)

>Truly, truly, an abuse of the Unix filesystem.  But hey, cool!

  - Logan
--
                   =-- do not send me any junk e-mail --=
 
 
 

Changing Modification Time for a Symbolic Link

Post by Geoff Cla » Sat, 18 Nov 1995 04:00:00



Quote:>|   ln -s "take out the trash" 1 (priority 1)
>|   ln -s "feed the dog" 2 (priority 2)
>|   ls -l (shows the current listing)
>|   mv 1 3 (change priority)
>|   ls -l (new listing)
>|   rm 3 (been there, did that!)
>It works for only a maximum of nine tasks at a time, though, unless
>you pipe ls -l to sort -n with the appropriate keyfield.
>Well, ten tasks if you start numbering from zero.

Who says they have to be digits?  With just the "obvious" characters
(0-9A-Za-z) you get 62 tasks.  If you know the ASCII sequence reasonably
well you can extend this a little, although the shell metacharacters
would probably best be avoided, and "." is right out :-).

Appropriately, "!" would be the highest priority.

--

UniSoft Limited, London, England.

 
 
 

Changing Modification Time for a Symbolic Link

Post by Zefr » Wed, 22 Nov 1995 04:00:00



>Who says they have to be digits?  With just the "obvious" characters
>(0-9A-Za-z) you get 62 tasks.  If you know the ASCII sequence reasonably
>well you can extend this a little, although the shell metacharacters
>would probably best be avoided, and "." is right out :-).

A bit of mucking about with dd never hurt anyone.  (-:

Quote:>Appropriately, "!" would be the highest priority.

" " would be higher priority, and "^A" (that's "\1") even higher.  The
highest possible priority would be "", which, approriately, you'd find
a little difficult to remove...

-zefram

 
 
 

1. Changing modification and access times on a sym link

Hi,

Shouldn't there be a call to do that (or how can it be done without tapping
into the kernel and creating a new system call)? Current call: utime(s)()
will change the time stamps on the file being pointed to, not the sym link.
Any help is appreciated.

Dusan

2. how do I get linux to recognize my modem

3. changing symbolic link i-node times

4. Howto: set connect() timeout?

5. Changing mod time on symbolic link

6. PostScript from roff input?

7. IBM PCI 10/100

8. lutime() for changing times of a symbolic link

9. Too many symbolic links, Symbolic link loop

10. TAR doesn't retain date/time of symbolic links

11. How to change the modification time of a file ?

12. Change modification times on a symlink: How?