all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Fabrice Popineau <fabrice.popineau@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: w32.c/link()
Date: Mon, 16 Jun 2014 17:55:23 +0300	[thread overview]
Message-ID: <83k38gvr8k.fsf@gnu.org> (raw)
In-Reply-To: <loom.20140616T092558-81@post.gmane.org>

> From: Fabrice Popineau <fabrice.popineau@gmail.com>
> Date: Mon, 16 Jun 2014 07:30:50 +0000 (UTC)
> 
> I tried to use add-name-to-file from elisp,
> which calls w32.c/link(). It seems to end up in doing 
> a copy of the file. 

No, it doesn't copy.  It creates a hard link, as you'd expect.

You can verify this yourself, with the following simple procedure:

  . start Dired on some directory
  . go to any file in the listing (not a directory: Windows doesn't
    support hard links to directories)
  . notice that the second column from the left says "1", i.e. this
    file has only 1 link to its data
  . press H, type the name of a link in the minibuffer and press RET
  . press g to refresh the directory listing, and notice that both the
    original file and the link now have their link count at 2
  . visit the original file, set backup-by-copying-when-linked to a
    non-nil value, then modify the file and save it
  . visit the link and observe that the same modifications are
    "miraculously" present there as well
  . still not convinced? type "C-u C-x d", change the switches to say
    "-ali", hit RET, and observe that both the file and the link have
    the same filesystem index (a.k.a. "inode"), which means they share
    the same file data

If you have a decent port of GNU 'ls', you will see the link counts
change there as well.

If you see something different from the above, please describe what
you see.

> I'm fine with that, but that wasn't clear before trying it.
> OTOH if hard links were possible, why not using them? Permissions?

We do use them (on NTFS; on other Windows filesystems you'll likely
get an error).

> Could someone (Eli ?) care to explain why link() is implemented this way?
> Why BackupWrite() is used? I would have expected either CopyFile() or 
> CreateHardLink().

CreateHardLink was introduced with Windows 2000, while this code tries
to support older NT systems which lacked that API.  Back then this was
the only way to create a hard link.  I don't think we still support
NT4 etc., but the code works very well, so I see no reason to rewrite
it using newer APIs.



  reply	other threads:[~2014-06-16 14:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16  7:30 w32.c/link() Fabrice Popineau
2014-06-16 14:55 ` Eli Zaretskii [this message]
2014-06-16 17:55   ` w32.c/link() Fabrice Popineau
2014-06-16 18:48     ` w32.c/link() Fabrice Popineau
2014-06-16 19:27       ` w32.c/link() Eli Zaretskii
2014-06-16 20:58       ` w32.c/link() Stefan Monnier
2014-06-16 22:08         ` w32.c/link() Fabrice Popineau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83k38gvr8k.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=fabrice.popineau@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.