Re: bug: :if-exists :append

Jean Louis <[email protected]>
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
Hello,

Thank you, I understand it.

On Mon, Feb 13, 2017 at 01:51:10PM -0500, Sam Steingold wrote:
> When I click on "Create Ticket" on https://sourceforge.net/p/clisp/bugs/,
> I am redirected to https://sourceforge.net/p/clisp/bugs/new/
> What happens to you?

I guess I don't have account there. I have account only on mailing
list. Not that I am fond of sourceforge especially for GNU projects.

OK, if you happen to know how to get file descriptor by sys:: let me
know. Or how to append to file which is chattr +a

I have tried that with SBCL and it appended to the file, the technical
stuff behind it is well explained from your side, on my side, I can
just observe what happened, cannot observe it. Now I am using shell
echo ~a >> to the file.

Jean

> IOW, to open your `chattr +a` file, we need to pass `O_APPEND` to `open(2)`.
> However, this will break this code:
> 
> --8<---------------cut here---------------start------------->8---
> (with-open-file (s "my-append-only-file" :direction :output :if-exists :append)
>   (let ((pos (file-position s)))
>     (write-string "foo" s)
>     (file-position s (- pos 3))
>     (write-string "bar" s)))
> --8<---------------cut here---------------end--------------->8---
> 
> ANSI CL mandates that this appends 3 chars "bar" to
> "my-append-only-file".
> However, if "my-append-only-file" was opened with `O_APPEND`, it will
> actually append 6 chars "foobar".
> 
> It is not clear to me what to do here:
> 
> * `file-position' can detect that the file is O_APPEND and return nil -
>   this is a functionality loss in many ways - e.g., we cannot scroll
>   back and read an O_RDWR|O_APPEND file.
> 
> * Accept that the code above will not do what the user expects for
>   ___SOME___ streams.
> 
> * Add another `:direction' option -- `:unix-append' which will use
>   `O_APPEND'.
> 
> I think the best course of action if the last one - it will be backwards
> compatible and will not violate too many expectations.
> 
> For now the only course of action is to use FFI or syscall (not sure if
> it can do that) to get a raw file descriptor and then wrap it into a
> Lisp stream using [`make-stream`](http://clisp.org/impnotes/make-stream.html).

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.