mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-23 02:05:01 +03:00
Add ostree_repo_is_writable()
This commit is contained in:
parent
f89032f581
commit
a25c7fab12
@ -217,6 +217,7 @@ ostree_repo_new_default
|
|||||||
ostree_repo_open
|
ostree_repo_open
|
||||||
ostree_repo_set_disable_fsync
|
ostree_repo_set_disable_fsync
|
||||||
ostree_repo_is_system
|
ostree_repo_is_system
|
||||||
|
ostree_repo_is_writable
|
||||||
ostree_repo_create
|
ostree_repo_create
|
||||||
ostree_repo_get_path
|
ostree_repo_get_path
|
||||||
ostree_repo_get_mode
|
ostree_repo_get_mode
|
||||||
|
@ -65,6 +65,7 @@ struct OstreeRepo {
|
|||||||
|
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
gboolean writable;
|
gboolean writable;
|
||||||
|
GError *writable_error;
|
||||||
gboolean in_transaction;
|
gboolean in_transaction;
|
||||||
gboolean disable_fsync;
|
gboolean disable_fsync;
|
||||||
GHashTable *loose_object_devino_hash;
|
GHashTable *loose_object_devino_hash;
|
||||||
|
@ -381,6 +381,7 @@ ostree_repo_finalize (GObject *object)
|
|||||||
g_clear_pointer (&self->txn_refs, g_hash_table_destroy);
|
g_clear_pointer (&self->txn_refs, g_hash_table_destroy);
|
||||||
g_clear_pointer (&self->cached_meta_indexes, (GDestroyNotify) g_ptr_array_unref);
|
g_clear_pointer (&self->cached_meta_indexes, (GDestroyNotify) g_ptr_array_unref);
|
||||||
g_clear_pointer (&self->cached_content_indexes, (GDestroyNotify) g_ptr_array_unref);
|
g_clear_pointer (&self->cached_content_indexes, (GDestroyNotify) g_ptr_array_unref);
|
||||||
|
g_clear_error (&self->writable_error);
|
||||||
g_clear_pointer (&self->object_sizes, (GDestroyNotify) g_hash_table_unref);
|
g_clear_pointer (&self->object_sizes, (GDestroyNotify) g_hash_table_unref);
|
||||||
g_mutex_clear (&self->cache_lock);
|
g_mutex_clear (&self->cache_lock);
|
||||||
g_mutex_clear (&self->txn_stats_lock);
|
g_mutex_clear (&self->txn_stats_lock);
|
||||||
@ -551,6 +552,28 @@ ostree_repo_is_system (OstreeRepo *repo)
|
|||||||
return g_file_equal (repo->repodir, default_repo_path);
|
return g_file_equal (repo->repodir, default_repo_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ostree_repo_is_writable:
|
||||||
|
* @self: Repo
|
||||||
|
* @error: a #GError
|
||||||
|
*
|
||||||
|
* Returns whether the repository is writable by the current user.
|
||||||
|
* If the repository is not writable, the @error indicates why.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if this repository is writable
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
ostree_repo_is_writable (OstreeRepo *self,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (self->inited, FALSE);
|
||||||
|
|
||||||
|
if (error != NULL && self->writable_error != NULL)
|
||||||
|
*error = g_error_copy (self->writable_error);
|
||||||
|
|
||||||
|
return self->writable;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_repo_get_config:
|
* ostree_repo_get_config:
|
||||||
* @self:
|
* @self:
|
||||||
@ -1339,6 +1362,11 @@ ostree_repo_open (OstreeRepo *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
self->writable = faccessat (self->objects_dir_fd, ".", W_OK, 0) == 0;
|
self->writable = faccessat (self->objects_dir_fd, ".", W_OK, 0) == 0;
|
||||||
|
if (!self->writable)
|
||||||
|
{
|
||||||
|
/* This is returned through ostree_repo_is_writable(). */
|
||||||
|
gs_set_error_from_errno (&self->writable_error, errno);
|
||||||
|
}
|
||||||
|
|
||||||
if (fstat (self->objects_dir_fd, &stbuf) != 0)
|
if (fstat (self->objects_dir_fd, &stbuf) != 0)
|
||||||
{
|
{
|
||||||
|
@ -55,6 +55,9 @@ void ostree_repo_set_disable_fsync (OstreeRepo *self,
|
|||||||
|
|
||||||
gboolean ostree_repo_is_system (OstreeRepo *repo);
|
gboolean ostree_repo_is_system (OstreeRepo *repo);
|
||||||
|
|
||||||
|
gboolean ostree_repo_is_writable (OstreeRepo *self,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_repo_create (OstreeRepo *self,
|
gboolean ostree_repo_create (OstreeRepo *self,
|
||||||
OstreeRepoMode mode,
|
OstreeRepoMode mode,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user