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 committed 2021-03-05 10:15:46 +01:00
1 parent 621da582c2
commit cf3d3f6f8e
1 file changed
+9 -3
+9 -3
View File
@@ -179,7 +179,8 @@ static void fs_remount_root(int fsckerr)
* XXX: Untested, in the initramfs age we should * XXX: Untested, in the initramfs age we should
* probably use switch_root instead. * 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 */ #endif /* SYSROOT */
@@ -218,8 +219,13 @@ static void fs_init(void)
}; };
size_t i; size_t i;
for (i = 0; i < NELEMS(fs); i++) for (i = 0; i < NELEMS(fs); i++) {
mount(fs[i].spec, fs[i].file, fs[i].type, 0, NULL); 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);
}
} }
/* /*