[PATCH v2 08/13] support: Add support_count_maps

Florian Weimer fweimer@redhat.com
Fri Nov 29 13:35:00 GMT 2024


* Adhemerval Zanella Netto:

>> +#include <support/support.h>
>> +#include <support/check.h>
>> +#include <support/xstdio.h>
>> +#include <errno.h>
>> +
>> +size_t
>> +support_count_maps (void)
>> +{
>
> Maybe add a support_need_proc().
>
>> +  FILE *fp = fopen ("/proc/self/maps", "r");
>> +  if (fp == NULL)
>> +    {
>> +      if (errno == ENOENT)
>> +        FAIL_UNSUPPORTED ("support_count_maps: test needs /proc/self/maps");
>> +      else
>> +        FAIL_EXIT1 ("cannot open /proc/self/maps: %m");
>> +    }
>
> And then you can just use xfopen here.

I don't know if Hurd has /proc/self/maps (but it has other parts of
/proc).

Thanks,
Florian



More information about the Libc-alpha mailing list