• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Generic creation of a symblic link
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generic creation of a symblic link


  • Subject: Re: Generic creation of a symblic link
  • From: James Bucanek <email@hidden>
  • Date: Fri, 12 Oct 2012 00:05:26 -0700

Jim Luther <mailto:email@hidden> wrote (Thursday, October 11, 2012 10:29 PM -0700):
As several others said, you cannot rewrite a symbolic link file.

I'm discovering that.

If you call
symlink(path1, path2) and path2 refers to an existing file, you'll just get a
EEXISTS error.

If you're trying to replace the target of a symlink atomically so that there's
always a symbolic link file at a certain path, rename(2) is your friend. You
can create a new symbolic link file in a temporary location and then rename it
over an existing symlink:

err = symlink(new_location, temp_symlink_location); err =
rename(temp_symlink_location, symlink_location);

That will work even if the file you're renaming over isn't a symbolic link
file.

Jim, that's a fantastic tip. I was just planing on deleting the file to be replaced by the symlink first, but this is much smoother.

--
James Bucanek


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Generic creation of a symblic link (From: Jim Luther <email@hidden>)

  • Prev by Date: Re: fcntl(fd,F_SETSIZE,?)
  • Next by Date: Re: Generic creation of a symblic link
  • Previous by thread: Re: Generic creation of a symblic link
  • Next by thread: Re: Generic creation of a symblic link
  • Index(es):
    • Date
    • Thread