libglnx porting: Port away from gs_file_ensure_directory()

The init-fs code in particular gets (IMO) a lot cleaner being fd
relative.

Closes: #312
Approved by: giuseppe
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2016-05-30 11:33:28 +00:00
1 parent e5eb6f3a22
commit 6e57987c7c
4 files changed
+49 -46

No files matched your search

@@ -1483,7 +1483,8 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
descriptor_dir = g_file_get_parent (descriptor_path);
if (!gs_file_ensure_directory (descriptor_dir, TRUE, cancellable, error))
if (!glnx_shutil_mkdir_p_at (AT_FDCWD, gs_file_get_path_cached (descriptor_dir), 0755,
cancellable, error))
goto out;
for (i = 0; i < part_tempfiles->len; i++)
+10 -3
View File
@@ -2228,8 +2228,14 @@ ostree_repo_create (OstreeRepo *self,
if (!ostree_repo_mode_to_string (mode, &mode_str, error))
goto out;
if (!gs_file_ensure_directory (self->repodir, FALSE, cancellable, error))
goto out;
if (mkdir (gs_file_get_path_cached (self->repodir), 0755) != 0)
{
if (errno != EEXIST)
{
glnx_set_error_from_errno (error);
goto out;
}
}
config_data = g_string_new (DEFAULT_CONFIG_CONTENTS);
g_string_append_printf (config_data, "mode=%s\n", mode_str);
@@ -2632,7 +2638,8 @@ ostree_repo_open (OstreeRepo *self,
if (self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2 && self->enable_uncompressed_cache)
{
if (!gs_file_ensure_directory (self->uncompressed_objects_dir, TRUE, cancellable, error))
if (!glnx_shutil_mkdir_p_at (self->repo_dir_fd, "uncompressed-objects-cache", 0755,
cancellable, error))
goto out;
if (!glnx_opendirat (self->repo_dir_fd, "uncompressed-objects-cache", TRUE,
&self->uncompressed_objects_dir_fd,
+19 -18
View File
@@ -278,28 +278,29 @@ ostree_sysroot_ensure_initialized (OstreeSysroot *self,
GError **error)
{
gboolean ret = FALSE;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFile) ostree_dir = NULL;
g_autoptr(GFile) repo_dir = NULL;
struct stat stbuf;
ostree_dir = g_file_get_child (self->path, "ostree");
repo_dir = g_file_get_child (ostree_dir, "repo");
if (!gs_file_ensure_directory (repo_dir, TRUE, cancellable, error))
if (!ensure_sysroot_fd (self, error))
goto out;
g_clear_object (&dir);
dir = g_file_get_child (ostree_dir, "deploy");
if (!gs_file_ensure_directory (dir, TRUE, cancellable, error))
goto out;
g_clear_object (&dir);
dir = ot_gfile_get_child_build_path (ostree_dir, "repo", "objects", NULL);
if (!g_file_query_exists (dir, NULL))
{
glnx_unref_object OstreeRepo *repo = ostree_repo_new (repo_dir);
if (!ostree_repo_create (repo, OSTREE_REPO_MODE_BARE,
if (!glnx_shutil_mkdir_p_at (self->sysroot_fd, "ostree/repo", 0755,
cancellable, error))
goto out;
goto out;
if (!glnx_shutil_mkdir_p_at (self->sysroot_fd, "ostree/deploy", 0755,
cancellable, error))
goto out;
if (fstatat (self->sysroot_fd, "ostree/repo/objects", &stbuf, 0) != 0)
{
if (errno == ENOENT)
{
g_autoptr(GFile) repo_dir = g_file_resolve_relative_path (self->path, "ostree/repo");
glnx_unref_object OstreeRepo *repo = ostree_repo_new (repo_dir);
if (!ostree_repo_create (repo, OSTREE_REPO_MODE_BARE,
cancellable, error))
goto out;
}
}
ret = TRUE;