delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2024/05/11/06:21:40

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Recipient: dj AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
mime-version; bh=rWtIEILQLHxTs7dE49dKCP40VxSdwMUOgZRPptjhZ6M=; b=F12vb09+vM08
DRjZf9BzxD2dvW2IlKrjOsdfXTV/xq5Oc57eo2NgKXGENxQiGc8WIymuU1rOLaeBc9OiERoDAhsto
Og+9oM4vnWgaj/I/Ie0nNgZE9ExKcta6t9QEMdmwlfzufspXw9thZFjXq1GDEobQKdqlpjdChxJ5g
0Ck+halrQr13c4AHWoFAxRldTCxgyw1pLCYl5jfqcSWl22jaRR/tE8Iu8mQrK+Yvozc88S/M5NgYx
PR/JOZvy6G+fawEJr8a8GMBH+h2AIT2NYM+OSF130T2QqVivu930JqzVj2sFoze5amSq7ls1aWEU/
GB6g7GRook6ASppnr+cZ1A==;
Date: Sat, 11 May 2024 13:21:05 +0300
Message-Id: <867cg03azy.fsf@gnu.org>
From: "Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
To: Pali <pali AT pali DOT im>, DJ Delorie <dj AT delorie DOT com>
Cc: djgpp AT delorie DOT com
In-Reply-To: <20240509182019.mrbfcyv4jhl3w34x@pali> (message from Pali on Thu,
9 May 2024 20:20:19 +0200)
Subject: Re: Fix passing fcntl and ioctl variadic arguments to file system
extension API
References: <20240509182019 DOT mrbfcyv4jhl3w34x AT pali>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Thu, 9 May 2024 20:20:19 +0200
> From: Pali <pali AT pali DOT im>
> Cc: djgpp AT delorie DOT com
> 
> Hello. I have there a change which fixes ioctl and fcntl functions when
> file descriptor uses file system extension API. These two functions are
> takes variadic arguments and file system extension API takes va_list
> structure with all corresponding arguments. djgpp code currently do not
> pass all arguments to API functions __FSEXT_ioctl and __FSEXT_fcntl.
> 
> My fix, which is below, uses __builtin_apply_args() which returns
> pointer to va_list-compatible structure of all arguments (including
> non-variadic). It works for djgpp i386 calling convention. It does not
> work on e.g. AMD64, but this is not a djgpp case which is 32-bit x86.
> For using __builtin_apply_args, it was required to manually inline
> __FSEXT_func_wrapper function as it takes variadic arguments and not
> va_list structure as the "func" itself.

ISTR that the rest of the arguments can be accessed because they are
on the stack.

Anyway, I'm not familiar with this code well enough to review these
patches, but I do know that the code is tricky because ioctl and fcntl
have "dynamic" signature, and the actual arguments depend on the
IOCTL/FCNTL function being invoked.  I hope someone else (DJ?) could
review the patches.  Sorry.

> And I have there small cleanup, which removes dead code in local static
> function _unix_ioctl. This function is called only when __FSEXT_ioctl
> rejected the call and there is no need to call __FSEXT_get_function()
> second time if the first time it returned NULL (no FSEXT).

maybe I'm misreading the code, but AFAIU it can call _unix_ioctl also
when FSEXT is non-NULL, but __FSEXT_func_wrapper returned zero.  So
I'm not sure this patch is correct.

Thanks.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019