lttng-create(1): specify that `--shm-path` only applies to UST channels
[lttng-tools.git] / src / common / fs-handle.c
CommitLineData
f5ea0241 1/*
ab5be9fa 2 * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
f5ea0241 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
f5ea0241 5 *
f5ea0241
JG
6 */
7
f5ea0241 8#include <common/fs-handle-internal.h>
8bb66c3c
JG
9#include <common/fs-handle.h>
10#include <common/readwrite.h>
f5ea0241
JG
11
12LTTNG_HIDDEN
13int fs_handle_get_fd(struct fs_handle *handle)
14{
15 return handle->get_fd(handle);
16}
17
18LTTNG_HIDDEN
19void fs_handle_put_fd(struct fs_handle *handle)
20{
21 return handle->put_fd(handle);
22}
23
24LTTNG_HIDDEN
25int fs_handle_unlink(struct fs_handle *handle)
26{
27 return handle->unlink(handle);
28}
29
30LTTNG_HIDDEN
31int fs_handle_close(struct fs_handle *handle)
32{
33 return handle->close(handle);
34}
8bb66c3c
JG
35
36LTTNG_HIDDEN
37ssize_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);
49end:
50 return ret;
51}
52
53LTTNG_HIDDEN
54ssize_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);
66end:
67 return ret;
68}
69
70LTTNG_HIDDEN
71int fs_handle_truncate(struct fs_handle *handle, off_t offset)
72{
3e778ab0 73 int ret;
8bb66c3c
JG
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);
83end:
84 return ret;
85}
86
87LTTNG_HIDDEN
3e778ab0 88off_t fs_handle_seek(struct fs_handle *handle, off_t offset, int whence)
8bb66c3c 89{
3e778ab0 90 off_t ret;
8bb66c3c
JG
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);
100end:
101 return ret;
102}
This page took 0.033813 seconds and 4 git commands to generate.