summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/mount.c')
-rw-r--r--mdk-stage1/mount.c14
1 files changed, 11 insertions, 3 deletions
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);