]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: remove ul_prefix_fopen
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 8 Oct 2023 18:49:31 +0000 (20:49 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 8 Oct 2023 18:49:31 +0000 (20:49 +0200)
The function ul_prefix_fopen does not properly check for paths which are
too long. Since the only caller of ul_prefix_fopen can be easily
converted to ul_path_fopen, remove the function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
include/path.h
lib/path.c
sys-utils/lscpu-virt.c

index 19c1be6e7e36dc2c571c44f2a28911bd6142f981..e523f178120b0f2725e8aa8427a71fd18ca4e3f0 100644 (file)
@@ -134,8 +134,6 @@ int ul_path_countf_dirents(struct path_cxt *pc, const char *path, ...)
 
 int ul_path_next_dirent(struct path_cxt *pc, DIR **sub, const char *dirname, struct dirent **d);
 
-FILE *ul_prefix_fopen(const char *prefix, const char *path, const char *mode);
-
 
 #ifdef HAVE_CPU_SET_T
 # include "cpuset.h"
index 9232755ae2356a588965fd402bce573191ce0b30..1e4f36a56eb0ae9ebfd0824941cda85053c0cfcd 100644 (file)
@@ -996,25 +996,6 @@ int ul_path_next_dirent(struct path_cxt *pc, DIR **sub, const char *dirname, str
        return 1;
 }
 
-/*
- * Like fopen() but, @path is always prefixed by @prefix. This function is
- * useful in case when ul_path_* API is overkill.
- */
-FILE *ul_prefix_fopen(const char *prefix, const char *path, const char *mode)
-{
-       char buf[PATH_MAX];
-
-       if (!path)
-               return NULL;
-       if (!prefix)
-               return fopen(path, mode);
-       if (*path == '/')
-               path++;
-
-       snprintf(buf, sizeof(buf), "%s/%s", prefix, path);
-       return fopen(buf, mode);
-}
-
 #ifdef HAVE_CPU_SET_T
 static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, int islist, const char *path, va_list ap)
 {
index 6b6deb8e81c121db330135967d112905d95b9cbf..280c462aab712c3a4b5421f3f0520f3272000760 100644 (file)
@@ -551,7 +551,7 @@ struct lscpu_virt *lscpu_read_virtualization(struct lscpu_cxt *cxt)
                if (virt->vendor == VIRT_VENDOR_XEN) {
                        uint32_t features;
 
-                       fd = ul_prefix_fopen(cxt->prefix, "r", _PATH_SYS_HYP_FEATURES);
+                       fd = ul_path_fopen(cxt->rootfs, "r", _PATH_SYS_HYP_FEATURES);
 
                        if (fd && fscanf(fd, "%x", &features) == 1) {
                                /* Xen PV domain */