[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Move switch-symlinks to (guix build utils)
From: |
bokr |
Subject: |
Re: Move switch-symlinks to (guix build utils) |
Date: |
Sat, 4 Jun 2022 01:55:05 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Hi,
I am not expert on kernel link internals, but if
you need/prefer atomic change to a specific link,
does my log [1] below suggest a way?
On +2022-06-03 21:30:39 +0200, Ludovic Courtès wrote:
> Hi,
>
> Maxime Devos <maximedevos@telenet.be> skribis:
>
> >, Maybe replace
> >
> > (symlink target pivot)
> >
> > by (symlink/remove-old target pivot)
> >
> > where
> >
> > (define (symlink/remove-old target link)
> > "Make a symbolic link named LINK pointing to TARGET.
> > If LINK already exists, it will be removed first.
> > This is not an atomic operation."
> > (catch 'system-error
> > (lambda ()
> > (symlink target link))
> > (lambda stuff
> > (if (= (system-error-errno stuff) EEXIST)
> > (begin
> > ;; remove old link and retry
> > (delete-file link)
> > (symlink/remove-old link target))
> > (apply throw stuff)))))
>
> Alright, SGTM (this procedure would be kept private).
>
> So Arun, the floor is yours! :-)
>
> Ludo’.
>
[0]: (some "<--= note" notes edited in)
BTW: notice that Size: is number of chars in TARGET name, not the LINK name
--8<---------------cut here---------------start------------->8---
$ ln -sT TARGET LINK
$ stat LINK
File: LINK -> TARGET
Size: 6 Blocks: 0 IO Block: 4096 symbolic link
Device: fe00h/65024d Inode: 19401553 Links: 1 # <--= note inode number:
mv will not change it
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bokr) Gid: ( 1000/ bokr)
Access: 2022-06-04 00:57:47.680832044 +0200
Modify: 2022-06-04 00:57:47.680832044 +0200
Change: 2022-06-04 00:57:47.680832044 +0200
Birth: -
$ mv -v LINK WAS-LINK
renamed 'LINK' -> 'WAS-LINK'
$ stat WAS-LINK
File: WAS-LINK -> TARGET
Size: 6 Blocks: 0 IO Block: 4096 symbolic link #
<--= TARGET is still 6 chars :)
Device: fe00h/65024d Inode: 19401553 Links: 1 # <--= note inode
number: did not change with mv
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bokr) Gid: ( 1000/ bokr)
Access: 2022-06-04 00:57:47.680832044 +0200
Modify: 2022-06-04 00:57:47.680832044 +0200
Change: 2022-06-04 00:58:33.617240104 +0200
Birth: -
$ ln -sT NEW-TARGET LINK
$ stat LINK
File: LINK -> NEW-TARGET
Size: 10 Blocks: 0 IO Block: 4096 symbolic link #
<--= NEW-TARGET is 10 chars :)
Device: fe00h/65024d Inode: 19401638 Links: 1 <--= note inode number:
new for new use of LINK name
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bokr) Gid: ( 1000/ bokr)
Access: 2022-06-04 01:00:10.630121441 +0200
Modify: 2022-06-04 01:00:10.630121441 +0200
Change: 2022-06-04 01:00:10.630121441 +0200
Birth: -
$ rm -v WAS-LINK <--= note no OS objection to removing renamed old LINK
removed 'WAS-LINK'
$ stat *LINK*
File: LINK -> NEW-TARGET
Size: 10 Blocks: 0 IO Block: 4096 symbolic link
Device: fe00h/65024d Inode: 19401638 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bokr) Gid: ( 1000/ bokr)
Access: 2022-06-04 01:00:10.630121441 +0200
Modify: 2022-06-04 01:00:10.630121441 +0200
Change: 2022-06-04 01:00:10.630121441 +0200
Birth: -
$
--8<---------------cut here---------------end--------------->8---
I'm guessing the inode rewrite involved in mv -v LINK WAS-LINK should be atomic?
Maybe some kernels have to struggle without good hardware support, but still
atomic?
Maybe a kernel insider will chime in?
HTH some way.
--
Regards,
Bengt Richter
- Move switch-symlinks to (guix build utils), Arun Isaac, 2022/06/01
- Re: Move switch-symlinks to (guix build utils), Maxime Devos, 2022/06/01
- Re: Move switch-symlinks to (guix build utils), Arun Isaac, 2022/06/02
- Re: Move switch-symlinks to (guix build utils), Maxime Devos, 2022/06/02
- Re: Move switch-symlinks to (guix build utils), Ludovic Courtès, 2022/06/03
- Re: Move switch-symlinks to (guix build utils), Maxime Devos, 2022/06/03
- Re: Move switch-symlinks to (guix build utils), Ludovic Courtès, 2022/06/03
- Re: Move switch-symlinks to (guix build utils), Ludovic Courtès, 2022/06/03
- Re: Move switch-symlinks to (guix build utils),
bokr <=
- Re: Move switch-symlinks to (guix build utils), Maxime Devos, 2022/06/04
- Re: Move switch-symlinks to (guix build utils), Arun Isaac, 2022/06/06
- Re: Move switch-symlinks to (guix build utils), Maxime Devos, 2022/06/06
- Re: Move switch-symlinks to (guix build utils), Arun Isaac, 2022/06/08