Some code fix suggestions in mountall.c
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mountall (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: mountall
Until I discover I'm affected by the bug #430542, I looked mountall's source code during several hours in order to learn how to get my system bootable again. I got my computer working again by changing my "/etc/fstab".
But... I think there are 2 things to be improved in mountall-0.1.6.
-------
The function "cleanup" (src/mountall.
But there is a problem here: some file system types are implemented by kernel modules. These modules may not be loaded into kernel yet, so those file system types won't appear in /proc/filesystem. But, unfortunately, the function "parse_filesystems" don't try to check if unknown file system types could be implemented by not-loaded modules. As a result, "cleanup" drops mount entries which should be mounted.
This is my first suggestion: the function "cleanup" should try to load file system modules before discarding invalid mount entries.
-------
First, a code example:
// File "test.c" begin
#include <assert.h>
int main (void) {
int test = 1;
assert (test--);
return (test);
}
// File "test.c" end
Build the code with these command lines:
$ gcc -o test_a test.c
$ gcc -DNDEBUG -o test_b test.c
Run these executables:
$ ./test_a ; echo $?
$ ./test_b ; echo $?
You will see the decrement is not executed when NDEBUG is defined (test_b).
Such problem may happen in several lines within mountall.c:
1165: nih_assert (i++ < num_paths);
1675: nih_assert (i++ < num_paths);
1717: nih_assert (i++ < num_paths);
2325: nih_assert (udev = udev_new ());
2326: nih_assert (udev_monitor = udev_monitor_
2327: nih_assert (udev_monitor_
2328: nih_assert (udev_monitor_
Perhaps, such errors don't happen now, because "nih_assert" is always compiled. But, in the future, some developer may implement a macro that affects nih_assert() just like NDEBUG affects assert()... If this day comes, the code will break...
This is my second suggestion: change the assertion lines. By example:
1165: nih_assert (i++ < num_paths);
Change to:
1165: nih_assert (i < num_paths); i++;
cleanup only discards filesystem entries where device is NULL, ie. builtins - these are required to be built-in, and is used to implement the architecture- dependent filesystems like spufs
This will never remove a mount record for a filesystem specified in fstab or found from mountinfo