[ostree] repo: Hold an fd "repo_dir_fd" open for the toplevel too
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] repo: Hold an fd "repo_dir_fd" open for the toplevel too
- Date: Thu, 12 Feb 2015 16:43:40 +0000 (UTC)
commit 3b8ed12ab24d3aa4b97ea09f5689d533fe65e3ba
Author: Colin Walters <walters verbum org>
Date: Mon Feb 2 14:56:39 2015 -0500
repo: Hold an fd "repo_dir_fd" open for the toplevel too
We could just make everything relative to this, but the objects/ and
tmp/ are accessed very often, so I think it's worth holding individual
fds.
This fd can cover everything else: refs, deltas, etc.
src/libostree/ostree-repo-private.h | 1 +
src/libostree/ostree-repo.c | 16 +++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/libostree/ostree-repo-private.h b/src/libostree/ostree-repo-private.h
index f38db57..82d3534 100644
--- a/src/libostree/ostree-repo-private.h
+++ b/src/libostree/ostree-repo-private.h
@@ -37,6 +37,7 @@ struct OstreeRepo {
char *boot_id;
GFile *repodir;
+ int repo_dir_fd;
GFile *tmp_dir;
int tmp_dir_fd;
GFile *local_heads_dir;
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 1fc9ed1..1de17a8 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -328,6 +328,8 @@ ostree_repo_finalize (GObject *object)
g_free (self->boot_id);
g_clear_object (&self->repodir);
+ if (self->repo_dir_fd != -1)
+ (void) close (self->repo_dir_fd);
g_clear_object (&self->tmp_dir);
if (self->tmp_dir_fd)
(void) close (self->tmp_dir_fd);
@@ -453,6 +455,7 @@ ostree_repo_init (OstreeRepo *self)
(GDestroyNotify) ost_remote_unref);
g_mutex_init (&self->remotes_lock);
+ self->repo_dir_fd = -1;
self->objects_dir_fd = -1;
self->uncompressed_objects_dir_fd = -1;
}
@@ -1288,13 +1291,20 @@ ostree_repo_open (OstreeRepo *self,
goto out;
g_strdelimit (self->boot_id, "\n", '\0');
- if (!gs_file_open_dir_fd (self->objects_dir, &self->objects_dir_fd, cancellable, error))
+ if (!gs_file_open_dir_fd (self->repodir, &self->repo_dir_fd, cancellable, error))
{
- g_prefix_error (error, "Reading objects/ directory: ");
+ g_prefix_error (error, "%s: ", gs_file_get_path_cached (self->repodir));
goto out;
}
- self->writable = faccessat (AT_FDCWD, gs_file_get_path_cached (self->objects_dir), W_OK, 0) == 0;
+ if (!gs_file_open_dir_fd_at (self->repo_dir_fd, "objects",
+ &self->objects_dir_fd, cancellable, error))
+ {
+ g_prefix_error (error, "Opening objects/ directory: ");
+ goto out;
+ }
+
+ self->writable = faccessat (self->objects_dir_fd, ".", W_OK, 0) == 0;
if (fstat (self->objects_dir_fd, &stbuf) != 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]