Unexport fu_common_realpath()

We don't want plugins to be using this.
This commit is contained in:
Richard Hughes 2022-06-06 15:34:44 +01:00 committed by Mario Limonciello
parent 2c5e4ff3ab
commit 518ba8b6f7
5 changed files with 36 additions and 46 deletions

View File

@ -79,3 +79,4 @@ Remember: Plugins should be upstream!
* `fu_common_set_firmware_search_path()`: Use `fu_kernel_set_firmware_search_path` instead.
* `fu_common_reset_firmware_search_path()`: Use `fu_kernel_reset_firmware_search_path` instead.
* `fu_common_firmware_builder()`: You should not be using this.
* `fu_common_realpath()`: You should not be using this.

View File

@ -663,48 +663,6 @@ fu_common_dump_bytes(const gchar *log_domain, const gchar *title, GBytes *bytes)
fu_common_dump_raw(log_domain, title, data, len);
}
/**
* fu_common_realpath:
* @filename: a filename
* @error: (nullable): optional return location for an error
*
* Finds the canonicalized absolute filename for a path.
*
* Returns: a filename, or %NULL if invalid or not found
*
* Since: 1.2.6
**/
gchar *
fu_common_realpath(const gchar *filename, GError **error)
{
char full_tmp[PATH_MAX];
g_return_val_if_fail(filename != NULL, NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
#ifdef HAVE_REALPATH
if (realpath(filename, full_tmp) == NULL) {
#else
if (_fullpath(full_tmp, filename, sizeof(full_tmp)) == NULL) {
#endif
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot resolve path: %s",
strerror(errno));
return NULL;
}
if (!g_file_test(full_tmp, G_FILE_TEST_EXISTS)) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot find path: %s",
full_tmp);
return NULL;
}
return g_strdup(full_tmp);
}
/**
* fu_common_fnmatch:
* @pattern: a glob pattern, e.g. `*foo*`

View File

@ -171,8 +171,6 @@ typedef enum {
gchar *
fu_common_get_path(FuPathKind path_kind);
gchar *
fu_common_realpath(const gchar *filename, GError **error) G_GNUC_WARN_UNUSED_RESULT;
GPtrArray *
fu_common_filename_glob(const gchar *directory,
const gchar *pattern,

View File

@ -291,7 +291,6 @@ LIBFWUPDPLUGIN_1.2.5 {
LIBFWUPDPLUGIN_1.2.6 {
global:
fu_common_realpath;
fu_device_activate;
fu_device_get_firmware_size_max;
fu_device_get_firmware_size_min;

View File

@ -13,6 +13,7 @@
#include <gio/gunixinputstream.h>
#endif
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UTSNAME_H
#include <sys/utsname.h>
@ -2096,6 +2097,39 @@ fu_engine_is_running_offline(FuEngine *self)
#endif
}
#ifdef HAVE_GIO_UNIX
static gchar *
fu_realpath(const gchar *filename, GError **error)
{
char full_tmp[PATH_MAX];
g_return_val_if_fail(filename != NULL, NULL);
g_return_val_if_fail(error == NULL || *error == NULL, NULL);
#ifdef HAVE_REALPATH
if (realpath(filename, full_tmp) == NULL) {
#else
if (_fullpath(full_tmp, filename, sizeof(full_tmp)) == NULL) {
#endif
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot resolve path: %s",
strerror(errno));
return NULL;
}
if (!g_file_test(full_tmp, G_FILE_TEST_EXISTS)) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot find path: %s",
full_tmp);
return NULL;
}
return g_strdup(full_tmp);
}
#endif
static gboolean
fu_engine_offline_setup(GError **error)
{
@ -2108,7 +2142,7 @@ fu_engine_offline_setup(GError **error)
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
/* does already exist */
filename = fu_common_realpath(trigger, NULL);
filename = fu_realpath(trigger, NULL);
if (g_strcmp0(filename, symlink_target) == 0) {
g_debug("%s already points to %s, skipping creation", trigger, symlink_target);
return TRUE;