diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:06:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:06:51 +0000 |
commit | 86fcc93b6dde545a549437629292af70f0af0e9d (patch) | |
tree | 10be690f14e138dd6a5e07326e354ced15f52835 /src/nvme/filters.c | |
parent | Releasing progress-linux version 1.8-3~progress7.99u1. (diff) | |
download | libnvme-86fcc93b6dde545a549437629292af70f0af0e9d.tar.xz libnvme-86fcc93b6dde545a549437629292af70f0af0e9d.zip |
Merging upstream version 1.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/nvme/filters.c')
-rw-r--r-- | src/nvme/filters.c | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/src/nvme/filters.c b/src/nvme/filters.c index 312b8f6..ceaba68 100644 --- a/src/nvme/filters.c +++ b/src/nvme/filters.c @@ -6,68 +6,12 @@ * Authors: Keith Busch <keith.busch@wdc.com> * Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> */ -#include <stdlib.h> #include <stdio.h> #include <string.h> #include <dirent.h> -#include <libgen.h> - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> #include "filters.h" -#include "types.h" -#include "util.h" -#include "cleanup.h" - -#define PATH_SYSFS_NVME "/sys/class/nvme" -#define PATH_SYSFS_NVME_SUBSYSTEM "/sys/class/nvme-subsystem" -#define PATH_SYSFS_BLOCK "/sys/block" - -char *nvme_ctrl_sysfs_dir(void) -{ - char *basepath = getenv("LIBNVME_SYSFS_PATH"); - char *str; - - if (!basepath) - return strdup(PATH_SYSFS_NVME); - - if (!asprintf(&str, "%s" PATH_SYSFS_NVME, basepath)) - return NULL; - - return str; -} - -char *nvme_ns_sysfs_dir(void) -{ - char *basepath = getenv("LIBNVME_SYSFS_PATH"); - char *str; - - if (!basepath) - return strdup(PATH_SYSFS_BLOCK); - - if (!asprintf(&str, "%s" PATH_SYSFS_BLOCK, basepath)) - return NULL; - - return str; -} - -char *nvme_subsys_sysfs_dir(void) -{ - char *basepath = getenv("LIBNVME_SYSFS_PATH"); - char *str; - - if (!basepath) - return strdup(PATH_SYSFS_NVME_SUBSYSTEM); - - if (!asprintf(&str, "%s" PATH_SYSFS_NVME_SUBSYSTEM, basepath)) - return NULL; - - return str; -} +#include "private.h" int nvme_namespace_filter(const struct dirent *d) { @@ -132,7 +76,7 @@ int nvme_subsys_filter(const struct dirent *d) int nvme_scan_subsystems(struct dirent ***subsys) { - _cleanup_free_ char *dir = nvme_subsys_sysfs_dir(); + const char *dir = nvme_subsys_sysfs_dir(); return scandir(dir, subsys, nvme_subsys_filter, alphasort); } @@ -145,7 +89,7 @@ int nvme_scan_subsystem_namespaces(nvme_subsystem_t s, struct dirent ***ns) int nvme_scan_ctrls(struct dirent ***ctrls) { - _cleanup_free_ char *dir = nvme_ctrl_sysfs_dir(); + const char *dir = nvme_ctrl_sysfs_dir(); return scandir(dir, ctrls, nvme_ctrls_filter, alphasort); } |