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
|
name=mount
|
||||||
revision=1
|
revision=2
|
||||||
from_source=mount
|
from_source=mount
|
||||||
imagedeps="build-essential"
|
imagedeps="build-essential"
|
||||||
hostdeps="xbinutils xgcc"
|
hostdeps="xbinutils xgcc"
|
||||||
|
|||||||
+18
-10
@@ -14,9 +14,10 @@ struct mtab_list {
|
|||||||
|
|
||||||
static const char *argv0;
|
static const char *argv0;
|
||||||
static struct mtab_list *mtab_list;
|
static struct mtab_list *mtab_list;
|
||||||
|
static bool force = false;
|
||||||
|
|
||||||
void usage(void) {
|
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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,15 +26,17 @@ static int mount_filesystem(char *device, char *path, char *filesystem, unsigned
|
|||||||
device = NULL;
|
device = NULL;
|
||||||
|
|
||||||
// check if device already mounted
|
// check if device already mounted
|
||||||
for (struct mtab_list *it = mtab_list; it; it = it->next) {
|
if (!force) {
|
||||||
if (strcmp(path, it->mntent.mnt_dir) == 0 && strcmp(filesystem, it->mntent.mnt_type) == 0 && strcmp(it->mntent.mnt_fsname, "none") == 0) {
|
for (struct mtab_list *it = mtab_list; it; it = it->next) {
|
||||||
fprintf(stderr, "%s: virtual filesystem %s already mounted at %s\n", argv0, filesystem, path);
|
if (strcmp(path, it->mntent.mnt_dir) == 0 && strcmp(filesystem, it->mntent.mnt_type) == 0 && strcmp(it->mntent.mnt_fsname, "none") == 0) {
|
||||||
return EXIT_SUCCESS;
|
fprintf(stderr, "%s: virtual filesystem %s already mounted at %s\n", argv0, filesystem, path);
|
||||||
}
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (device && strcmp(device, it->mntent.mnt_fsname) == 0 && strcmp(it->mntent.mnt_fsname, "none")) {
|
if (device && strcmp(device, it->mntent.mnt_fsname) == 0 && strcmp(it->mntent.mnt_fsname, "none")) {
|
||||||
fprintf(stderr, "%s: %s already mounted at %s\n", argv0, device, path);
|
fprintf(stderr, "%s: %s already mounted at %s\n", argv0, device, path);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +53,6 @@ static int mount_filesystem(char *device, char *path, char *filesystem, unsigned
|
|||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
|
||||||
entry->mntent.mnt_fsname = device ? strdup(device) : "none";
|
entry->mntent.mnt_fsname = device ? strdup(device) : "none";
|
||||||
entry->mntent.mnt_dir = strdup(path);
|
entry->mntent.mnt_dir = strdup(path);
|
||||||
entry->mntent.mnt_type = strdup(filesystem);
|
entry->mntent.mnt_type = strdup(filesystem);
|
||||||
@@ -247,6 +249,12 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (strcmp(argv[i], "-a") == 0) {
|
if (strcmp(argv[i], "-a") == 0) {
|
||||||
all = true;
|
all = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "-f") == 0) {
|
||||||
|
force = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devnext) {
|
if (devnext) {
|
||||||
|
|||||||
Reference in New Issue
Block a user