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

DJ Delorie dj@redhat.com
Tue Jun 9 03:06:42 GMT 2026


Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
> I tend to avoid sprintf, and we do have xasprintf:

It's what cache.c did.

>> +      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.

> I really think we should add a testcase for this, something like:

May I include yours as-is?  And add you as co-author?



More information about the Libc-alpha mailing list