Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Facts are stubborn, but statistics are more pliable.


devel / comp.unix.shell / Re: How can I rename and "touch" a file in one go?

SubjectAuthor
* How can I rename and "touch" a file in one go?Ottavio Caruso
+* How can I rename and "touch" a file in one go?Janis Papanagnou
|`* How can I rename and "touch" a file in one go?Ottavio Caruso
| +- How can I rename and "touch" a file in one go?Janis Papanagnou
| +* How can I rename and "touch" a file in one go?Lew Pitcher
| |`- How can I rename and "touch" a file in one go?Lew Pitcher
| +- How can I rename and "touch" a file in one go?David W. Hodgins
| +* How can I rename and "touch" a file in one go?Kaz Kylheku
| |+* How can I rename and "touch" a file in one go?Bit Twister
| ||+- How can I rename and "touch" a file in one go?Janis Papanagnou
| ||`- How can I rename and "touch" a file in one go?Keith Thompson
| |`* How can I rename and "touch" a file in one go?Ottavio Caruso
| | `- How can I rename and "touch" a file in one go?Wayne
| +* How can I rename and "touch" a file in one go?Frank Winkler
| |+* Bad defaults for Unix 'cp" commands (Was: How can I rename and "touch" a file inKenny McCormack
| ||`* Bad defaults for Unix 'cp" commands (Was: How can I rename andChris Elvidge
| || +* Bad defaults for Unix 'cp" commands (Was: How can I rename andFrank Winkler
| || |`* Bad defaults for Unix 'cp" commands (Was: How can I rename andKenny McCormack
| || | +* Bad defaults for Unix 'cp" commands (Was: How can I rename andFrank Winkler
| || | |+* Google is soooo kewl! (Was: Bad defaults for Unix 'cp" commands (Was: How can I Kenny McCormack
| || | ||`- Google is soooo kewl! (Was: Bad defaults for Unix 'cp" commandsOttavio Caruso
| || | |`- Bad defaults for Unix 'cp" commands (Was: How can I rename andKenny McCormack
| || | `- Bad defaults for Unix 'cp" commands (Was: How can I rename andChris Elvidge
| || +- Bad defaults for Unix 'cp" commands (Was: How can I rename andDavid W. Hodgins
| || +- Bad defaults for Unix 'cp" commands (Was: How can I rename andKaz Kylheku
| || `* Bad defaults for Unix 'cp" commands (Was: How can I rename andKaz Kylheku
| ||  `* Bad defaults for Unix 'cp" commands (Was: How can I rename andWayne
| ||   `- Bad defaults for Unix 'cp" commands (Was: How can I rename andOttavio Caruso
| |+* How can I rename and "touch" a file in one go?Janis Papanagnou
| ||`* How can I rename and "touch" a file in one go?Keith Thompson
| || `- How can I rename and "touch" a file in one go?Janis Papanagnou
| |+* How can I rename and "touch" a file in one go?Ben Bacarisse
| ||`* How can I rename and "touch" a file in one go?Geoff Clare
| || `- How can I rename and "touch" a file in one go?Ben Bacarisse
| |+- How can I rename and "touch" a file in one go?Keith Thompson
| |`* How can I rename and "touch" a file in one go?Kaz Kylheku
| | +* How can I rename and "touch" a file in one go?Janis Papanagnou
| | |`- How can I rename and "touch" a file in one go?Kaz Kylheku
| | `- How can I rename and "touch" a file in one go?Ben Bacarisse
| +- How can I rename and "touch" a file in one go?Wayne
| +* How can I rename and "touch" a file in one go?Randal L. Schwartz
| |+* How can I rename and "touch" a file in one go?Christian Weisgerber
| ||+* How can I rename and "touch" a file in one go?Janis Papanagnou
| |||`- How can I rename and "touch" a file in one go?Dan Cross
| ||`- How can I rename and "touch" a file in one go?Kaz Kylheku
| |+- How can I rename and "touch" a file in one go?Ben Bacarisse
| |`- How can I rename and "touch" a file in one go?Dan Cross
| `* How can I rename and "touch" a file in one go?Richard Kettlewell
|  `* How can I rename and "touch" a file in one go?Kenny McCormack
|   +* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |`* How can I rename and "touch" a file in one go?Kenny McCormack
|   | `* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |  `* How can I rename and "touch" a file in one go?Richard Kettlewell
|   |   `* How can I rename and "touch" a file in one go?Janis Papanagnou
|   |    `- How can I rename and "touch" a file in one go?Dan Cross
|   +* How can I rename and "touch" a file in one go?Ben Bacarisse
|   |`- How can I rename and "touch" a file in one go?Dan Cross
|   `* How can I rename and "touch" a file in one go?Geoff Clare
|    +* How can I rename and "touch" a file in one go?Christian Weisgerber
|    |`* How can I rename and "touch" a file in one go?Geoff Clare
|    | +- How can I rename and "touch" a file in one go?Kenny McCormack
|    | `* How can I rename and "touch" a file in one go?Keith Thompson
|    |  +- How can I rename and "touch" a file in one go?Richard Kettlewell
|    |  `- How can I rename and "touch" a file in one go?Jim
|    `- How can I rename and "touch" a file in one go?John D Groenveld
`- How can I rename and "touch" a file in one go?Kaz Kylheku

Pages:123
Re: How can I rename and "touch" a file in one go?

<20230730110546.658@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6478&group=comp.unix.shell#6478

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Sun, 30 Jul 2023 18:06:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <20230730110546.658@kylheku.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com>
<slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de>
Injection-Date: Sun, 30 Jul 2023 18:06:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e03ffdfa499b0f433ff65455cb09cf27";
logging-data="3154051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JqC0L+ms46OlpsLRyEx9SN0Ubul2yocI="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:q8CvtuZFKIBj73aZZdeJ063cJ6U=
 by: Kaz Kylheku - Sun, 30 Jul 2023 18:06 UTC

On 2023-07-30, Christian Weisgerber <naddy@mips.inka.de> wrote:
> On 2023-07-30, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>
>> Classic Unix filesystems do *not* have a "creation date". They have a
>> "ctime" field, which updates when the file is opened for write, or the
>> metadata about the file has changed (name, number of links, and so on).
>>
>> Renaming a file traditionally has updated ctime,
>
> ... because it was implemented as a sequence of link(2) and unlink(2),
> which touched the inode's link count.
>
> I have a vague memory that the atomicity (or lack thereof) of the
> later rename(2) system call was a much discussed topic, but I don't
> remember what's the status on modern operating systems.

It's funny that something which is probably 3 lines of C somewhere
keeps generating debate decades later.

If every decision in every 3 lines came with the threat of debate
decades later, I'd be paralyzed from coding anything. :)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: How can I rename and "touch" a file in one go?

<avmkpj-up8.ln1@ID-313840.user.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6479&group=comp.unix.shell#6479

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Mon, 31 Jul 2023 13:44:58 +0100
Lines: 15
Message-ID: <avmkpj-up8.ln1@ID-313840.user.individual.net>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net wOou9uD/xBgUfQkZ2LUPYwlzeCxIuxb/vaA2cK7N0Ne13APyvp
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:tzG1wThlddZtMjB2zhLarCy/wsc= sha256:6/69TyWoauzvJPRmiypXQoNfUMxkFaSP+IM2Q0BqMrw=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Mon, 31 Jul 2023 12:44 UTC

Kenny McCormack wrote:

> But the real point here, which has been alluded to by various posters (but
> not stated explicitly), is that many new users (including, I believe, OP)
> assume that the "c" in "ctime" stands for "creation". In fact, it doesn't.
> It stands for "change" - specifically, an inode change, as opposed to a
> data change.
>
> And, in fact, when you rename a file (*), "ctime" *is* updated.

Some systems update it, some don't. It may well be an old SysV v. BSD
difference, as Solaris updates it but macOS does not.

--
Geoff Clare <netnews@gclare.org.uk>

Re: How can I rename and "touch" a file in one go?

<ua8dkm$39n3c$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6480&group=comp.unix.shell#6480

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Mon, 31 Jul 2023 15:40:38 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ua8dkm$39n3c$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me>
<wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk> <ua5io6$2tteg$1@news.xmission.com>
<ua5pko$2uu8g$1@dont-email.me> <ua61kg$2u50c$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Jul 2023 13:40:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="711eb905ff5c636eb1cd33a1e72c81bf";
logging-data="3464300"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//L0Ne5eQjr1+5BPSCwUlL"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:w1UDOK+nL8m01EPM/wPhBEahOUY=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <ua61kg$2u50c$1@news.xmission.com>
 by: Janis Papanagnou - Mon, 31 Jul 2023 13:40 UTC

On 30.07.2023 18:03, Kenny McCormack wrote:
> In article <ua5pko$2uu8g$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> This part made me curious...
>>
>> On 30.07.2023 13:49, Kenny McCormack wrote:
>>>
>>> (*) Note that, at the nuts-and-bolts level, in Unix terms, a "rename"
>>> always boils down to a link followed by an unlink.
>>
>> Inspecting the system log file during a file "rename" invoked by mv(1)
>> I can only spot a rename(2) system call (but no link(2) or unlink(2)).
>
> Obviously, somebody was going to post that.
>
> But I think even lower, at the real nuts&bolts level, rename is doing the
> equivalent of link/unlink. The point of making rename a system call was to
> make it possible to make certain guarantees of atomicity.

If atomicity is the topic then a statement "always boils down to a link
followed by an unlink" makes even less sense. But okay, YMMV.

Janis

Re: How can I rename and "touch" a file in one go?

<slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6481&group=comp.unix.shell#6481

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Mon, 31 Jul 2023 13:49:40 -0000 (UTC)
Message-ID: <slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
<avmkpj-up8.ln1@ID-313840.user.individual.net>
Injection-Date: Mon, 31 Jul 2023 13:49:40 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="86321"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Mon, 31 Jul 2023 13:49 UTC

On 2023-07-31, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:

>> And, in fact, when you rename a file (*), "ctime" *is* updated.
>
> Some systems update it, some don't. It may well be an old SysV v. BSD
> difference, as Solaris updates it but macOS does not.

FreeBSD and OpenBSD do update it.

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: How can I rename and "touch" a file in one go?

<aoVxM.134753$ens9.78401@fx45.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6482&group=comp.unix.shell#6482

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
From: groenveld@acm.org (John D Groenveld)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
References: <u9at4h$2kq2g$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk> <ua5io6$2tteg$1@news.xmission.com> <avmkpj-up8.ln1@ID-313840.user.individual.net>
Organization: Groenveld.US
Lines: 10
Message-ID: <aoVxM.134753$ens9.78401@fx45.iad>
X-Complaints-To: abuse@frugalusenet.com
NNTP-Posting-Date: Mon, 31 Jul 2023 21:07:18 UTC
Date: Mon, 31 Jul 2023 21:07:18 GMT
X-Received-Bytes: 943
 by: John D Groenveld - Mon, 31 Jul 2023 21:07 UTC

In article <avmkpj-up8.ln1@ID-313840.user.individual.net>,
Geoff Clare <netnews@gclare.org.uk> wrote:
>Some systems update it, some don't. It may well be an old SysV v. BSD
>difference, as Solaris updates it but macOS does not.

On Omnios (illumos) stat(1) lists an updated ctime on ZFS and tmpfs(4FS).
With ZFS stat(1) reports a birthtime.

John
groenveld@acm.org

Re: How can I rename and "touch" a file in one go?

<wwvil9zi51m.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6483&group=comp.unix.shell#6483

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 01 Aug 2023 08:40:37 +0100
Organization: terraraq NNTP server
Message-ID: <wwvil9zi51m.fsf@LkoBDZeT.terraraq.uk>
References: <u9at4h$2kq2g$1@dont-email.me>
<wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com> <ua5pko$2uu8g$1@dont-email.me>
<ua61kg$2u50c$1@news.xmission.com> <ua8dkm$39n3c$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="29813"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:Td5Jbc1HxcIOqRg7aEcJDXkuOTg=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Tue, 1 Aug 2023 07:40 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 30.07.2023 18:03, Kenny McCormack wrote:

>> But I think even lower, at the real nuts&bolts level, rename is doing
>> the equivalent of link/unlink. The point of making rename a system
>> call was to make it possible to make certain guarantees of atomicity.
>
> If atomicity is the topic then a statement "always boils down to a link
> followed by an unlink" makes even less sense. But okay, YMMV.

“rename is link followed by unlink, but atomic” doesn’t reflect what
happens with directories, where you need to add an additional unlink
followed by link to reflect the overall outcome (at least in traditional
Unix filesystsem).

It’s also troublesome as an explanatory model in filesystems which don’t
support hard links (i.e. which can’t have two names for one file
existing at once).

Finally it’s not a great model when talking to an audience which isn’t
familiar or comfortable with the idea of multiple names for a single
file.

With those caveats in mind, though, I agree with Kenny, and the reason
for that is that you can still see reflections of the link+unlink design
(generally surrounded by a lot of additional complexity) in some modern
kernel implementations.

--
https://www.greenend.org.uk/rjk/

Re: How can I rename and "touch" a file in one go?

<o5anpj-nh6.ln1@ID-313840.user.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6485&group=comp.unix.shell#6485

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: geoff@clare.See-My-Signature.invalid (Geoff Clare)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 13:24:56 +0100
Lines: 17
Message-ID: <o5anpj-nh6.ln1@ID-313840.user.individual.net>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
<avmkpj-up8.ln1@ID-313840.user.individual.net>
<slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>
Reply-To: netnews@gclare.org.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net wmUotu2LcfmXq1LTzeMhigJDKQeduBqsw1PPPtc45AsTLJM8vZ
X-Orig-Path: ID-313840.user.individual.net!not-for-mail
Cancel-Lock: sha1:lA6KZyN55HLAQz4tZ5J/fDr93ok= sha256:LZFVHmNZ/nczBJYdpg9FTylEtEB3kIY0C0YSDVZwRhg=
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
 by: Geoff Clare - Tue, 1 Aug 2023 12:24 UTC

Christian Weisgerber wrote:

> On 2023-07-31, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:
>
>>> And, in fact, when you rename a file (*), "ctime" *is* updated.
>>
>> Some systems update it, some don't. It may well be an old SysV v. BSD
>> difference, as Solaris updates it but macOS does not.
>
> FreeBSD and OpenBSD do update it.

Thanks. I suppose that means either the macOS rename() internals
didn't come from FreeBSD or there has been a change in FreeBSD since
Apple used it as the basis for OS X.

--
Geoff Clare <netnews@gclare.org.uk>

Re: How can I rename and "touch" a file in one go?

<uab1ge$30lad$1@news.xmission.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6486&group=comp.unix.shell#6486

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 13:31:58 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <uab1ge$30lad$1@news.xmission.com>
References: <u9at4h$2kq2g$1@dont-email.me> <avmkpj-up8.ln1@ID-313840.user.individual.net> <slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de> <o5anpj-nh6.ln1@ID-313840.user.individual.net>
Injection-Date: Tue, 1 Aug 2023 13:31:58 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3167565"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 1 Aug 2023 13:31 UTC

In article <o5anpj-nh6.ln1@ID-313840.user.individual.net>,
Geoff Clare <netnews@gclare.org.uk> wrote:
>Christian Weisgerber wrote:
>
>> On 2023-07-31, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:
>>
>>>> And, in fact, when you rename a file (*), "ctime" *is* updated.
>>>
>>> Some systems update it, some don't. It may well be an old SysV v. BSD
>>> difference, as Solaris updates it but macOS does not.
>>
>> FreeBSD and OpenBSD do update it.
>
>Thanks. I suppose that means either the macOS rename() internals
>didn't come from FreeBSD or there has been a change in FreeBSD since
>Apple used it as the basis for OS X.

It isn't just the OS that is the variable. The underlying filesystem
matters, too. Having used a Mac myself, I know that the underlying
filesystem (HFS) is not really a regular Unix filesystem - it has its roots
in more PC-ish OSes (i.e., original Mac OS, FAT, HPFS/NTFS, etc). For
example (and be warned that I don't have access to a Mac at the moment to
test this, so my memory may be inaccurate), but my memory is that HFS
doesn't really support hard links (they are emulated in software). Also,
it is only case retentive (like NTFS), not case sensitive (like regular
Unix/Linux filesystems).

Also, see the man page for renameat2(2), for another example of where the
underlying fs matters.

--
I am not a troll.
Rick C. Hodgin
I am not a crook.
Rick M. Nixon

Re: How can I rename and "touch" a file in one go?

<uab4dp$bfc$2@reader2.panix.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6487&group=comp.unix.shell#6487

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 14:21:45 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uab4dp$bfc$2@reader2.panix.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me> <u9bfbf$2o509$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com>
Injection-Date: Tue, 1 Aug 2023 14:21:45 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="11756"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Tue, 1 Aug 2023 14:21 UTC

In article <86edkq9p2n.fsf@red.stonehenge.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Ottavio" == Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
>
>Ottavio> Thanks, but it sucks. Has this been "mv" standard behaviour
>Ottavio> from the UNIX days? You would expect that renaming a file
>Ottavio> literally creates a new file, hence modifying creation date.
>
>Classic Unix filesystems do *not* have a "creation date". They have a
>"ctime" field, which updates when the file is opened for write, or the
>metadata about the file has changed (name, number of links, and so on).

I'm not sure about the "opened for write" bit. On a write(2),
sure, but not necessary an open(2); at least, this is not listed
in the man page as a call that updates `st_ctime`. A quick spin
through 4.4BSD's ufs leads me to believe `ctime` is only changed
with the inode is updated, but not on open.

- Dan C.

Re: How can I rename and "touch" a file in one go?

<uab4th$bfc$3@reader2.panix.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6488&group=comp.unix.shell#6488

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 14:30:09 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uab4th$bfc$3@reader2.panix.com>
References: <u9at4h$2kq2g$1@dont-email.me> <86edkq9p2n.fsf@red.stonehenge.com> <slrnuccm4s.1l8k.naddy@lorvorc.mips.inka.de> <ua5udp$2vbt2$1@dont-email.me>
Injection-Date: Tue, 1 Aug 2023 14:30:09 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="11756"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Tue, 1 Aug 2023 14:30 UTC

In article <ua5udp$2vbt2$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>On 30.07.2023 14:33, Christian Weisgerber wrote:
>> On 2023-07-30, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>
>>> Classic Unix filesystems do *not* have a "creation date". They have a
>>> "ctime" field, which updates when the file is opened for write, or the
>>> metadata about the file has changed (name, number of links, and so on).
>>>
>>> Renaming a file traditionally has updated ctime,
>>
>> ... because it was implemented as a sequence of link(2) and unlink(2),
>> which touched the inode's link count.
>>
>> I have a vague memory that the atomicity (or lack thereof) of the
>> later rename(2) system call was a much discussed topic, but I don't
>> remember what's the status on modern operating systems.
>
>I think the "later" and the "modern" should be put in a quantified
>age context. My Stevens' APUE from 1993 (that's three decades ago)
>already describes rename(2) (and also mentions POSIX.1 changes).
>An older Unix book (based on UNIX Version 7) from 1984 didn't have
>it listed.

Research Unix up to the 7th Edition implemented `mv` as a pair
of system calls: `link` and then `unlink`. The introduction of
the 4.2BSD "fast filesystem" brought the `rename` system call
(really, this seems to have first showed up in 4.1c) which was
atomic. Curiously, post-7th Ed Unix, which reimported the 4BSD
kernel, seems to have eschewed the `rename(2)` system call.

- Dan C.

Re: How can I rename and "touch" a file in one go?

<uab6d7$lu0$1@reader2.panix.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6489&group=comp.unix.shell#6489

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 14:55:35 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uab6d7$lu0$1@reader2.panix.com>
References: <u9at4h$2kq2g$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk> <ua5io6$2tteg$1@news.xmission.com> <87wmyhwe25.fsf@bsb.me.uk>
Injection-Date: Tue, 1 Aug 2023 14:55:35 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="22464"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Tue, 1 Aug 2023 14:55 UTC

In article <87wmyhwe25.fsf@bsb.me.uk>,
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>gazelle@shell.xmission.com (Kenny McCormack) writes:
>
>> But the real point here, which has been alluded to by various posters (but
>> not stated explicitly), is that many new users (including, I believe, OP)
>> assume that the "c" in "ctime" stands for "creation". In fact, it doesn't.
>> It stands for "change" - specifically, an inode change, as opposed to a
>> data change.
>
>That's a new interpretation. In the original paper on Unix, the i-node
>is described as having a creation time. The field names, st_ctime,
>st_mtime and st_atime were chosen with these meanings. When (very soon
>after) a new kind of time had to be recorded, st_ctime was re-purposed.

It is true that the 1978 paper says that, as does the comment on
the `st_ctime` field in `sys/ino.h` in 7th Edition; `st_ctime`
was not present before that.

However, that is not the original Unix paper; the earlier 1974
paper published in CACM does not mention a ctime at all; instead
it just mentions "5. Time of last modification." Note that
mention of accessed time is also absent here.
https://dsf.berkeley.edu/cs262/unix.pdf

Note that with respect to 7th Edition, both the comment and the
paperappear to be wrong. Looking at the kernel sources,
`di_ctime` is updated by `iupdat` in `usr/sys/iget.c` whenever
the `ICHG` flag is set on the inode; that flag is set in a
number of places (write, chmod, chown, link/unlink, etc) in
addition to the original file creation.

>So what the "c" in ctime stands for has changed. It's no wonder people
>are confused because atime, mtime and ctime are so obvious. Had it
>originally been used for its later purpose, I doubt it would have been
>called ctime.

It would seem that the `ctime` field in the inode has always had
a meaning very close to what we assume it to be in a modern
context; if it was ever _just_ the creation time, then that
would likely have been in an unreleased version of Unix and only
for a very short time indeed.

- Dan C.

Re: How can I rename and "touch" a file in one go?

<87h6pimr7g.fsf@nosuchdomain.example.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6490&group=comp.unix.shell#6490

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 01 Aug 2023 13:40:35 -0700
Organization: None to speak of
Lines: 22
Message-ID: <87h6pimr7g.fsf@nosuchdomain.example.com>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
<avmkpj-up8.ln1@ID-313840.user.individual.net>
<slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>
<o5anpj-nh6.ln1@ID-313840.user.individual.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="cf163eef2e6d3fe4b73e25e19dd6ab37";
logging-data="3954511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/z6tRX5+CP5ETs7on+NLWu"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:VICYKlqgTRk/N8+k5cldt4AKL8Y=
sha1:39zjwpI1lVYLcBAgFZZt2xlB1gE=
 by: Keith Thompson - Tue, 1 Aug 2023 20:40 UTC

Geoff Clare <geoff@clare.See-My-Signature.invalid> writes:
> Christian Weisgerber wrote:
>> On 2023-07-31, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:
>>>> And, in fact, when you rename a file (*), "ctime" *is* updated.
>>>
>>> Some systems update it, some don't. It may well be an old SysV v. BSD
>>> difference, as Solaris updates it but macOS does not.
>>
>> FreeBSD and OpenBSD do update it.
>
> Thanks. I suppose that means either the macOS rename() internals
> didn't come from FreeBSD or there has been a change in FreeBSD since
> Apple used it as the basis for OS X.

My understanding is that MacOS was based on an older BSD (and other
sources), not on FreeBSD. FreeBSD and MacOS are siblings or cousins,
not parent and child.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: How can I rename and "touch" a file in one go?

<uabr7k$3ospu$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6491&group=comp.unix.shell#6491

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 1 Aug 2023 22:50:59 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <uabr7k$3ospu$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me>
<wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk> <ua5io6$2tteg$1@news.xmission.com>
<ua5pko$2uu8g$1@dont-email.me> <ua61kg$2u50c$1@news.xmission.com>
<ua8dkm$39n3c$1@dont-email.me> <wwvil9zi51m.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 1 Aug 2023 20:51:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="67a0cbfdf4b728875efb956287fb8603";
logging-data="3961662"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3KmZVB2ySoB5TEewYmUiI"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:E9nUGgiFnzZ64cmrSPz5JMkQvMY=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <wwvil9zi51m.fsf@LkoBDZeT.terraraq.uk>
 by: Janis Papanagnou - Tue, 1 Aug 2023 20:50 UTC

On 01.08.2023 09:40, Richard Kettlewell wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 30.07.2023 18:03, Kenny McCormack wrote:
>
>>> But I think even lower, at the real nuts&bolts level, rename is doing
>>> the equivalent of link/unlink. The point of making rename a system
>>> call was to make it possible to make certain guarantees of atomicity.
>>
>> If atomicity is the topic then a statement "always boils down to a link
>> followed by an unlink" makes even less sense. But okay, YMMV.
>
> “rename is link followed by unlink, but atomic” doesn’t reflect what
> happens with directories, where you need to add an additional unlink
> followed by link to reflect the overall outcome (at least in traditional
> Unix filesystsem).
>
> It’s also troublesome as an explanatory model in filesystems which don’t
> support hard links (i.e. which can’t have two names for one file
> existing at once).

Same issue with cross-device links.

Generally I agree with you concerning directories and the general case
of hard links (whether non-supporting FS or cross-device applications).

Or similar a 'mv' when considering cross-device arguments (emulated by
cp/rm).

>
> Finally it’s not a great model when talking to an audience which isn’t
> familiar or comfortable with the idea of multiple names for a single
> file.

Speaking about "models", I wouldn't consider explaining rename(2) by
link(2) and unlink(2) (or explaining mv(1) by cp(1) and rm(1), just to
make my point clear) a sensible approach if it doesn't reflect reality
(which is optimized for the simple standard cases). If an "audience"
is operating/working on _that_ OS level it should IMO know the details
and differences of the supported actual cases. A model that gives the
impression that an [atomic] system function is effectively built upon
more than one system function - thus conceptually/model-wise becoming
non-atomic - I'd not consider a preferable description. Introducing
functions that aren't actually used to explain a function I also don't
consider sensible. (The formal part of the POSIX specs, for example,
doesn't mention them; they are unnecessary for understanding.) But as
I said upthread, mileages (obviously) vary.

>
> With those caveats in mind, though, I agree with Kenny, and the reason
> for that is that you can still see reflections of the link+unlink design
> (generally surrounded by a lot of additional complexity) in some modern
> kernel implementations.

Maybe. I currently have no systems other than Linux available. Though
the POSIX description should anyway suffice.

Janis

Re: How can I rename and "touch" a file in one go?

<wwvedkmv45t.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6492&group=comp.unix.shell#6492

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Tue, 01 Aug 2023 22:33:34 +0100
Organization: terraraq NNTP server
Message-ID: <wwvedkmv45t.fsf@LkoBDZeT.terraraq.uk>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
<avmkpj-up8.ln1@ID-313840.user.individual.net>
<slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>
<o5anpj-nh6.ln1@ID-313840.user.individual.net>
<87h6pimr7g.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="41848"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:I3aTyN/23lZcmMF5K06XKLlLDxM=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Tue, 1 Aug 2023 21:33 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Geoff Clare <geoff@clare.See-My-Signature.invalid> writes:
>> Thanks. I suppose that means either the macOS rename() internals
>> didn't come from FreeBSD or there has been a change in FreeBSD since
>> Apple used it as the basis for OS X.
>
> My understanding is that MacOS was based on an older BSD (and other
> sources), not on FreeBSD. FreeBSD and MacOS are siblings or cousins,
> not parent and child.

At some point between NeXTStep and current macOS they upgraded from 4.x
BSD to FreeBSD.

https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/BSD/BSD.html

But this isn’t probably not directly relevant to the provenance of
rename(); the nuts and bolts are filesystem-dependent and HFS/HFS+ are
Apple code.

--
https://www.greenend.org.uk/rjk/

Re: How can I rename and "touch" a file in one go?

<uadnqb$34cd$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6499&group=comp.unix.shell#6499

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jim.beard@verizon.net (Jim)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Wed, 2 Aug 2023 14:04:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <uadnqb$34cd$1@dont-email.me>
References: <u9at4h$2kq2g$1@dont-email.me> <u9atuc$2l1a0$1@dont-email.me>
<u9bfbf$2o509$1@dont-email.me> <wwv8raxk7me.fsf@LkoBDZeT.terraraq.uk>
<ua5io6$2tteg$1@news.xmission.com>
<avmkpj-up8.ln1@ID-313840.user.individual.net>
<slrnucfevk.2k9g.naddy@lorvorc.mips.inka.de>
<o5anpj-nh6.ln1@ID-313840.user.individual.net>
<87h6pimr7g.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Aug 2023 14:04:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0132197fd62841ce654d6ef8e0b83e76";
logging-data="102797"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WBM0kQsp96aPRf53hCADS"
User-Agent: Pan/0.146 (Hic habitat felicitas; 8107378
git@gitlab.gnome.org:GNOME/pan.git)
Cancel-Lock: sha1:Yj+bZk5Oa6gVfuqvIs8AqIpODik=
 by: Jim - Wed, 2 Aug 2023 14:04 UTC

On Tue, 01 Aug 2023 13:40:35 -0700, Keith Thompson wrote:

> Geoff Clare <geoff@clare.See-My-Signature.invalid> writes:
>> Christian Weisgerber wrote:
>>> On 2023-07-31, Geoff Clare <geoff@clare.See-My-Signature.invalid> wrote:
>>>>> And, in fact, when you rename a file (*), "ctime" *is* updated.
>>>>
>>>> Some systems update it, some don't. It may well be an old SysV v. BSD
>>>> difference, as Solaris updates it but macOS does not.
>>>
>>> FreeBSD and OpenBSD do update it.
>>
>> Thanks. I suppose that means either the macOS rename() internals
>> didn't come from FreeBSD or there has been a change in FreeBSD since
>> Apple used it as the basis for OS X.
>
> My understanding is that MacOS was based on an older BSD (and other
> sources), not on FreeBSD. FreeBSD and MacOS are siblings or cousins,
> not parent and child.

macOS version history in WIKI has a section on Development outside Apple
that is consistent with what I have read and remember over the years.

en.wikipedia.org/wiki/MacOS_version_history

Cheers!

jim b.

--
UNIX is not user-unfriendly, it merely
expects users to be computer friendly.

Re: How can I rename and "touch" a file in one go?

<uae036$rsf$1@reader2.panix.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=6503&group=comp.unix.shell#6503

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.unix.shell
Subject: Re: How can I rename and "touch" a file in one go?
Date: Wed, 2 Aug 2023 16:26:14 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uae036$rsf$1@reader2.panix.com>
References: <u9at4h$2kq2g$1@dont-email.me> <ua8dkm$39n3c$1@dont-email.me> <wwvil9zi51m.fsf@LkoBDZeT.terraraq.uk> <uabr7k$3ospu$1@dont-email.me>
Injection-Date: Wed, 2 Aug 2023 16:26:14 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="28559"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Wed, 2 Aug 2023 16:26 UTC

In article <uabr7k$3ospu$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>[snip]
>Speaking about "models", I wouldn't consider explaining rename(2) by
>link(2) and unlink(2) (or explaining mv(1) by cp(1) and rm(1), just to
>make my point clear) a sensible approach if it doesn't reflect reality
>(which is optimized for the simple standard cases). If an "audience"
>is operating/working on _that_ OS level it should IMO know the details
>and differences of the supported actual cases. A model that gives the
>impression that an [atomic] system function is effectively built upon
>more than one system function - thus conceptually/model-wise becoming
>non-atomic - I'd not consider a preferable description. Introducing
>functions that aren't actually used to explain a function I also don't
>consider sensible. (The formal part of the POSIX specs, for example,
>doesn't mention them; they are unnecessary for understanding.) But as
>I said upthread, mileages (obviously) vary.

It is illustrative here to look at the history of the call, and
when it was added in BSD (4.1c is when it first appeared). From
sys/sys/ufs_syscalls.c, we can see the comment on `rename`:

/*
* Rename system call.
* rename("foo", "bar");
* is essentially
* unlink("bar");
* link("foo", "bar");
* unlink("foo");
* but ``atomically''. Can't do full commit without saving state in the
* inode on disk which isn't feasible at this time. Best we can do is
* always guarantee the target exists.
*
* Basic algorithm is:
*
* 1) Bump link count on source while we're linking it to the
* target. This also insure the inode won't be deleted out
* from underneath us while we work.
* 2) Link source to destination. If destination already exists,
* delete it first.
* 3) Unlink source reference to inode if still around.
* 4) If a directory was moved and the parent of the destination
* is different from the source, patch the ".." entry in the
* directory.
*
* Source and destination must either both be directories, or both
* not be directories. If target is a directory, it must be empty.
*/
(https://www.tuhs.org/cgi-bin/utree.pl?file=4.1cBSD/a/sys/sys/ufs_syscalls.c)

In order to understand the semantics here, it is important to
contextualize what "atomic" means in the context of filesystems:
this means that an operation with side effects cannot allow an
observer to see intermediate states, one either sees the new
state or the old state; whether the transition from one to the
other requires many steps is immaterial: the point is that this
invariant is maintained _with respect to the external
observer_.

A way to unify this with a mental model may be to describe it as
being multiple operations that happen in a critical section.

Here, the comment gives us a hint about the limitations: "Best
we can do is always guarantee the target exists." Note that
this implies that both the target _and_ source may exist if,
say, the system crashes in the middle of the syscall.

- Dan C.

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor