(COPYFILE 'FOO;1 'FOO;1) for any FOO wipes out the contents
I think it should detect that it is about to overwrite, and cause an error
At the unix shell, cp FOO FOO is not allowed, Medley should have the same check.
But how can COPYFILE determine that it is copying from and to the same file? It has to know that that is about to happen before it opens the output file. If FOO;1 is an existing file, (OPENSTREAM 'FOO;1 'OUTPUT) has already smashed the file.
It seems that (EQ (INFILEP X)(OUTFILEP X)) is close, but what if the same underlying file is referred to by both its {DSK} and {UNIX} names.
Is there a way of getting a handle on an existing file that can be safely used in such a comparison? Or if it has to go through the canonical device-dependent names, is there a standard way of mapping a DSK file name to the name by which the underlying file system knows it?
In the Unix shell case, for cp either the destination file doesn't exist, in which case the operation can go ahead, or it does exist and therefore you can compare the inode numbers of the source and destination after resolving any links (hard and/or symbolic) and reject the operation if they're the same.
However, note that:
briggs@flap /tmp % cat foo
asdf
briggs@flap /tmp % cat foo >foo
briggs@flap /tmp % cat foo
briggs@flap /tmp %
has exactly the behavior as current COPYFILE.
I suspect that what would be most useful is to have (GETFILEINFO <name-or-stream> 'NUMBER) return the i-node number (or equivalent) of an existing file, then we could implement (SAMEFILEP <name-or-stream1> <name-or-stream2>) (or just open code it in COPYFILE) which would, for two existing files, compare the i-node numbers. SAMEFILEP could take names or streams but in the COPYFILE case you'd want to pass the names before you open the output file.
please note there is a script 'cpv' in medley/scripts/ which is used by loadup and other scripts for maintaining versioned files from the Unix shell.
It started as a quick hac but Frank has addeed quite a bit of machanism for odd cases.
Check it out.
File system i-node numbers are 64-bit -- we don't have a 64-bit datatype in Lisp, and I don't know that we can pass more than a single pointer to a result through the FDEV GETFILEINFO method.
Can it make 2 calls, asking separately for the high and low 32 bits of the file's id?
On Aug 15, 2025, at 3:13 PM, Nick Briggs @.***> wrote:
nbriggs left a comment (Interlisp/medley#2238) https://github.com/Interlisp/medley/issues/2238#issuecomment-3192878426 File system i-node numbers are 64-bit -- we don't have a 64-bit datatype in Lisp, and I don't know that we can pass more than a single pointer to a result through the FDEV GETFILEINFO method.
— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/2238#issuecomment-3192878426, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJJSDBCA2LWP64KP5Z33NZLPLAVCNFSM6AAAAACC3MOIUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJSHA3TQNBSGY. You are receiving this because you authored the thread.
Yeah, that would work - perhaps I'll go with INODE.LO and INODE.HI for property names -- and you can fetch the low word first and skip the high if they're different. Most of the time you'd only need the one call.
If the only point is to see if identical or not, then just getting either half would be sufficient.
Sent via the Samsung Galaxy S22+ 5G, an AT&T 5G smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: rmkaplan @.> Sent: Friday, August 15, 2025 5:47:38 PM To: Interlisp/medley @.> Cc: Subscribed @.***> Subject: Re: [Interlisp/medley] (COPYFILE 'FOO;1 'FOO;1) for any FOO wipes out the contents (Issue #2238)
[https://avatars.githubusercontent.com/u/69548581?s=20&v=4]rmkaplan left a comment (Interlisp/medley#2238)https://github.com/Interlisp/medley/issues/2238#issuecomment-3193077179 Can it make 2 calls, asking separately for the high and low 32 bits of the file's id?
On Aug 15, 2025, at 3:13 PM, Nick Briggs @.***> wrote:
nbriggs left a comment (Interlisp/medley#2238) https://github.com/Interlisp/medley/issues/2238#issuecomment-3192878426 File system i-node numbers are 64-bit -- we don't have a 64-bit datatype in Lisp, and I don't know that we can pass more than a single pointer to a result through the FDEV GETFILEINFO method.
— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/2238#issuecomment-3192878426, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJJSDBCA2LWP64KP5Z33NZLPLAVCNFSM6AAAAACC3MOIUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJSHA3TQNBSGY. You are receiving this because you authored the thread.
— Reply to this email directly, view it on GitHubhttps://github.com/Interlisp/medley/issues/2238#issuecomment-3193077179, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB7BB4RVMG4S2GQQING2UND3NZ5SVAVCNFSM6AAAAACC3MOIUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOJTGA3TOMJXHE. You are receiving this because you are subscribed to this thread.Message ID: @.***>