[Rpm-maint] [rpm-software-management/rpm] debugedit: Distinguish files from directories in src list file (#1436)
Mark Wielaard
mark at klomp.org
Sun Nov 15 20:28:00 UTC 2020
Hi,
On Sun, 2020-11-15 at 07:20 -0800, Vitalio wrote:
> Append '/' to directories in source file list (for `-l'
> option) to allow
> quickly distinguish them from regular files (to avoid adding them raw
> into %files section). This is needed for ALT for our debuginfo
> processing to speed things up.
I understand you would like to make sure all comp_dirs end with a
trailing '/' character. But I don't think unconditionally adding a '/'
is the right thing to do:
> diff --git a/tools/debugedit.c b/tools/debugedit.c
> index c2884933c..2eb912c72 100644
> --- a/tools/debugedit.c
> +++ b/tools/debugedit.c
> @@ -1923,7 +1923,7 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
> const char *p = skip_dir_prefix (comp_dir, base_dir);
> if (p != NULL && p[0] != '\0')
> {
> - size_t size = strlen (p) + 1;
> + size_t size = strlen (p);
> while (size > 0)
> {
> ssize_t ret = write (list_file_fd, p, size);
> @@ -1932,6 +1932,10 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
> size -= ret;
> p += ret;
> }
> + /* Output trailing dir separator to distinguish them quickly from
> + regular files. */
> + if (size == 0)
> + write (list_file_fd, "/", 2);
> }
> }
Note for others, the list_file contains zero terminated file names.
That is why we want to write size = strlen (p) + 1 characters, so that
it includes the '\0' terminator.
After the while loop size is always zero, unless an error occurred and
not all characters were written. So this code would add a "/"
(including a termination '\0') always, even if there was already one.
So I think you actually want to test that p[0] != '/' before adding the
string "/", but just write (list_file_fd, "", 1) otherwise.
BTW. How does this help you speed things up?
Cheers,
Mark
More information about the Rpm-maint
mailing list