Message ID | 1478706218-8935-2-git-send-email-thuth@redhat.com |
---|---|
State | Changes Requested |
Headers | show |
Thomas Huth <thuth@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@redhat.com> Reviewed-by: Nikunj A Dadhania <nikunj@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
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 +! +;
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@redhat.com> --- slof/fs/packages/deblocker.fs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)