[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mountlist: libmount support on Linux

From: Eric Blake
Subject: Re: mountlist: libmount support on Linux
Date: Wed, 27 Aug 2014 13:06:02 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

On 08/27/2014 10:15 AM, Pádraig Brady wrote:
> On 08/27/2014 03:08 PM, Fridolin Pokorny wrote:
>> diff --git a/lib/mountlist.c b/lib/mountlist.c
> Cool, this fits well.
> It would be good to mention the functionality and
> performance benefits in the changelog.
>> +static const char *
>> +mountinfo_path (void) {
>> +  static char filename[sizeof ("/proc//mountinfo") + 13]; /* 13 to hold a 
>> PID */

The magic number 13 is gross, compared to using <intprops.h> from gnulib
and using INT_STRLEN_BOUND(pid_t) (which should evaluate to 13) instead.

>> +
>> +  sprintf (filename, "/proc/%u/mountinfo", getpid ());
>> +
>> +  return filename;
>> +}
> I dislike the above as it precludes concurrent usage.
> You could avoid that issue by allocating on the heap,

or by setting up a witness so that sprintf is called only once by the
first caller, and all later callers wait until the first caller is complete.

> but can't this be simplified by using /proc/self/mountinfo ?

The argument here was that the kernel is slightly slower in order to
resolve the symlink of /proc/self in all cases - but is that penalty
going to be noticeable?

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]