From patchwork Wed Nov 9 15:43:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 692834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tDVpG38bNz9vFF for ; Thu, 10 Nov 2016 02:43:50 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tDVpG0RQXzDvNV for ; Thu, 10 Nov 2016 02:43:50 +1100 (AEDT) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tDVp80fL4zDvHw for ; Thu, 10 Nov 2016 02:43:44 +1100 (AEDT) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 726D63D955; Wed, 9 Nov 2016 15:43:42 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA9Fhc8F010122; Wed, 9 Nov 2016 10:43:41 -0500 From: Thomas Huth To: slof@lists.ozlabs.org Date: Wed, 9 Nov 2016 16:43:35 +0100 Message-Id: <1478706218-8935-2-git-send-email-thuth@redhat.com> In-Reply-To: <1478706218-8935-1-git-send-email-thuth@redhat.com> References: <1478706218-8935-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 09 Nov 2016 15:43:42 +0000 (UTC) Subject: [SLOF] [PATCH 1/4] deblocker: Add a 'write' function X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 Reviewed-by: Nikunj A Dadhania --- 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 +! +;