[PATCH i-g-t 03/39] lib/igt_configfs: Add helper to mount configfs
Louis Chauvet
louis.chauvet at bootlin.com
Thu Feb 27 13:14:39 UTC 2025
Le 18/02/2025 à 17:49, José Expósito a écrit :
> Add a new helper function to mount configfs. Required to test VKMS
> configuration.
>
> Co-developed-by: Jim Shargo <jshargo at chromium.org>
> Signed-off-by: Jim Shargo <jshargo at chromium.org>
> Co-developed-by: Marius Vlad <marius.vlad at collabora.com>
> Signed-off-by: Marius Vlad <marius.vlad at collabora.com>
> Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
> ---
> lib/igt.h | 1 +
> lib/igt_configfs.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
> lib/igt_configfs.h | 13 +++++++++++
> lib/meson.build | 1 +
> 4 files changed, 72 insertions(+)
> create mode 100644 lib/igt_configfs.c
> create mode 100644 lib/igt_configfs.h
>
> diff --git a/lib/igt.h b/lib/igt.h
> index 58c39e098..173ca70bf 100644
> --- a/lib/igt.h
> +++ b/lib/igt.h
> @@ -27,6 +27,7 @@
> #include "drmtest.h"
> #include "i915_3d.h"
> #include "igt_aux.h"
> +#include "igt_configfs.h"
> #include "igt_core.h"
> #include "igt_debugfs.h"
> #include "igt_draw.h"
> diff --git a/lib/igt_configfs.c b/lib/igt_configfs.c
> new file mode 100644
> index 000000000..cd8674cb5
> --- /dev/null
> +++ b/lib/igt_configfs.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Google LLC.
> + * Copyright © 2023 Collabora, Ltd.
> + * Copyright © 2024 Red Hat, Inc.
> + */
> +
> +#include <sys/mount.h>
> +
> +#include "igt_aux.h"
> +#include "igt_configfs.h"
> +
> +/**
> + * SECTION:igt_configfs
> + * @short_description: Support code for configfs features
> + * @title: configfs
> + * @include: igt_configfs.h
> + *
> + * This library provides helpers to access configfs features.
> + */
> +
> +/*
> + * General configfs helpers
> + */
> +
> +static const char *__igt_configfs_mount(void)
> +{
> + if (igt_is_mountpoint("/sys/kernel/config"))
> + return "/sys/kernel/config";
> +
> + if (igt_is_mountpoint("/config"))
> + return "/config";
> +
> + if (mount("config", "/sys/kernel/config", "configfs", 0, 0))
> + return NULL;
> +
> + return "/sys/kernel/config";
> +}
> +
> +/**
> + * igt_configfs_mount:
> + *
> + * This attempts to locate where configfs is mounted on the filesystem,
> + * and if not found, will then try to mount configfs at /sys/kernel/config.
> + *
> + * Returns:
> + * The path to the configfs mount point (e.g. /sys/kernel/config)
> + */
> +const char *igt_configfs_mount(void)
> +{
> + static const char *path;
> +
> + if (!path)
> + path = __igt_configfs_mount();
> +
> + return path;
> +}
> diff --git a/lib/igt_configfs.h b/lib/igt_configfs.h
> new file mode 100644
> index 000000000..4cbe9001e
> --- /dev/null
> +++ b/lib/igt_configfs.h
> @@ -0,0 +1,13 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2023 Google LLC.
> + * Copyright © 2023 Collabora, Ltd.
> + * Copyright © 2024 Red Hat, Inc.
> + */
> +
> +#ifndef __IGT_CONFIGFS_H__
> +#define __IGT_CONFIGFS_H__
> +
> +const char *igt_configfs_mount(void);
> +
> +#endif /* __IGT_CONFIGFS_H__ */
> diff --git a/lib/meson.build b/lib/meson.build
> index 9fffdd3c6..201b1fbb4 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -18,6 +18,7 @@ lib_sources = [
> 'i915/i915_crc.c',
> 'igt_collection.c',
> 'igt_color_encoding.c',
> + 'igt_configfs.c',
> 'igt_facts.c',
> 'igt_crc.c',
> 'igt_debugfs.c',
--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the igt-dev
mailing list