From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br3dv-00008W-LR for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br3dp-0002vn-Ki for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:50:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br3dp-0002v8-ED for qemu-devel@nongnu.org; Mon, 03 Oct 2016 09:50:49 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 E3402624A5 for ; Mon, 3 Oct 2016 13:50:48 +0000 (UTC) Date: Mon, 3 Oct 2016 15:50:45 +0200 From: =?UTF-8?B?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= Message-ID: <20161003155045.6889f89d@fiorina> In-Reply-To: <806811cc-5788-a93c-43a3-59271b2cdfbb@redhat.com> References: <20160920113759.23a1ee06@fiorina> <806811cc-5788-a93c-43a3-59271b2cdfbb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Paolo Bonzini , qemu-devel@nongnu.org Whops, somehow I completely forgot about this. On Tue, 20 Sep 2016 09:09:59 -0500 Eric Blake wrote: > On 09/20/2016 04:37 AM, Tom=C3=A1=C5=A1 Golembiovsk=C3=BD wrote: >=20 > [meta-comment]: Your series came through without any threading (you sent > three threads, instead of patch 1 and 2 being marked In-Reply-To the 0/2 > cover letter). Thanks for the comment. Unfortunately it was my email client interfering. It should be better next time. > > When --offset is set the apparent device size has to be adjusted > > accordingly. Otherwise client may request read/write beyond the file end > > which would fail. > >=20 > > Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD > > --- > > qemu-nbd.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > >=20 > > diff --git a/qemu-nbd.c b/qemu-nbd.c > > index 99297a5..629bce1 100644 > > --- a/qemu-nbd.c > > +++ b/qemu-nbd.c > > @@ -901,6 +901,13 @@ int main(int argc, char **argv) > > exit(EXIT_FAILURE); > > } =20 >=20 > Additional context: >=20 > off_t dev_offset =3D 0; >=20 > off_t fd_size; >=20 > > =20 > > + if (dev_offset >=3D fd_size) { > > + error_report("Offset (%lu) has to be smaller than the image si= ze (%lu)", > > + dev_offset, fd_size); =20 >=20 > Whoops, this fails to compile on 32-bit platforms. %lu is not > necessarily synonymous with off_t values. After some digging I figured off_t is in fact signed type. That makes the formatting wrong everywhere. Unfortunately I didn't find any good definition of the type. Any suggestion what format flag should I use? Or should I just use a temporary variable of known size for that? Thanks, Tomas --=20 Tom=C3=A1=C5=A1 Golembiovsk=C3=BD