Fix: kconsumer: missing wait for metadata thread in do_sync_metadata
[lttng-tools.git] / src / common / fs-handle.c
1 /*
2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #include <common/fs-handle-internal.h>
9 #include <common/fs-handle.h>
10 #include <common/readwrite.h>
11
12 LTTNG_HIDDEN
13 int fs_handle_get_fd(struct fs_handle *handle)
14 {
15 return handle->get_fd(handle);
16 }
17
18 LTTNG_HIDDEN
19 void fs_handle_put_fd(struct fs_handle *handle)
20 {
21 return handle->put_fd(handle);
22 }
23
24 LTTNG_HIDDEN
25 int fs_handle_unlink(struct fs_handle *handle)
26 {
27 return handle->unlink(handle);
28 }
29
30 LTTNG_HIDDEN
31 int fs_handle_close(struct fs_handle *handle)
32 {
33 return handle->close(handle);
34 }
35
36 LTTNG_HIDDEN
37 ssize_t fs_handle_read(struct fs_handle *handle, void *buf, size_t count)
38 {
39 ssize_t ret;
40 const int fd = fs_handle_get_fd(handle);
41
42 if (fd < 0) {
43 ret = -1;
44 goto end;
45 }
46
47 ret = lttng_read(fd, buf, count);
48 fs_handle_put_fd(handle);
49 end:
50 return ret;
51 }
52
53 LTTNG_HIDDEN
54 ssize_t fs_handle_write(struct fs_handle *handle, const void *buf, size_t count)
55 {
56 ssize_t ret;
57 const int fd = fs_handle_get_fd(handle);
58
59 if (fd < 0) {
60 ret = -1;
61 goto end;
62 }
63
64 ret = lttng_write(fd, buf, count);
65 fs_handle_put_fd(handle);
66 end:
67 return ret;
68 }
69
70 LTTNG_HIDDEN
71 int fs_handle_truncate(struct fs_handle *handle, off_t offset)
72 {
73 int ret;
74 const int fd = fs_handle_get_fd(handle);
75
76 if (fd < 0) {
77 ret = -1;
78 goto end;
79 }
80
81 ret = ftruncate(fd, offset);
82 fs_handle_put_fd(handle);
83 end:
84 return ret;
85 }
86
87 LTTNG_HIDDEN
88 off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence)
89 {
90 off_t ret;
91 const int fd = fs_handle_get_fd(handle);
92
93 if (fd < 0) {
94 ret = -1;
95 goto end;
96 }
97
98 ret = lseek(fd, offset, whence);
99 fs_handle_put_fd(handle);
100 end:
101 return ret;
102 }
This page took 0.030852 seconds and 4 git commands to generate.