1 | /*
|
---|
2 | * Copyright (c) 2025 Miroslav Cimerman
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup hr
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /**
|
---|
33 | * @file
|
---|
34 | */
|
---|
35 |
|
---|
36 | #include <loc.h>
|
---|
37 | #include <stdio.h>
|
---|
38 |
|
---|
39 | #include "../superblock.h"
|
---|
40 | #include "../util.h"
|
---|
41 | #include "../var.h"
|
---|
42 |
|
---|
43 | static errno_t meta_noop_probe(service_id_t, void **);
|
---|
44 | static errno_t meta_noop_init_vol2meta(hr_volume_t *);
|
---|
45 | static errno_t meta_noop_init_meta2vol(const list_t *, hr_volume_t *);
|
---|
46 | static errno_t meta_noop_erase_block(service_id_t);
|
---|
47 | static bool meta_noop_compare_uuids(const void *, const void *);
|
---|
48 | static void meta_noop_inc_counter(hr_volume_t *);
|
---|
49 | static errno_t meta_noop_save(hr_volume_t *, bool);
|
---|
50 | static errno_t meta_noop_save_ext(hr_volume_t *, size_t, bool);
|
---|
51 | static const char *meta_noop_get_devname(const void *);
|
---|
52 | static hr_level_t meta_noop_get_level(const void *);
|
---|
53 | static uint64_t meta_noop_get_data_offset(void);
|
---|
54 | static size_t meta_noop_get_size(void);
|
---|
55 | static uint8_t meta_noop_get_flags(void);
|
---|
56 | static hr_metadata_type_t meta_noop_get_type(void);
|
---|
57 | static void meta_noop_dump(const void *);
|
---|
58 |
|
---|
59 | hr_superblock_ops_t noop_ops = {
|
---|
60 | .probe = meta_noop_probe,
|
---|
61 | .init_vol2meta = meta_noop_init_vol2meta,
|
---|
62 | .init_meta2vol = meta_noop_init_meta2vol,
|
---|
63 | .erase_block = meta_noop_erase_block,
|
---|
64 | .compare_uuids = meta_noop_compare_uuids,
|
---|
65 | .inc_counter = meta_noop_inc_counter,
|
---|
66 | .save = meta_noop_save,
|
---|
67 | .save_ext = meta_noop_save_ext,
|
---|
68 | .get_devname = meta_noop_get_devname,
|
---|
69 | .get_level = meta_noop_get_level,
|
---|
70 | .get_data_offset = meta_noop_get_data_offset,
|
---|
71 | .get_size = meta_noop_get_size,
|
---|
72 | .get_flags = meta_noop_get_flags,
|
---|
73 | .get_type = meta_noop_get_type,
|
---|
74 | .dump = meta_noop_dump
|
---|
75 | };
|
---|
76 |
|
---|
77 | static errno_t meta_noop_probe(service_id_t svc_id, void **rmd)
|
---|
78 | {
|
---|
79 | HR_DEBUG("%s()", __func__);
|
---|
80 |
|
---|
81 | return ENOTSUP;
|
---|
82 | }
|
---|
83 |
|
---|
84 | static errno_t meta_noop_init_vol2meta(hr_volume_t *vol)
|
---|
85 | {
|
---|
86 | HR_DEBUG("%s()", __func__);
|
---|
87 |
|
---|
88 | return EOK;
|
---|
89 | }
|
---|
90 |
|
---|
91 | static errno_t meta_noop_init_meta2vol(const list_t *list, hr_volume_t *vol)
|
---|
92 | {
|
---|
93 | HR_DEBUG("%s()", __func__);
|
---|
94 |
|
---|
95 | return ENOTSUP;
|
---|
96 | }
|
---|
97 |
|
---|
98 | static errno_t meta_noop_erase_block(service_id_t dev)
|
---|
99 | {
|
---|
100 | HR_DEBUG("%s()", __func__);
|
---|
101 |
|
---|
102 | return EOK;
|
---|
103 | }
|
---|
104 |
|
---|
105 | static bool meta_noop_compare_uuids(const void *m1p, const void *m2p)
|
---|
106 | {
|
---|
107 | return false;
|
---|
108 | }
|
---|
109 |
|
---|
110 | static void meta_noop_inc_counter(hr_volume_t *vol)
|
---|
111 | {
|
---|
112 | (void)vol;
|
---|
113 | }
|
---|
114 |
|
---|
115 | static errno_t meta_noop_save(hr_volume_t *vol, bool with_state_callback)
|
---|
116 | {
|
---|
117 | HR_DEBUG("%s()", __func__);
|
---|
118 |
|
---|
119 | return EOK;
|
---|
120 | }
|
---|
121 |
|
---|
122 | static errno_t meta_noop_save_ext(hr_volume_t *vol, size_t ext_idx,
|
---|
123 | bool with_state_callback)
|
---|
124 | {
|
---|
125 | HR_DEBUG("%s()", __func__);
|
---|
126 |
|
---|
127 | return EOK;
|
---|
128 | }
|
---|
129 |
|
---|
130 | static const char *meta_noop_get_devname(const void *md_v)
|
---|
131 | {
|
---|
132 | return NULL;
|
---|
133 | }
|
---|
134 |
|
---|
135 | static hr_level_t meta_noop_get_level(const void *md_v)
|
---|
136 | {
|
---|
137 | return HR_LVL_UNKNOWN;
|
---|
138 | }
|
---|
139 |
|
---|
140 | static uint64_t meta_noop_get_data_offset(void)
|
---|
141 | {
|
---|
142 | return 0;
|
---|
143 | }
|
---|
144 |
|
---|
145 | static size_t meta_noop_get_size(void)
|
---|
146 | {
|
---|
147 | return 0;
|
---|
148 | }
|
---|
149 |
|
---|
150 | static uint8_t meta_noop_get_flags(void)
|
---|
151 | {
|
---|
152 | HR_DEBUG("%s()", __func__);
|
---|
153 |
|
---|
154 | uint8_t flags = 0;
|
---|
155 |
|
---|
156 | flags |= HR_METADATA_HOTSPARE_SUPPORT;
|
---|
157 | flags |= HR_METADATA_ALLOW_REBUILD;
|
---|
158 |
|
---|
159 | return flags;
|
---|
160 | }
|
---|
161 |
|
---|
162 | static hr_metadata_type_t meta_noop_get_type(void)
|
---|
163 | {
|
---|
164 | HR_DEBUG("%s()", __func__);
|
---|
165 |
|
---|
166 | return HR_METADATA_NOOP;
|
---|
167 | }
|
---|
168 |
|
---|
169 | static void meta_noop_dump(const void *md_v)
|
---|
170 | {
|
---|
171 | HR_DEBUG("%s()", __func__);
|
---|
172 |
|
---|
173 | printf("NOOP Metadata\n");
|
---|
174 | }
|
---|
175 |
|
---|
176 | /** @}
|
---|
177 | */
|
---|