unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Fabrice Popineau <fabrice.popineau@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: w32.c/link()
Date: Mon, 16 Jun 2014 19:55:25 +0200	[thread overview]
Message-ID: <CAFgFV9OXfoGKxD6TWsbiraiHyR2xqt2DD3eYJaN5WRn9=MXqpQ@mail.gmail.com> (raw)
In-Reply-To: <83k38gvr8k.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2367 bytes --]

Thanks for the explanations.
After carefully trying again, it is working as expected.

Fabrice


2014-06-16 16:55 GMT+02:00 Eli Zaretskii <eliz@gnu.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.
>

[-- Attachment #2: Type: text/html, Size: 3049 bytes --]

  reply	other threads:[~2014-06-16 17: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 ` w32.c/link() Eli Zaretskii
2014-06-16 17:55   ` Fabrice Popineau [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAFgFV9OXfoGKxD6TWsbiraiHyR2xqt2DD3eYJaN5WRn9=MXqpQ@mail.gmail.com' \
    --to=fabrice.popineau@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).