Properly check return value from mount(2) and display error message

Found by Coverity Scan.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-03-05 10:15:46 +01:00
parent 621da582c2
commit cf3d3f6f8e
+9 -3
View File
@@ -179,7 +179,8 @@ static void fs_remount_root(int fsckerr)
* XXX: Untested, in the initramfs age we should
* probably use switch_root instead.
*/
rc = mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
if (mount(SYSROOT, "/", NULL, MS_MOVE, NULL))
_pe("Failed %s / MS_MOVE");
}
#endif /* SYSROOT */
@@ -218,8 +219,13 @@ static void fs_init(void)
};
size_t i;
for (i = 0; i < NELEMS(fs); i++)
mount(fs[i].spec, fs[i].file, fs[i].type, 0, NULL);
for (i = 0; i < NELEMS(fs); i++) {
int rc;
rc = mount(fs[i].spec, fs[i].file, fs[i].type, 0, NULL);
if (rc)
_pe("Failed mounting %s on %s", fs[i].spec, fs[i].file);
}
}
/*