[SLOF] [PATCH 1/4] deblocker: Add a 'write' function
Nikunj A Dadhania
nikunj at linux.vnet.ibm.com
Mon Nov 14 17:36:28 AEDT 2016
Thomas Huth <thuth at redhat.com> writes:
> To support block writes, the deblocker should feature a 'write'
> function, too. Since our only client that tries to use write
> accesses so far (GRUB2) is always writing whole sectors, we
> do not do the complicated read-modify-write dance here yet, but
> simply check that the client always tries to write whole sectors.
>
> Signed-off-by: Thomas Huth <thuth at redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
> ---
> slof/fs/packages/deblocker.fs | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/slof/fs/packages/deblocker.fs b/slof/fs/packages/deblocker.fs
> index 83cd712..ebed5cf 100644
> --- a/slof/fs/packages/deblocker.fs
> +++ b/slof/fs/packages/deblocker.fs
> @@ -68,3 +68,24 @@ INSTANCE VARIABLE fail-count
> my-block @ adr @ len @ move THEN
>
> r> ;
> +
> +: write-blocks ( addr block# #blocks -- #writtenblks )
> + s" write-blocks" $call-parent
> +;
> +
> +: write ( addr len -- actual )
> + dup block-size @ mod IF
> + ." ERROR: Can not write partial sector length." cr
> + 2drop 0 EXIT
> + THEN
> + block-size @ / ( addr #blocks )
> + offset @ ( addr #blocks offset )
> + dup block-size @ mod IF
> + ." ERROR: Can not write at partial sector offset." cr
> + 3drop 0 EXIT
> + THEN
> + block-size @ / swap ( addr block# #blocks )
> + write-blocks ( #writtenblks )
> + block-size @ *
> + dup offset +!
> +;
> --
> 1.8.3.1
More information about the SLOF
mailing list