aboutsummaryrefslogtreecommitdiff
path: root/slof
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-11-15 14:02:49 +0100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-11-24 23:24:23 +1100
commitabd21203aa27435e9e5248350dcaf14940de0947 (patch)
treec04bc273b66a792c819dff47a27204387b32df39 /slof
parent9290756ae1195b331373dbcfd3b37d978b3b71f4 (diff)
downloadSLOF-abd21203aa27435e9e5248350dcaf14940de0947.zip
SLOF-abd21203aa27435e9e5248350dcaf14940de0947.tar.gz
SLOF-abd21203aa27435e9e5248350dcaf14940de0947.tar.bz2
deblocker: Add a 'write' function
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. Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'slof')
-rw-r--r--slof/fs/packages/deblocker.fs21
1 files changed, 21 insertions, 0 deletions
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 +!
+;