From ffad198337f7226ab151eabde3317e95c3e074dd Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 09:44:57 +0200 Subject: [PATCH 01/11] debug details --- util/fusermount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/fusermount.c b/util/fusermount.c index a2dd8e120..fd4455749 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -196,7 +196,7 @@ static int may_unmount(const char *mnt, int quiet) fp = setmntent(mtab, "r"); if (fp == NULL) { - fprintf(stderr, "%s: failed to open %s: %s\n", progname, mtab, + fprintf(stderr, "%s: failed [:199] to open %s: %s\n", progname, mtab, strerror(errno)); return -1; } @@ -495,7 +495,7 @@ static int count_fuse_fs(void) const char *mtab = _PATH_MOUNTED; FILE *fp = setmntent(mtab, "r"); if (fp == NULL) { - fprintf(stderr, "%s: failed to open %s: %s\n", progname, mtab, + fprintf(stderr, "%s: failed [:498] to open %s: %s\n", progname, mtab, strerror(errno)); return -1; } From 96ec7054b2c5bb1c16cc151c50b4027be4cf96b6 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 12:24:14 +0200 Subject: [PATCH 02/11] more debug --- util/fusermount.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/util/fusermount.c b/util/fusermount.c index fd4455749..a9964406e 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -194,6 +194,28 @@ static int may_unmount(const char *mnt, int quiet) if (user == NULL) return -1; + /* more details about file */ + FILE * pFile; + + pFile = fopen (mtab, "r"); + if (pFile!=NULL) + { + fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab) + fclose (pFile); + } else { + fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, mtab) + } + char file_name[] = "/etc/fstab"; + pFile = fopen (file_name, "r"); + if (pFile!=NULL) + { + fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, file_name) + fclose (pFile); + } else { + fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, file_name) + } + /* */ + fp = setmntent(mtab, "r"); if (fp == NULL) { fprintf(stderr, "%s: failed [:199] to open %s: %s\n", progname, mtab, From 217fc457be610aa23bf0f315f78405883d1c5487 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 12:27:55 +0200 Subject: [PATCH 03/11] dd --- util/fusermount.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/util/fusermount.c b/util/fusermount.c index a9964406e..c25c86c96 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -198,21 +198,19 @@ static int may_unmount(const char *mnt, int quiet) FILE * pFile; pFile = fopen (mtab, "r"); - if (pFile!=NULL) - { - fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab) + if (pFile!=NULL) { + fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); fclose (pFile); } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, mtab) + fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, mtab); } char file_name[] = "/etc/fstab"; pFile = fopen (file_name, "r"); - if (pFile!=NULL) - { - fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, file_name) + if (pFile!=NULL) { + fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, file_name); fclose (pFile); } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, file_name) + fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, file_name); } /* */ From b6e9893b97f24799d6d54ccc0e517294c7c8aa07 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 13:30:42 +0200 Subject: [PATCH 04/11] additional exit --- util/fusermount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/fusermount.c b/util/fusermount.c index c25c86c96..1b827d81b 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -202,7 +202,8 @@ static int may_unmount(const char *mnt, int quiet) fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); fclose (pFile); } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, mtab); + fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\n Already unmounted ?", progname, mtab); + return 0; } char file_name[] = "/etc/fstab"; pFile = fopen (file_name, "r"); From 5881e99c18f09498a91ea1794f9fa6c1526d0628 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 14:08:46 +0200 Subject: [PATCH 05/11] info msg --- util/fusermount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/fusermount.c b/util/fusermount.c index 1b827d81b..1dbf8c057 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -202,7 +202,7 @@ static int may_unmount(const char *mnt, int quiet) fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); fclose (pFile); } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\n Already unmounted ?", progname, mtab); + fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nAlready unmounted...\n", progname, mtab); return 0; } char file_name[] = "/etc/fstab"; From 966b1ab6bce76b0dda548666280680279eaca8aa Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Wed, 25 Oct 2023 15:17:24 +0200 Subject: [PATCH 06/11] small clean up --- util/fusermount.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/util/fusermount.c b/util/fusermount.c index 1dbf8c057..6a19db1b5 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -194,7 +194,9 @@ static int may_unmount(const char *mnt, int quiet) if (user == NULL) return -1; - /* more details about file */ + /* OCEAN_IO_IGNORE_MISSING_MTAB start + mtab missing file ignore + */ FILE * pFile; pFile = fopen (mtab, "r"); @@ -202,18 +204,13 @@ static int may_unmount(const char *mnt, int quiet) fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); fclose (pFile); } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nAlready unmounted...\n", progname, mtab); - return 0; - } - char file_name[] = "/etc/fstab"; - pFile = fopen (file_name, "r"); - if (pFile!=NULL) { - fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, file_name); - fclose (pFile); - } else { - fprintf(stderr, "%s: TSZZ file %s does not exists\n", progname, file_name); + const char* ignore_missing_mtab = getenv("OCEAN_IO_IGNORE_MISSING_MTAB"); + if (ignore_missing_mtab != NULL && strcmp(ignore_missing_mtab,"TRUE") == 0) { + fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); + return 0; + } } - /* */ + /* OCEAN_IO_IGNORE_MISSING_MTAB end */ fp = setmntent(mtab, "r"); if (fp == NULL) { From f238bf1cc542a2032463dafd4e7196217eae1c56 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Thu, 26 Oct 2023 08:58:13 +0200 Subject: [PATCH 07/11] debug 1 --- util/fusermount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/fusermount.c b/util/fusermount.c index 6a19db1b5..66b2052d0 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -205,6 +205,7 @@ static int may_unmount(const char *mnt, int quiet) fclose (pFile); } else { const char* ignore_missing_mtab = getenv("OCEAN_IO_IGNORE_MISSING_MTAB"); + fprintf(stderr, "%s: TSZZ file %s does not exists\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); if (ignore_missing_mtab != NULL && strcmp(ignore_missing_mtab,"TRUE") == 0) { fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); return 0; From 38ea8a1e02130727b8729356435d8127805ca744 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Thu, 26 Oct 2023 13:01:23 +0200 Subject: [PATCH 08/11] clean up --- util/fusermount.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/fusermount.c b/util/fusermount.c index 66b2052d0..c0cccda6d 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -204,9 +204,10 @@ static int may_unmount(const char *mnt, int quiet) fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); fclose (pFile); } else { - const char* ignore_missing_mtab = getenv("OCEAN_IO_IGNORE_MISSING_MTAB"); + char* ignore_missing_mtab; + ignore_missing_mtab = getenv("OCEAN_IO_IGNORE_MISSING_MTAB"); fprintf(stderr, "%s: TSZZ file %s does not exists\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); - if (ignore_missing_mtab != NULL && strcmp(ignore_missing_mtab,"TRUE") == 0) { + if (ignore_missing_mtab != NULL && strcmp(ignore_missing_mtab, "TRUE") == 0) { fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); return 0; } From 5009e3847744971ff63870d67072a6b3ed31709e Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Thu, 26 Oct 2023 13:52:10 +0200 Subject: [PATCH 09/11] move parameter to config file --- util/fuse.conf | 2 ++ util/fusermount.c | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/util/fuse.conf b/util/fuse.conf index ab048e034..fd779ae1e 100644 --- a/util/fuse.conf +++ b/util/fuse.conf @@ -15,3 +15,5 @@ # equals sign). #mount_max = 1000 + +#allow_missing_mtab diff --git a/util/fusermount.c b/util/fusermount.c index c0cccda6d..6be0e86ed 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -41,6 +41,7 @@ static const char *progname; static int user_allow_other = 0; +static int allow_missing_mtab = 0; static int mount_max = 1000; static int auto_unmount = 0; @@ -194,25 +195,24 @@ static int may_unmount(const char *mnt, int quiet) if (user == NULL) return -1; - /* OCEAN_IO_IGNORE_MISSING_MTAB start - mtab missing file ignore + /* allow_missing_mtab start + mtab missing file is ignored + in case of kubernetes mtab is linked to mounts + /etc/mtab -> ../proc/self/mounts */ - FILE * pFile; + if (allow_missing_mtab) { - pFile = fopen (mtab, "r"); - if (pFile!=NULL) { - fprintf(stderr, "%s: TSZZ file %s can be open for read\n", progname, mtab); - fclose (pFile); - } else { - char* ignore_missing_mtab; - ignore_missing_mtab = getenv("OCEAN_IO_IGNORE_MISSING_MTAB"); - fprintf(stderr, "%s: TSZZ file %s does not exists\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); - if (ignore_missing_mtab != NULL && strcmp(ignore_missing_mtab, "TRUE") == 0) { - fprintf(stderr, "%s: TSZZ file %s does not exists\nExiting anyway.\nOCEAN_IO_IGNORE_MISSING_MTAB=%s\n", progname, mtab, ignore_missing_mtab); + FILE * pFile; + pFile = fopen (mtab, "r"); + if (pFile!=NULL) { + fclose (pFile); + } else { + + fprintf(stderr, "%s: INFO: file %s does not exists\nExiting ...\n", progname, mtab); return 0; } } - /* OCEAN_IO_IGNORE_MISSING_MTAB end */ + /* allow_missing_mtab end */ fp = setmntent(mtab, "r"); if (fp == NULL) { @@ -570,6 +570,8 @@ static void parse_line(char *line, int linenum) int tmp; if (strcmp(line, "user_allow_other") == 0) user_allow_other = 1; + else if (strcmp(line, "allow_missing_mtab") == 0) + allow_missing_mtab = 1; else if (sscanf(line, "mount_max = %i", &tmp) == 1) mount_max = tmp; else if(line[0]) From 6e571c16b7f183509d424b3edeefcd3dbd4fe094 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Thu, 26 Oct 2023 17:05:14 +0200 Subject: [PATCH 10/11] ignore based on variable --- util/fusermount.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/util/fusermount.c b/util/fusermount.c index 6be0e86ed..505f17352 100644 --- a/util/fusermount.c +++ b/util/fusermount.c @@ -41,7 +41,6 @@ static const char *progname; static int user_allow_other = 0; -static int allow_missing_mtab = 0; static int mount_max = 1000; static int auto_unmount = 0; @@ -189,6 +188,7 @@ static int may_unmount(const char *mnt, int quiet) char uidstr[32]; unsigned uidlen = 0; int found; + int allow_missing_mtab = 1; const char *mtab = _PATH_MOUNTED; user = get_user_name(); @@ -200,14 +200,13 @@ static int may_unmount(const char *mnt, int quiet) in case of kubernetes mtab is linked to mounts /etc/mtab -> ../proc/self/mounts */ - if (allow_missing_mtab) { + if (allow_missing_mtab == 1) { FILE * pFile; pFile = fopen (mtab, "r"); if (pFile!=NULL) { fclose (pFile); } else { - fprintf(stderr, "%s: INFO: file %s does not exists\nExiting ...\n", progname, mtab); return 0; } @@ -570,8 +569,6 @@ static void parse_line(char *line, int linenum) int tmp; if (strcmp(line, "user_allow_other") == 0) user_allow_other = 1; - else if (strcmp(line, "allow_missing_mtab") == 0) - allow_missing_mtab = 1; else if (sscanf(line, "mount_max = %i", &tmp) == 1) mount_max = tmp; else if(line[0]) From 1a384f7e961ffddedf76f69653011b1b7a59a2f3 Mon Sep 17 00:00:00 2001 From: Tomasz Szoszorek Date: Thu, 26 Oct 2023 17:05:39 +0200 Subject: [PATCH 11/11] clean up --- util/fuse.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/util/fuse.conf b/util/fuse.conf index fd779ae1e..36c2cb895 100644 --- a/util/fuse.conf +++ b/util/fuse.conf @@ -16,4 +16,3 @@ #mount_max = 1000 -#allow_missing_mtab