core: Use GFile for xattr API
This commit is contained in:
parent
e588a47ba6
commit
218684786d
|
|
@ -123,15 +123,18 @@ read_xattr_name_array (const char *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant *
|
GVariant *
|
||||||
ostree_get_xattrs_for_path (const char *path,
|
ostree_get_xattrs_for_file (GFile *f,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
const char *path;
|
||||||
GVariant *ret = NULL;
|
GVariant *ret = NULL;
|
||||||
GVariantBuilder builder;
|
GVariantBuilder builder;
|
||||||
char *xattr_names = NULL;
|
char *xattr_names = NULL;
|
||||||
char *xattr_names_canonical = NULL;
|
char *xattr_names_canonical = NULL;
|
||||||
ssize_t bytes_read;
|
ssize_t bytes_read;
|
||||||
|
|
||||||
|
path = ot_gfile_get_path_cached (f);
|
||||||
|
|
||||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
|
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
|
||||||
|
|
||||||
bytes_read = llistxattr (path, NULL, 0);
|
bytes_read = llistxattr (path, NULL, 0);
|
||||||
|
|
@ -175,6 +178,7 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
|
||||||
struct stat *out_stbuf,
|
struct stat *out_stbuf,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
GFile *f = NULL;
|
||||||
GChecksum *content_sha256 = NULL;
|
GChecksum *content_sha256 = NULL;
|
||||||
GChecksum *content_and_meta_sha256 = NULL;
|
GChecksum *content_and_meta_sha256 = NULL;
|
||||||
char *stat_string = NULL;
|
char *stat_string = NULL;
|
||||||
|
|
@ -188,6 +192,8 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
|
||||||
char *device_id = NULL;
|
char *device_id = NULL;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
|
|
||||||
|
f = ot_util_new_file_for_path (path);
|
||||||
|
|
||||||
basename = g_path_get_basename (path);
|
basename = g_path_get_basename (path);
|
||||||
|
|
||||||
if (dir_fd == -1)
|
if (dir_fd == -1)
|
||||||
|
|
@ -221,7 +227,7 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
|
||||||
|
|
||||||
if (objtype == OSTREE_OBJECT_TYPE_FILE)
|
if (objtype == OSTREE_OBJECT_TYPE_FILE)
|
||||||
{
|
{
|
||||||
xattrs = ostree_get_xattrs_for_path (path, error);
|
xattrs = ostree_get_xattrs_for_file (f, error);
|
||||||
if (!xattrs)
|
if (!xattrs)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
@ -286,6 +292,7 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
|
||||||
*out_checksum = content_and_meta_sha256;
|
*out_checksum = content_and_meta_sha256;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
g_clear_object (&f);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
close (fd);
|
close (fd);
|
||||||
if (temp_dir != NULL)
|
if (temp_dir != NULL)
|
||||||
|
|
@ -324,7 +331,7 @@ ostree_get_directory_metadata (GFile *dir,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
xattrs = ostree_get_xattrs_for_path (ot_gfile_get_path_cached (dir), error);
|
xattrs = ostree_get_xattrs_for_file (dir, error);
|
||||||
if (!xattrs)
|
if (!xattrs)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
@ -348,11 +355,17 @@ ostree_get_directory_metadata (GFile *dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_set_xattrs (const char *path, GVariant *xattrs, GCancellable *cancellable, GError **error)
|
ostree_set_xattrs (GFile *f,
|
||||||
|
GVariant *xattrs,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
|
const char *path;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
|
path = ot_gfile_get_path_cached (f);
|
||||||
|
|
||||||
n = g_variant_n_children (xattrs);
|
n = g_variant_n_children (xattrs);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -462,7 +475,6 @@ ostree_pack_object (GOutputStream *output,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
const char *path = NULL;
|
|
||||||
GFileInfo *finfo = NULL;
|
GFileInfo *finfo = NULL;
|
||||||
GFileInputStream *instream = NULL;
|
GFileInputStream *instream = NULL;
|
||||||
gboolean pack_builder_initialized = FALSE;
|
gboolean pack_builder_initialized = FALSE;
|
||||||
|
|
@ -471,8 +483,6 @@ ostree_pack_object (GOutputStream *output,
|
||||||
GVariant *xattrs = NULL;
|
GVariant *xattrs = NULL;
|
||||||
gsize bytes_written;
|
gsize bytes_written;
|
||||||
|
|
||||||
path = ot_gfile_get_path_cached (file);
|
|
||||||
|
|
||||||
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
|
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
|
||||||
if (!finfo)
|
if (!finfo)
|
||||||
|
|
@ -510,7 +520,7 @@ ostree_pack_object (GOutputStream *output,
|
||||||
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (gid));
|
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (gid));
|
||||||
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (mode));
|
g_variant_builder_add (&pack_builder, "u", GUINT32_TO_BE (mode));
|
||||||
|
|
||||||
xattrs = ostree_get_xattrs_for_path (path, error);
|
xattrs = ostree_get_xattrs_for_file (file, error);
|
||||||
if (!xattrs)
|
if (!xattrs)
|
||||||
goto out;
|
goto out;
|
||||||
g_variant_builder_add (&pack_builder, "@a(ayay)", xattrs);
|
g_variant_builder_add (&pack_builder, "@a(ayay)", xattrs);
|
||||||
|
|
@ -856,7 +866,7 @@ unpack_file (const char *path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_set_xattrs (dest_path, xattrs, NULL, error))
|
if (!ostree_set_xattrs (file, xattrs, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (ret_checksum)
|
if (ret_checksum)
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,10 @@ char *ostree_get_relative_object_path (const char *checksum,
|
||||||
OstreeObjectType type,
|
OstreeObjectType type,
|
||||||
gboolean archive);
|
gboolean archive);
|
||||||
|
|
||||||
GVariant *ostree_get_xattrs_for_path (const char *path,
|
GVariant *ostree_get_xattrs_for_file (GFile *f,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_set_xattrs (const char *path, GVariant *xattrs,
|
gboolean ostree_set_xattrs (GFile *f, GVariant *xattrs,
|
||||||
GCancellable *cancellable, GError **error);
|
GCancellable *cancellable, GError **error);
|
||||||
|
|
||||||
gboolean ostree_parse_metadata_file (const char *path,
|
gboolean ostree_parse_metadata_file (const char *path,
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ _ostree_repo_file_get_xattrs (OstreeRepoFile *self,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
local_file = _ostree_repo_file_nontree_get_local (self);
|
local_file = _ostree_repo_file_nontree_get_local (self);
|
||||||
ret_xattrs = ostree_get_xattrs_for_path (ot_gfile_get_path_cached (local_file), error);
|
ret_xattrs = ostree_get_xattrs_for_file (local_file, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
|
||||||
|
|
@ -1710,10 +1710,12 @@ checkout_one_directory (OstreeRepo *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
GFile *dest_file = NULL;
|
||||||
char *dest_path = NULL;
|
char *dest_path = NULL;
|
||||||
GVariant *xattr_variant = NULL;
|
GVariant *xattr_variant = NULL;
|
||||||
|
|
||||||
dest_path = g_build_filename (destination, dirname, NULL);
|
dest_path = g_build_filename (destination, dirname, NULL);
|
||||||
|
dest_file = ot_util_new_file_for_path (dest_path);
|
||||||
|
|
||||||
if (!_ostree_repo_file_get_xattrs (dir, &xattr_variant, NULL, error))
|
if (!_ostree_repo_file_get_xattrs (dir, &xattr_variant, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -1725,7 +1727,7 @@ checkout_one_directory (OstreeRepo *self,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_set_xattrs (dest_path, xattr_variant, cancellable, error))
|
if (!ostree_set_xattrs (dest_file, xattr_variant, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!checkout_tree (self, dir, dest_path, cancellable, error))
|
if (!checkout_tree (self, dir, dest_path, cancellable, error))
|
||||||
|
|
@ -1733,6 +1735,7 @@ checkout_one_directory (OstreeRepo *self,
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
g_clear_object (&dest_file);
|
||||||
g_free (dest_path);
|
g_free (dest_path);
|
||||||
if (xattr_variant)
|
if (xattr_variant)
|
||||||
g_variant_unref (xattr_variant);
|
g_variant_unref (xattr_variant);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue