From: Andrew Burgess <aburgess@redhat.com>
To: Abhay Kandpal <abhay@linux.ibm.com>, gdb-patches@sourceware.org
Cc: Ulrich.Weigand@de.ibm.com, eliz@gnu.org, cel@linux.ibm.com,
abhay.k@ibm.com, Abhay Kandpal <abhay@linux.ibm.com>
Subject: Re: [PATCH v4 1/2] gdbserver: widen the stat fields returned by the vFile packets
Date: Tue, 03 Nov 2026 16:27:24 +0000 [thread overview]
Message-ID: <877bit7udv.fsf@redhat.com> (raw)
In-Reply-To: <20261029092124.233055-2-abhay@linux.ibm.com>
Abhay Kandpal <abhay@linux.ibm.com> writes:
> @@ -48816,6 +48831,41 @@ Note that due to size differences between the host, target, and protocol
> representations of @code{struct stat} members, these members could eventually
> get truncated on the target.
>
> +@node struct stat64
> +@unnumberedsubsubsec struct stat64
> +@cindex struct stat64, in file-i/o protocol
> +
> +When the @samp{stat64} feature has been negotiated, the buffer returned
> +by the @samp{vFile:fstat}, @samp{vFile:stat} and @samp{vFile:lstat}
> +packets uses the following representation instead:
> +
> +@smallexample
> +struct stat64 @{
> + uint64_t st_dev; /* device */
> + uint64_t st_ino; /* inode */
> + mode_t st_mode; /* protection */
> + uint64_t st_nlink; /* number of hard links */
> + unsigned int st_uid; /* user ID of owner */
> + unsigned int st_gid; /* group ID of owner */
> + uint64_t st_rdev; /* device type (if inode device) */
> + uint64_t st_size; /* total size, in bytes */
> + uint64_t st_blksize; /* blocksize for filesystem I/O */
> + uint64_t st_blocks; /* number of blocks allocated */
> + uint64_t st_atime; /* time of last access */
> + uint64_t st_mtime; /* time of last modification */
> + uint64_t st_ctime; /* time of last change */
> +@};
> +@end smallexample
In the '@node strut stat' we have this text:
The integral datatypes conform to the definitions given in the
appropriate section (see @ref{Integral Datatypes}, for details) so this
structure is of size 64 bytes.
The 'Integral Datatypes' section gives some definitions for on the wire
data types. uint64_t is not defined here, but 'long' and 'unsigned
long' are defined as the 64-bit type. I think you should update the
struct definition here to use the existing type. It might be a good
idea to include that same boilerplate paragraph, but with the size
updated from 64 to 92.
> @@ -179,19 +204,27 @@ host_to_bigendian (LONGEST num, char *buf, int bytes)
> buf[i] = (num >> (8 * (bytes - i - 1))) & 0xff;
> }
>
> -/* Pack a host-format integer into an fio_uint_t. */
> +/* Pack a host-format integer into an fio_uint_t, warning if the value
> + does not fit. */
>
> static inline void
> host_to_fileio_uint (long num, fio_uint_t fnum)
> {
> + if ((ULONGEST) num > 0xffffffff)
> + warning (_("file-i/o: value %s does not fit in 32 bits and will be "
> + "truncated"), plongest (num));
I have similar feedback to Ulrich here, but reach a slightly different
conclusion. I also see an additional problem in addition to the
truncation that Ulrich pointed out, on hosts where 'long' is 4-bytes,
this warning could trigger incorrectly. A 32-bit negative value with
the top bit set, when sign-extended to a 64-bit unsigned will have all
of the top 32-bits set, which will trigger this warning when it
shouldn't.
My gut says that host_to_fileio_uint should take NUM as ULONGEST, it's
mostly being called for unsigned fields anyway.
We can always add an additional helper host_to_fileio_int which takes a
LONGEST for signed fields.
Thanks,
Andrew
next prev parent reply other threads:[~2026-11-03 16:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 9:21 [PATCH v4 0/2] Widen the stat fields in the remote protocol Abhay Kandpal
2026-10-29 9:21 ` [PATCH v4 1/2] gdbserver: widen the stat fields returned by the vFile packets Abhay Kandpal
2026-10-29 16:56 ` Ulrich Weigand
2026-11-02 6:29 ` Abhay Kandpal
2026-11-03 16:27 ` Andrew Burgess [this message]
2026-10-29 9:21 ` [PATCH v4 2/2] gdb: add stat64 and fstat64 to the F-packet file-i/o protocol Abhay Kandpal
2026-11-03 17:31 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877bit7udv.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=abhay.k@ibm.com \
--cc=abhay@linux.ibm.com \
--cc=cel@linux.ibm.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox