aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindfs.c103
1 files changed, 90 insertions, 13 deletions
diff --git a/src/bindfs.c b/src/bindfs.c
index 23d4ee4..d79e4df 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -2395,7 +2395,7 @@ struct fuse_args filter_special_opts(struct fuse_args *args)
{
int i, j, ignore;
struct fuse_args new_args = FUSE_ARGS_INIT(0, (void*)0);
- char *tmpStr;
+ char *tmpStr, *tmpStr2, *ptr;
// Copied from "libfuse/util/mount.fuse.c" (fuse-3.10.1)
// but not as const char, because needs to be modified later
@@ -2413,26 +2413,102 @@ struct fuse_args filter_special_opts(struct fuse_args *args)
for (i=0; i < args->argc; i++) {
ignore = 0;
+
+ /* If current element is exactly "-o" modify/check the following element */
if (strcmp(args->argv[i], "-o") == 0 && (i+1) < args->argc) {
- for (j = 0; ignore_opts[j]; j++) {
- if (strcmp(args->argv[i+1], ignore_opts[j]) == 0) {
+
+ /* remove ignored option from a comma seperated list */
+ if (strchr(args->argv[i+1], ',') != NULL) {
+ tmpStr = (char*) calloc(strlen(args->argv[i+1]), sizeof(char));
+ ptr = strtok(args->argv[i+1], ",");
+ while (ptr != NULL) {
+ ignore = 0;
+ for (j = 0; ignore_opts[j]; j++) {
+ if (strcmp(ptr, ignore_opts[j]) == 0) {
+ ignore = 1;
+ break;
+ }
+ }
+ if (!ignore) {
+ if (strlen(tmpStr) > 0) strcat(tmpStr, ",");
+ strcat(tmpStr, ptr);
+ }
+ ptr = strtok(NULL, ",");
+ }
+ if (strlen(tmpStr) > 0) {
+ args->argv[i+1] = (char*) calloc(strlen(tmpStr), sizeof(char));
+ strcpy(args->argv[i+1], tmpStr);
+ free(tmpStr);
+ ignore = 0;
+ }
+ else {
ignore = 1;
i+=1;
- break;
+ }
+ }
+
+ /* ignore this and the following element if it has exactly the ignored option */
+ else {
+ for (j = 0; ignore_opts[j]; j++) {
+ if (strcmp(args->argv[i+1], ignore_opts[j]) == 0) {
+ ignore = 1;
+ i+=1;
+ break;
+ }
}
}
}
+
+ /* else if element starts with "-o" */
else if (strncmp(args->argv[i], "-o", 2) == 0) {
- for (j = 0; ignore_opts[j]; j++) {
- tmpStr = (char*) calloc( (3 + strlen(ignore_opts[j])), sizeof(char) );
- strcat(tmpStr, "-o");
- strcat(tmpStr, ignore_opts[j]);
- if (strcmp(args->argv[i], tmpStr) == 0) {
- ignore = 1;
+
+ /* remove ignored option from a comma seperated list */
+ if (strchr(args->argv[i], ',') != NULL) {
+ tmpStr = (char*) calloc(strlen(args->argv[i]), sizeof(char));
+ tmpStr2 = (char*) calloc(strlen(args->argv[i])-2, sizeof(char));
+ // remove first 2 chars from args->argv[i] and save this to tmpStr2
+ memmove(tmpStr2, args->argv[i]+2, strlen(args->argv[i])-2);
+ ptr = strtok(tmpStr2, ",");
+ while (ptr != NULL) {
+ ignore = 0;
+ for (j = 0; ignore_opts[j]; j++) {
+ if (strcmp(ptr, ignore_opts[j]) == 0) {
+ ignore = 1;
+ break;
+ }
+ }
+ if (!ignore) {
+ if (strlen(tmpStr) > 0) strcat(tmpStr, ",");
+ strcat(tmpStr, ptr);
+ }
+ ptr = strtok(NULL, ",");
+ }
+ if (strlen(tmpStr) > 0) {
+ args->argv[i] = (char*) calloc(strlen(tmpStr)+2, sizeof(char));
+ strcat(args->argv[i], "-o");
+ strcat(args->argv[i], tmpStr);
+ free(tmpStr);
+ free(tmpStr2);
+ ignore = 0;
+ }
+ else {
+ ignore = 1;
+ }
+ }
+
+ /* ignore this element if it has exactly the ignored option */
+ else {
+ for (j = 0; ignore_opts[j]; j++) {
+ tmpStr = (char*) calloc( (3 + strlen(ignore_opts[j])), sizeof(char) );
+ strcat(tmpStr, "-o");
+ strcat(tmpStr, ignore_opts[j]);
+ if (strcmp(args->argv[i], tmpStr) == 0) {
+ ignore = 1;
+ free(tmpStr);
+ break;
+ }
free(tmpStr);
- break;
}
- free(tmpStr);
}
}
if (!ignore) {
@@ -2441,6 +2517,7 @@ struct fuse_args filter_special_opts(struct fuse_args *args)
}
fuse_opt_free_args(args);
+
return new_args;
}
@@ -2924,7 +3001,7 @@ int main(int argc, char *argv[])
if (!settings.enable_ioctl) {
bindfs_oper.ioctl = NULL;
}
-
+
/* Remove/Ignore some special -o options */
args = filter_special_opts(&args);