summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/NEWS3
-rw-r--r--mdk-stage1/mount.c14
2 files changed, 14 insertions, 3 deletions
diff --git a/mdk-stage1/NEWS b/mdk-stage1/NEWS
index 86113ece8..2899d7a9c 100644
--- a/mdk-stage1/NEWS
+++ b/mdk-stage1/NEWS
@@ -1,3 +1,6 @@
+- mounting:
+ o use regular mount tool rather than manual system calls
+
2.33
- advertize "ext4" rather than "ext2"
diff --git a/mdk-stage1/mount.c b/mdk-stage1/mount.c
index 7588893dc..858beaf90 100644
--- a/mdk-stage1/mount.c
+++ b/mdk-stage1/mount.c
@@ -19,10 +19,12 @@
*
*/
+// for asprintf:
+#define _GNU_SOURCE
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <stdio.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -57,7 +59,6 @@ int ensure_dev_exists(const char * dev)
/* mounts, creating the device if needed+possible */
int my_mount(char *dev, char *location, char *fs, int force_rw)
{
- unsigned long flags = MS_MGC_VAL | (force_rw ? 0 : MS_RDONLY);
char * opts = NULL;
struct stat buf;
int rc;
@@ -133,7 +134,14 @@ int my_mount(char *dev, char *location, char *fs, int force_rw)
}
#endif
- rc = mount(dev, location, fs, flags, opts);
+ char *cmd;
+ rc = asprintf(&cmd, "mount %s %s -t %s -o %s%s", dev, location, fs, (force_rw ? "" : "ro,"), (opts ? opts : ""));
+ if (rc == -1) {
+ log_perror("asprint allocation failure");
+ rmdir(location);
+ return rc;
+ }
+ rc = system(cmd);
if (rc != 0) {
log_perror("mount failed");
rmdir(location);