| 1 | /* |
| 2 | * Copyright (C) 2020 - Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License, version 2 only, as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with |
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 15 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | */ |
| 17 | |
| 18 | #ifndef FD_TRACKER_INODE_H |
| 19 | #define FD_TRACKER_INODE_H |
| 20 | |
| 21 | #include <common/compat/directory-handle.h> |
| 22 | #include <stdbool.h> |
| 23 | |
| 24 | struct lttng_inode; |
| 25 | struct lttng_inode_registry; |
| 26 | struct lttng_unlinked_file_directory; |
| 27 | |
| 28 | /* |
| 29 | * The unlinked file pool is protected by the fd-tracker's lock. |
| 30 | * |
| 31 | * NOTE: the unlinked file pool can use a single file desriptor when unlinked |
| 32 | * files are present in the pool. This file descriptor is not accounted-for |
| 33 | * by the fd-tracker. Users of the fd-tracker should account for this extra |
| 34 | * file descriptor. |
| 35 | */ |
| 36 | struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create( |
| 37 | const char *path); |
| 38 | |
| 39 | void lttng_unlinked_file_pool_destroy( |
| 40 | struct lttng_unlinked_file_pool *pool); |
| 41 | |
| 42 | /* The inode registry is protected by the fd-tracker's lock. */ |
| 43 | struct lttng_inode_registry *lttng_inode_registry_create(void); |
| 44 | |
| 45 | struct lttng_inode *lttng_inode_registry_get_inode( |
| 46 | struct lttng_inode_registry *registry, |
| 47 | struct lttng_directory_handle *handle, |
| 48 | const char *path, |
| 49 | int fd, |
| 50 | struct lttng_unlinked_file_pool *pool); |
| 51 | |
| 52 | void lttng_inode_registry_destroy(struct lttng_inode_registry *registry); |
| 53 | |
| 54 | void lttng_inode_get_location(struct lttng_inode *inode, |
| 55 | const struct lttng_directory_handle **out_directory_handle, |
| 56 | const char **out_path); |
| 57 | |
| 58 | int lttng_inode_rename(struct lttng_inode *inode, |
| 59 | struct lttng_directory_handle *old_directory_handle, |
| 60 | const char *old_path, |
| 61 | struct lttng_directory_handle *new_directory_handle, |
| 62 | const char *new_path, |
| 63 | bool overwrite); |
| 64 | |
| 65 | int lttng_inode_unlink(struct lttng_inode *inode); |
| 66 | |
| 67 | void lttng_inode_put(struct lttng_inode *inode); |
| 68 | |
| 69 | #endif /* FD_TRACKER_INODE_H */ |