unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 34863@debbugs.gnu.org
Subject: [bug#34863] [WIP] syscalls: Add loop device interface.
Date: Tue, 21 May 2019 16:51:22 +0200	[thread overview]
Message-ID: <87v9y3zwr9.fsf@gnu.org> (raw)
In-Reply-To: <87wokwshdv.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 18 Mar 2019 09:42:36 +0100")

Ping!  :-)

Ludovic Courtès <ludo@gnu.org> skribis:

> Hello,
>
> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
>> On Sat, 16 Mar 2019 11:29:17 +0100
>> Ludovic Courtès <ludo@gnu.org> wrote:
>>
>>> What will be the use for this?  I prefer to make sure we only add code
>>> that is actually going to be used.  :-)
>>
>> See "boot multiple Gnu/Linux Distributions from one USB key" on the guix-devel
>> list.  This would make it possible to loop-mount stuff at boot.
>
> Oh OK (too much mail!).
>
>>> > +      (open-io-file (string-append "/dev/loop" (number->string ret))))  
>>> 
>>> I didn’t know about ‘open-io-file’ and indeed, it’s undocumented.  So
>>> I’d suggest using ‘open-file’ instead to be on the safe side.
>>
>> Do you mean 
>>
>>   open-file ... "r+"
>>
>> ?
>
> Exactly.
>
>>>Note that BACKING-FILE, the port, can be closed when it’s GC’d, which as
>>>a side effect would close its associated file descriptor.  Is this OK or
>>>does the FD have to remain open for the lifetime of the loopback device?
>>
>> I don't know, but guess it's okay for it to be closed again (the
>> "losetup" process doesn't keep running for long either and the loop device
>> is fine).
>
> It’d be good to double-check.  :-)
>
>>> > +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loop-control"))))
>>> > +  (set-loop-device-backing-file loop-device (open-input-file "tests/syscalls.scm"))
>>> > +  (set-loop-device-status loop-device (get-loop-device-status loop-device)))  
>>> 
>>> You’re missing a ‘test-assert’ or similar.  
>>
>> What would I be asserting?  I found no function to test whether an
>> exception was raised or not (or to just assert that no exception was
>> raised).  So I resorted to that.
>
> Tests always need to be enclosed in a ‘test-XYZ’ form.  Otherwise it’s
> code that’s evaluated as the top level and that’s not listed in the test
> log.
>
> So in this case, to check for a 'system-error exception, you could do, say:
>
>   (test-equal "foo"
>     ENOENT
>     (catch 'system-error
>       (lambda () … #f)
>       (lambda args
>         (system-error-errno args))))
>
> There are examples of that in ‘tests/syscalls.scm’.
>
> HTH!
>
> Ludo’.

      parent reply	other threads:[~2019-05-21 14:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 22:08 [bug#34863] [WIP] syscalls: Add loop device interface Danny Milosavljevic
2019-03-15 16:13 ` Danny Milosavljevic
2019-03-16 10:18   ` Ludovic Courtès
2019-03-16 10:29 ` Ludovic Courtès
2019-03-16 11:17   ` Danny Milosavljevic
2019-03-18  8:42     ` Ludovic Courtès
2019-04-10 14:56       ` Ludovic Courtès
2019-05-21 14:51       ` Ludovic Courtès [this message]

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://guix.gnu.org/

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

  git send-email \
    --in-reply-to=87v9y3zwr9.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=34863@debbugs.gnu.org \
    --cc=dannym@scratchpost.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/guix.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).