mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
mount: support -f option
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=mount
|
||||
revision=1
|
||||
revision=2
|
||||
from_source=mount
|
||||
imagedeps="build-essential"
|
||||
hostdeps="xbinutils xgcc"
|
||||
|
||||
+10
-2
@@ -14,9 +14,10 @@ struct mtab_list {
|
||||
|
||||
static const char *argv0;
|
||||
static struct mtab_list *mtab_list;
|
||||
static bool force = false;
|
||||
|
||||
void usage(void) {
|
||||
fprintf(stderr, "%s: usage: %s [-a] [-d device] [-t filesystem] [mountpoint]\n", argv0, argv0);
|
||||
fprintf(stderr, "%s: usage: %s [-a] [-f] [-d device] [-t filesystem] [mountpoint]\n", argv0, argv0);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -25,6 +26,7 @@ static int mount_filesystem(char *device, char *path, char *filesystem, unsigned
|
||||
device = NULL;
|
||||
|
||||
// check if device already mounted
|
||||
if (!force) {
|
||||
for (struct mtab_list *it = mtab_list; it; it = it->next) {
|
||||
if (strcmp(path, it->mntent.mnt_dir) == 0 && strcmp(filesystem, it->mntent.mnt_type) == 0 && strcmp(it->mntent.mnt_fsname, "none") == 0) {
|
||||
fprintf(stderr, "%s: virtual filesystem %s already mounted at %s\n", argv0, filesystem, path);
|
||||
@@ -36,6 +38,7 @@ static int mount_filesystem(char *device, char *path, char *filesystem, unsigned
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __astral__
|
||||
if (mount(device, path, filesystem, flags, opts)) {
|
||||
@@ -50,7 +53,6 @@ static int mount_filesystem(char *device, char *path, char *filesystem, unsigned
|
||||
if (entry == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
||||
entry->mntent.mnt_fsname = device ? strdup(device) : "none";
|
||||
entry->mntent.mnt_dir = strdup(path);
|
||||
entry->mntent.mnt_type = strdup(filesystem);
|
||||
@@ -247,6 +249,12 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (strcmp(argv[i], "-a") == 0) {
|
||||
all = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[i], "-f") == 0) {
|
||||
force = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (devnext) {
|
||||
|
||||
Reference in New Issue
Block a user