Commit | Line | Data |
---|---|---|
7a278c8e | 1 | /* |
ea0b4b9e | 2 | * fs.c |
7a278c8e | 3 | * |
ea0b4b9e | 4 | * Babeltrace CTF file system Reader Component |
7a278c8e | 5 | * |
f3bc2010 | 6 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
7a278c8e JG |
7 | * |
8 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
9 | * | |
10 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
11 | * of this software and associated documentation files (the "Software"), to deal | |
12 | * in the Software without restriction, including without limitation the rights | |
13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
14 | * copies of the Software, and to permit persons to whom the Software is | |
15 | * furnished to do so, subject to the following conditions: | |
16 | * | |
17 | * The above copyright notice and this permission notice shall be included in | |
18 | * all copies or substantial portions of the Software. | |
19 | * | |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
26 | * SOFTWARE. | |
27 | */ | |
28 | ||
ea0b4b9e JG |
29 | #include <babeltrace/plugin/plugin-system.h> |
30 | #include <glib.h> | |
31 | #include <assert.h> | |
6a29d9fd | 32 | #include "fs-internal.h" |
ea0b4b9e JG |
33 | |
34 | static bool ctf_fs_debug; | |
35 | ||
36 | static | |
37 | struct ctf_fs_component *ctf_fs_create(struct bt_value *params) | |
38 | { | |
39 | return g_new0(struct ctf_fs_component, 1); | |
40 | } | |
41 | ||
42 | static | |
43 | void ctf_fs_destroy(void *data) | |
44 | { | |
45 | g_free(data); | |
46 | } | |
bfd20a42 | 47 | |
f3bc2010 | 48 | BT_HIDDEN |
ea0b4b9e JG |
49 | enum bt_component_status ctf_fs_iterator_init(struct bt_component *source, |
50 | struct bt_notification_iterator *it) | |
4c1456f0 | 51 | { |
ea0b4b9e JG |
52 | enum bt_component_status ret = BT_COMPONENT_STATUS_OK; |
53 | ||
54 | assert(source && it); | |
55 | return ret; | |
4c1456f0 JG |
56 | } |
57 | ||
ea0b4b9e JG |
58 | BT_HIDDEN |
59 | enum bt_component_status ctf_fs_init(struct bt_component *source, | |
5c80adeb | 60 | struct bt_value *params) |
ea0b4b9e JG |
61 | { |
62 | struct ctf_fs_component *ctf_fs; | |
63 | enum bt_component_status ret = BT_COMPONENT_STATUS_OK; | |
64 | ||
65 | assert(source); | |
66 | ctf_fs_debug = g_strcmp0(getenv("CTF_FS_DEBUG"), "1") == 0; | |
67 | ctf_fs = ctf_fs_create(params); | |
68 | if (!ctf_fs) { | |
69 | ret = BT_COMPONENT_STATUS_NOMEM; | |
70 | goto end; | |
71 | } | |
4c1456f0 | 72 | |
ea0b4b9e JG |
73 | ret = bt_component_set_destroy_cb(source, ctf_fs_destroy); |
74 | if (ret != BT_COMPONENT_STATUS_OK) { | |
75 | goto error; | |
76 | } | |
77 | ||
78 | ret = bt_component_set_private_data(source, ctf_fs); | |
79 | if (ret != BT_COMPONENT_STATUS_OK) { | |
80 | goto error; | |
81 | } | |
82 | ||
83 | ret = bt_component_source_set_iterator_init_cb(source, | |
84 | ctf_fs_iterator_init); | |
85 | if (ret != BT_COMPONENT_STATUS_OK) { | |
86 | goto error; | |
87 | } | |
88 | end: | |
89 | return ret; | |
90 | error: | |
91 | (void) bt_component_set_private_data(source, NULL); | |
92 | ctf_fs_destroy(ctf_fs); | |
93 | return ret; | |
94 | } |