Subject: [bug#34863] [WIP] syscalls: Add loop device interface.

From: Ludovic Courtès <[email-masked]>
Date: Sat, 16 Mar 2019 11:18:12 +0100

Hi!

Danny Milosavljevic <[email-masked]> skribis:

>> +(define (set-loop-device-status loop-file status)
>> +  (let ((buf (make-bytevector sizeof-loop-info64)))
>> +    (apply write-loop-info64! buf status) ; TODO: Be more user-friendly.
>
> I don't know how instantiate a C structure given an assoc list.  Help?

You have to extract the fields from STATUS and then pass them in the
right order to ‘write-loop-info64!’:

  (let-syntax ((field (syntax-rules ()
                        ((_ field) (assoc-ref status 'field)))))
    (write-loop-info64! buf (field lo-device) (field lo-inode)
                        (field lo-rdevice) …))

However, given the number of fields, you might want to define a Scheme
record type, as is done for ‘%statfs’ and <file-system>.

HTH!

Ludo’.