[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#34863] [WIP] syscalls: Add loop device interface.
From: |
Ludovic Courtès |
Subject: |
[bug#34863] [WIP] syscalls: Add loop device interface. |
Date: |
Wed, 10 Apr 2019 16:56:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Ping! :-)
Ludovic Courtès <address@hidden> skribis:
> Hello,
>
> Danny Milosavljevic <address@hidden> skribis:
>
>> On Sat, 16 Mar 2019 11:29:17 +0100
>> Ludovic Courtès <address@hidden> 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’.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug#34863] [WIP] syscalls: Add loop device interface.,
Ludovic Courtès <=