News for hackers. Stuff that matters.
Re:How to change symlinks atomically (2005) by wfunction on Sunday August 21, 2016 @02:05AM (#12329637)
Yeah, it's another one of the many things that the Windows kernel gets right but *nix programmers never care to give it credit for. `FILE_LINK_INFORMATION` in Windows has a `ReplaceIfExists` flag just for this purpose.
Re:How to change symlinks atomically (2005) by rincebrain on Sunday August 21, 2016 @02:53AM (#12329748)
I'm not sure which is wrong, the person writing or the documentation, but rename() claims to be atomic with few exceptions even when overwriting an existing item.[1]

The only reason I suspect things do unlink-then-rename is that (evidently) rename() doesn't promise anything about what happens to the "src" item if rename() fails, just that something will still be in "dest".[1]

But I don't know why the commands do something different, and don't want to try reading the source of either GNU or BSD mv to find out why.

[1] - http://pubs.opengroup.org/onlinepubs/009695399/functions/ren...

Re:How to change symlinks atomically (2005) by AnonymousPlanet on Monday August 22, 2016 @09:50AM (#12336298)
It is one thing to get it right from a disgn perspective, but another to get it right from an implementation and common usage perspective (see the sibling threads to this comment).

If it doesn't exist in practice or does something different in a thousand edge cases, it's rightfully dismissed as nonexistant.

Re:How to change symlinks atomically (2005) by pif on Sunday August 21, 2016 @03:29AM (#12329846)
It's funny how you name Windows kernel in a comment about symbolic links, considering that it _misses_ symbolic links.
Re:How to change symlinks atomically (2005) by ordinary on Sunday August 21, 2016 @03:45AM (#12329888)
Re:How to change symlinks atomically (2005) by geocar on Sunday August 21, 2016 @03:58AM (#12329927)
These things are called symbolic links, but are not what UNIX calls a symbolic link. The name is unfortunate and perhaps cannot be helped.
Re:How to change symlinks atomically (2005) by icebraining on Sunday August 21, 2016 @04:03AM (#12329935)
What's the difference? Because MS claims it has created them "to function just like UNIX links", and I'm not seeing how they're wrong.
Re:How to change symlinks atomically (2005) by geocar on Sunday August 21, 2016 @04:19AM (#12329971)
On UNIX, anyone can create a symbolic link, and a symbolic link can contain arbitrary text, while Windows requires admin privileges and that the target be a valid file path.

The new WSL does have symbolic links, but these are only available to Linux programs.

Re:How to change symlinks atomically (2005) by icebraining on Sunday August 21, 2016 @04:26AM (#12329990)
The admin privileges is just the default security policy, you can configure it to allow regular users.
Re:How to change symlinks atomically (2005) by geocar on Sunday August 21, 2016 @04:44AM (#12330034)
That is really bad advice.

An application should not change the default security policy.

Re:How to change symlinks atomically (2005) by icebraining on Sunday August 21, 2016 @04:47AM (#12330037)
I'm not saying it should. I'm saying it's not a property of the symlink feature. Some Linux distro could implement the same policy, but symlinks would still be symlinks.
Re:How to change symlinks atomically (2005) by geocar on Sunday August 21, 2016 @12:20PM (#12331430)
> I'm not saying it should. I'm saying it's not a property of the symlink feature.

When someone uses the term "symbolic link" to mean something different than someone else using the term "symbolic link", we can assume they:

(a) do not understand what UNIX is calling a symbolic link, either because they have never heard the term, did not research it properly, or have some kind of learning disability

(b) are attempting to intentionally confuse users

We do not assume that "symbolic link ``features''" now means something else: We need justification to do that, and we don't have it:

A "link" is what POSIX calls a directory entry (§3.130), and a "symbolic link" is simply a directory entry (link) without a file associated with it.

When we are thinking about this clearly we can see what Microsoft did wrong, but we're under no obligation to support them in their definition because clearly their definition is less useful than the POSIX one.

> Some Linux distro could implement the same policy,

Users would revolt; they did revolt.

SELinux was popularized by a number of Linux distributions, and included a configuration that did exactly this, however people just turned it off because breaking applications pisses people off.

> but symlinks would still be symlinks.

No.

Just because they use the same words does not make them the same thing. You can use α-conversion to fix this without anyone else's help, and call Microsoft's "symbolic link" foo and UNIX's symbolic link bar, then you can find the sentence "foo would still be bar" the nonsense that it is.

Re:How to change symlinks atomically (2005) by lisivka on Sunday August 21, 2016 @05:16AM (#12330096)
No, it cannot be disabled via a policy in Linux, because it is regular FS operation, not a filter.
Re:How to change symlinks atomically (2005) by icebraining on Sunday August 21, 2016 @05:39AM (#12330167)
Sure it could, SELinux policies can operate on regular FS operations just fine.
Re:How to change symlinks atomically (2005) by lisivka on Sunday August 21, 2016 @05:14AM (#12330091)
Windows symbolic links to files are distinct from Windows symbolic links to directories. The default security settings in Windows Vista/Windows 7 disallow non-elevated administrators and all non-administrators from creating symbolic links. Symbolic links do not work at boot.
Re:How to change symlinks atomically (2005) by marcosdumay on Sunday August 21, 2016 @01:39PM (#12331809)
You know, that fixes the "May not be available for your operating system variant." disclaimer.

All the other still apply, and the GP forgot to tell you to check your HD model's documentation.

Re:How to change symlinks atomically (2005) by CyberShadow on Sunday August 21, 2016 @05:06AM (#12330071)