From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69987 invoked by alias); 17 May 2018 14:36:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 69328 invoked by uid 89); 17 May 2018 14:36:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=gary, Gary, B3, b3 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 May 2018 14:36:26 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E7EE401EF08; Thu, 17 May 2018 14:36:25 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 728B0D74C6; Thu, 17 May 2018 14:36:24 +0000 (UTC) Subject: Re: [PATCH] Do not clear the value of st_dev in File I/O's stat() To: Julio Guerra , "gdb-patches@sourceware.org" References: <20180517082631.26855-1-julio@farjump.io> <010201636d368a34-7edcde92-3661-4c9a-94b4-a894b9c8e90a-000000@eu-west-1.amazonses.com> From: Pedro Alves Cc: Corinna Vinschen Message-ID: <9445cc6c-a954-7cdf-d0dc-47a18e596db3@redhat.com> Date: Thu, 17 May 2018 15:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <010201636d368a34-7edcde92-3661-4c9a-94b4-a894b9c8e90a-000000@eu-west-1.amazonses.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-05/txt/msg00381.txt.bz2 [Hi Corinna, adding you in case you still happen to remember any of this and have any input. If not, that's fine.] On 05/17/2018 09:28 AM, Julio Guerra wrote: > Do not clear the value of st_dev in the fileio stat structure sent to the > target. It prevents from being able to check the file type on the target. > Note that the fileio function fstat `remote_fileio_func_fstat()` doesn't clear > this field. Curious. This looked like was written in a way like you'd write if you had a reason to so I did some archaeology to try to find what it was, see if the reason is still valid. I found the original File I/O protocol proposal here: https://www.sourceware.org/ml/gdb/2002-11/msg00107.html and in there, in the intro, it said: ~~~~~ The protocol is only used for files on the host file system and for I/O on the console. Character or block special devices, pipes, named pipes or sockets or any other communication method on the host system are not supported by this protocol. ~~~~~ and further below, in "B.3 struct stat", it says: ~~~~~ The values of several fields have a restricted meaning and/or range of values. st_dev: 0 file 1 console ~~~~~ And the current manual also says: @item st_dev A value of 0 represents a file, 1 the console. And it looks like early on, in: https://sourceware.org/ml/gdb-patches/2003-03/msg00221.html we had: +static void +remote_fileio_to_fio_stat (struct stat *st, struct fio_stat *fst) +{ + /* `st_dev' is set in the calling function */ + remote_fileio_to_fio_uint ((long) st->st_ino, fst->fst_ino); Note the comment. I can't find the comment in the current sources, but it was there up until: commit 791c00567a7ccbae3d71e3b63ac43c0b555079dc Author: Gary Benson AuthorDate: Wed Mar 11 17:53:57 2015 +0000 Move remote_fileio_to_fio_stat to gdb/common and note that remote_fileio_func_fstat still does: if (fd == FIO_FD_CONSOLE_IN || fd == FIO_FD_CONSOLE_OUT) { host_to_fileio_uint (1, fst.fst_dev); ^^^ "fstat" was only added later on, along the work that Gary did around that commit above, for this series: https://sourceware.org/ml/gdb-patches/2015-03/msg00286.html ... which introduced "fstat" in the protocol, and in that case, the 0/1 st_dev issue was either missed or ignored, so fstat is not following the documented values. Now I'm not sure what to do. If we let the real st_dev through, what shall we fill it in, in the "console" files case? > > 2018-05-16 Julio Guerra > > * remote-fileio.c: do not clear the value of st_dev in File I/O's stat(). Nit, you'd write: gdb/ChangeLog: 2018-05-16 Julio Guerra * remote-fileio.c (remote_fileio_func_stat): Do not clear the value of st_dev. Thanks, Pedro Alves