From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5B3F2D8006B for ; Thu, 24 Aug 2023 23:39:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UMoA6pctAYJfv2s2yvYm8doYKZM+EDjQ64YxmP9L7+A=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1692920379; v=1; b=thYlpciydO5uXBTZ2qtgjbBLexuCmJdbs6v7mpO6/0uhehf77PL9JjsA//NFIW7bFvu0M2wE 78yGzRDFSuFXdOpibp/way2WXJrbIhiSh0vm062o0CYcvQMYFq06cdmg8iKOxIWmwAHFAUr+XNp dK8BPM5dzOkwpdO4e6wjTdcQ= X-Received: by 127.0.0.2 with SMTP id t7n3YY7687511xRGfIdyDZ2v; Thu, 24 Aug 2023 16:39:39 -0700 X-Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by mx.groups.io with SMTP id smtpd.web11.2495.1692920377960753502 for ; Thu, 24 Aug 2023 16:39:38 -0700 X-Received: by mail-vs1-f49.google.com with SMTP id ada2fe7eead31-44dbd5011beso188351137.1 for ; Thu, 24 Aug 2023 16:39:37 -0700 (PDT) X-Gm-Message-State: gMS5eaW1tJ1luRcsCnOtV018x7686176AA= X-Google-Smtp-Source: AGHT+IG1HnHP7KWfIs+8LlhkegUwUBA+gOmzmnYbbIGBznAITB7XHJAN7osWGXKgFDtowgpJrEyv4Cct6dEW4e4pLXI= X-Received: by 2002:a67:ef90:0:b0:44d:5c17:d067 with SMTP id r16-20020a67ef90000000b0044d5c17d067mr9161115vsp.8.1692920376803; Thu, 24 Aug 2023 16:39:36 -0700 (PDT) MIME-Version: 1.0 References: <20230824163405.1386-1-n.jayaprakash@intel.com> <20230824163405.1386-2-n.jayaprakash@intel.com> In-Reply-To: <20230824163405.1386-2-n.jayaprakash@intel.com> From: "Pedro Falcato" Date: Fri, 25 Aug 2023 00:39:26 +0100 Message-ID: Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix console jump to 0, 0 issue in lseek() To: devel@edk2.groups.io, n.jayaprakash@intel.com Cc: Rebecca Cran , Michael D Kinney , Kloper Dimitry Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=thYlpciy; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) On Thu, Aug 24, 2023 at 5:34=E2=80=AFPM Jayaprakash, N wrote: > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4531 > > Python code opens console file descriptor and uses lseek() > with position =3D=3D 0 and SEEK_CUR as > 'do nothing, check console is alive' operation. > > Current implementation of daConsole ignores whence argument, > this is wrong in case lseek(0, SEEK_CUR) will send cursor to (0,0). > This fix is not generic, but solves the particular situation. > > Cc: Rebecca Cran > Cc: Michael D Kinney > Cc: Jayaprakash N > Signed-off-by: Kloper Dimitry > --- > StdLib/LibC/Uefi/Devices/Console/daConsole.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/StdLib/LibC/Uefi/Devices/Console/daConsole.c b/StdLib/LibC/U= efi/Devices/Console/daConsole.c > index 56571af..ba031d6 100644 > --- a/StdLib/LibC/Uefi/Devices/Console/daConsole.c > +++ b/StdLib/LibC/Uefi/Devices/Console/daConsole.c > @@ -141,8 +141,16 @@ da_ConSeek( > EFIerrno =3D RETURN_UNSUPPORTED; > return -1; > } > - // Everything is OK to do the final verification and "seek". > + > Proto =3D (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Stream->Dev; > + > + if(Position =3D=3D 0 && whence =3D=3D SEEK_CUR) { > + CursorPos.XYpos.Column =3D (UINT32)Proto->Mode->CursorColumn; > + CursorPos.XYpos.Row =3D (UINT32)Proto->Mode->CursorRow; > + return CursorPos.Offset; > + } > + > + // Everything is OK to do the final verification and "seek". > CursorPos.Offset =3D Position; > > EFIerrno =3D Proto->SetCursorPosition(Proto, > -- > 2.40.0.windows.1 ttys are historically not seekable devices. per Linux lseek(2): "On Linux, using lseek() on a terminal device fails with the error ESPIPE" So this function (and consequently this patch) is wrong. --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108025): https://edk2.groups.io/g/devel/message/108025 Mute This Topic: https://groups.io/mt/100938751/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-