[PATCH v4 1/1] ldconfig: add --install option

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Jun 9 11:26:09 GMT 2026



On 09/06/26 00:06, DJ Delorie wrote:
> Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
>> I tend to avoid sprintf, and we do have xasprintf:
> 
> It's what cache.c did.

Indeed, but I think xasprintf is slight simpler here.

> 
>>> +      dest_fd = open (dest, O_WRONLY, 0644);
>>
>> I think it requires O_CREAT, and the elf/cache.c:682 uses:
>>
>>   int fd = open (temp_name, O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW, S_IRUSR|S_IWUSR);
> 
> Fixed.
> 
>>> +      if (w < 0)
>>> +	{
>>> +	  unlink (dest);
>>> +	  close (dest_fd);
>>> +	  error (EXIT_FAILURE, errno, _("Error writing file %s"), dest);
>>> +	}
>>
>> I think there is no need to a loop here,
> 
> It's the way I've always done that, because on some OSs (including
> Linux), read and write can return a partial count if the program
> receives a signal.

Afaik we do not install a sighandler on ldconfig to catch possible partial
read/write due signal interruptions (which is the only case we can keep 
trying to copy the file). so I think any partial read/write would be better 
to be reported as an error.

> 
>> I really think we should add a testcase for this, something like:
> 
> May I include yours as-is?  And add you as co-author?
Sure.


More information about the Libc-alpha mailing list