X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Ffd-tracker%2Finode.c;h=16dd49a6ff2c95230efd1aba28fe2788d11c5722;hp=28825b106c6f2c69051e4de96e5cac26e8af7652;hb=640b9481e1805d314256361ed49d55dcc35d6172;hpb=f7c3ffd79ddcece895eb0de616001d549aced5fc diff --git a/src/common/fd-tracker/inode.c b/src/common/fd-tracker/inode.c index 28825b106..16dd49a6f 100644 --- a/src/common/fd-tracker/inode.c +++ b/src/common/fd-tracker/inode.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2020 - Jérémie Galarneau + * Copyright (C) 2020 Jérémie Galarneau * - * 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 @@ -143,6 +133,12 @@ static int lttng_unlinked_file_pool_add_inode( } 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, @@ -290,7 +286,19 @@ 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, +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; +} + +void lttng_inode_borrow_location(struct lttng_inode *inode, const struct lttng_directory_handle **out_directory_handle, const char **out_path) { @@ -514,6 +522,10 @@ struct lttng_inode *lttng_inode_registry_get_inode( 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);