[libdvdnav-devel] [PATCH 3/7] Use correct constant

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri May 22 12:47:46 CEST 2015


On Fri, 22 May 2015 13:01:22 +0300, Petri Hintukainen wrote:

> On to, 2015-05-21 at 22:44 +1200, Lawrence D'Oliveiro wrote:
>
>> On Thu, 21 May 2015 11:36:58 +0300, Petri Hintukainen wrote:
>> 
>>> In most Unix-like systems trailing slash must be removed or mount
>>> point search won't work.
>> 
>> I had a look at the source for the mountpoint(1) command, and it
>> will work regardless of trailing slashes or repeated slashes.
> 
> dvd_reader.c uses getmntent() + strcmp(). That will fail if the
> strings are not the same (= extra slashes etc.).

This seems
<http://manpages.ubuntu.com/manpages/hardy/man3/getmntent.3.html> to be
specific to glibc. Here is an extract from mountpoint(1) (source:
<https://packages.debian.org/jessie/initscripts>), where “path” is the
string the user typed:

    memset(buf, 0, sizeof(buf));
    strncpy(buf, path, sizeof(buf) - 4);
    strcat(buf, "/..");
    if (dostat(buf, &st2, 0, quiet) < 0)
        return 1;

    r = (st.st_dev != st2.st_dev) ||
        (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino);

    if (!quiet && !showdev)
        printf("%s is %sa mountpoint\n", path, r ? "" : "not ");
 
As you can see, that should be more robust, as well as being more
portable.


More information about the libdvdnav-devel mailing list