/*
- * Copyright (C) 2020 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <common/defaults.h>
}
pool->unlink_directory_handle = lttng_directory_handle_create(
pool->unlink_directory_path);
+ if (!pool->unlink_directory_handle) {
+ ERR("Failed to create directory handle to unlinked file pool at %s",
+ pool->unlink_directory_path);
+ ret = -1;
+ goto end;
+ }
}
ret = lttng_directory_handle_rename(inode->location.directory_handle,
urcu_ref_get(&inode->ref);
}
-struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
+LTTNG_HIDDEN struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create(
const char *path)
{
struct lttng_unlinked_file_pool *pool = zmalloc(sizeof(*pool));
+ if (!pool) {
+ goto error;
+ }
+
if (!path || *path != '/') {
ERR("Unlinked file pool must be created with an absolute path, path = \"%s\"",
path ? path : "NULL");
return NULL;
}
-void lttng_unlinked_file_pool_destroy(
+LTTNG_HIDDEN void lttng_unlinked_file_pool_destroy(
struct lttng_unlinked_file_pool *pool)
{
if (!pool) {
free(pool);
}
-void lttng_inode_put(struct lttng_inode *inode)
+LTTNG_HIDDEN void lttng_inode_put(struct lttng_inode *inode)
{
urcu_ref_put(&inode->ref, lttng_inode_release);
}
-void lttng_inode_get_location(struct lttng_inode *inode,
+LTTNG_HIDDEN struct lttng_directory_handle *
+lttng_inode_get_location_directory_handle(
+ struct lttng_inode *inode)
+{
+ if (inode->location.directory_handle) {
+ const bool reference_acquired = lttng_directory_handle_get(
+ inode->location.directory_handle);
+
+ assert(reference_acquired);
+ }
+ return inode->location.directory_handle;
+}
+
+LTTNG_HIDDEN void lttng_inode_borrow_location(struct lttng_inode *inode,
const struct lttng_directory_handle **out_directory_handle,
const char **out_path)
{
}
}
-int lttng_inode_rename(
+LTTNG_HIDDEN int lttng_inode_rename(
struct lttng_inode *inode,
struct lttng_directory_handle *old_directory_handle,
const char *old_path,
return ret;
}
-int lttng_inode_unlink(struct lttng_inode *inode)
+LTTNG_HIDDEN int lttng_inode_unlink(struct lttng_inode *inode)
{
int ret = 0;
return inode;
}
-struct lttng_inode_registry *lttng_inode_registry_create(void)
+LTTNG_HIDDEN struct lttng_inode_registry *lttng_inode_registry_create(void)
{
struct lttng_inode_registry *registry = zmalloc(sizeof(*registry));
return NULL;
}
-void lttng_inode_registry_destroy(struct lttng_inode_registry *registry)
+LTTNG_HIDDEN void lttng_inode_registry_destroy(
+ struct lttng_inode_registry *registry)
{
if (!registry) {
return;
free(registry);
}
-struct lttng_inode *lttng_inode_registry_get_inode(
+LTTNG_HIDDEN struct lttng_inode *lttng_inode_registry_get_inode(
struct lttng_inode_registry *registry,
struct lttng_directory_handle *handle,
const char *path,
inode = lttng_inode_create(&id, registry->inodes, unlinked_file_pool,
handle, path);
+ if (!inode) {
+ goto end_unlock;
+ }
+
node = cds_lfht_add_unique(registry->inodes,
lttng_inode_id_hash(&inode->id), lttng_inode_match,
&inode->id, &inode->registry_node);