Merge pull request #45549 from nmshelke/fuse-linux-only

ceph-fuse: restrict already_fuse_mounted function only for linux

Reviewed-by: Venky Shankar <vshankar@redhat.com>
This commit is contained in:
Venky Shankar 2022-04-14 17:38:20 +05:30 committed by GitHub
commit b4ea90ad82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from tasks.cephfs.fuse_mount import FuseMount
from tasks.cephfs.cephfs_test_case import CephFSTestCase
from teuthology.exceptions import CommandFailedError
import errno
import platform
import time
import json
import logging
@ -30,6 +31,9 @@ class TestMisc(CephFSTestCase):
p.wait()
def test_fuse_mount_on_already_mounted_path(self):
if platform.system() != "Linux":
self.skipTest("Require Linux platform")
if not isinstance(self.mount_a, FuseMount):
self.skipTest("Require FUSE client")

View File

@ -23,10 +23,13 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#if defined(__linux__)
#include <libgen.h>
#include <sys/vfs.h>
#include <sys/xattr.h>
#include <linux/magic.h>
#endif
// ceph
#include "common/errno.h"
@ -57,11 +60,13 @@
#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
#if defined(__linux__)
#ifndef FUSE_SUPER_MAGIC
#define FUSE_SUPER_MAGIC 0x65735546
#endif
#define _CEPH_CLIENT_ID "ceph.client_id"
#endif
using namespace std;
@ -173,6 +178,7 @@ public:
struct fuse_args args;
};
#if defined(__linux__)
static int already_fuse_mounted(const char *path, bool &already_mounted)
{
struct statx path_statx;
@ -242,6 +248,13 @@ static int already_fuse_mounted(const char *path, bool &already_mounted)
return err;
}
#else // non-linux platforms
static int already_fuse_mounted(const char *path, bool &already_mounted)
{
already_mounted = false;
return 0;
}
#endif
static int getgroups(fuse_req_t req, gid_t **sgids)
{

View File

@ -28,6 +28,7 @@ id=myuser,conf=/etc/ceph/foo.conf /mnt/ceph fuse.ceph defaults 0 0
import sys
import argparse
import errno
import platform
from subprocess import Popen
def ceph_options(mntops):
@ -74,7 +75,10 @@ def main(arguments):
mount_cmd.communicate()
if (mount_cmd.returncode != 0):
if (mount_cmd.returncode != errno.EBUSY):
if (platform.system() == "Linux"):
if (mount_cmd.returncode != errno.EBUSY):
print("Mount failed with status code: {}".format(mount_cmd.returncode))
else:
print("Mount failed with status code: {}".format(mount_cmd.returncode))
if __name__ == '__main__':