#15 Use gnulib mountlist to support systems without getmntent(3)
Opened 14 years ago by raimue. Modified 6 years ago

updatedb currently uses getmntent(3) to retrieve the list of mounted filesystems. This library function is not standardized and not available on all systems. Here is a patch to use the gnulib mountlist module instead.

The mountlist module does not provide access to the mount flags, making it impossible to prune bind mounts. Therefore it is only used if getmntent(3) is not available. Note that there is usually no support for mount --bind on non-linux systems anyway.

This patch has successfully been tested on:
* Mac OS X 10.6.2
* Debian Linux 5.0.4 (lenny)


Thanks for the patch. It probably needs more testing - AFAICS it does:

{{{
me = read_file_system_list(true);
while (me != NULL)
....
}}}

without ever advancing "me".

Also, I wonder if the result would be cleaner if all #ifdefs were concentrated near callers.

Perhaps
{{{

ifdef HAVE_GETMNTENT

}}}
... definitions for bind mounts

{{{

else / not HAVE_GETMNTENT /

define init_bind_mount_paths() (void)0

}}}
... and so on...

{{{

endif / not HAVE_GETMNTENT /

}}}

or use static functions for the alternatives, or perhaps push the #ifdefs inside functions. In any case, so many #ifdefs in callers should not be needed.

Replying to [comment:1 mitr]:

Thanks for the patch. It probably needs more testing - AFAICS it does:

{{{
me = read_file_system_list(true);
while (me != NULL)
....
}}}

without ever advancing "me".

Oops, that is a mistake. Sorry, probably the line got lost in final reformatting of the code. Will attach a revised patch.

Also, I wonder if the result would be cleaner if all #ifdefs were concentrated near callers.
...
or use static functions for the alternatives, or perhaps push the #ifdefs inside functions. In any case, so many #ifdefs in callers should not be needed.

Alright. filesystem_is_excluded() could also be converted to use gnulib only, although I wanted to be least intrusive to the existing code. The difference would be that gnulib mountlist always relies on _PATH_MOUNTED and does not use mount info from /proc.

Also I noticed that the memory allocated by read_file_system_list() needs to be released after use.

Revised patch with mount_entry pointer advance
mlocate-mountlist-hg.2.diff

I'm sorry about the terribly late response

Replying to [comment:2 raimue]:

Replying to [comment:1 mitr]:
Alright. filesystem_is_excluded() could also be converted to use gnulib only, although I wanted to be least intrusive to the existing code. The difference would be that gnulib mountlist always relies on _PATH_MOUNTED and does not use mount info from /proc.
Right, using /proc is actually important (as mentioned in the comment about NFS).

Also I noticed that the memory allocated by read_file_system_list() needs to be released after use.
It does need to be released. Care to update the patch?

The attachments for this issue (#15) seem to be missing - the links just lead to 404 error pages. I realize they are old and need more work; but are they available anywhere?

Thank you.

I don’t have any other copy I’m afraid.

It might be possible to get them from backups per https://fedoraproject.org/wiki/Infrastructure/Fedorahosted-retirement .

Metadata Update from @mitr:
- Issue close_status updated to: None

6 years ago

Sorry that I never continued the work on this patch, but my focus shifted elsewhere.

I do not seem to have the originally submitted patch any more, but after some digging in the backups I found a mercurial checkout that still has this change. I am attaching an export of the changesets.

mlocate-mountlist-hg-recovered.diff

Sorry that I never continued the work on this patch, but my focus shifted elsewhere.
I do not seem to have the originally submitted patch any more, but after some digging in the backups I found a mercurial checkout that still has this change. I am attaching an export of the changesets.

Thank you very much for digging that up!

Login to comment on this ticket.

Metadata
Attachments 1