1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 #include "cephfs_features.h"
8 #include <fmt/format.h>
10 static const std::array feature_names
28 "notify_session_state",
33 static_assert(feature_names
.size() == CEPHFS_FEATURE_MAX
+ 1);
35 std::string_view
cephfs_feature_name(size_t id
)
37 if (id
> feature_names
.size())
39 return feature_names
[id
];
42 int cephfs_feature_from_name(std::string_view name
)
44 if (name
== "reserved") {
47 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
48 if (name
== feature_names
[i
])
54 std::string
cephfs_stringify_features(const feature_bitset_t
& features
)
56 CachedStackStringStream css
;
59 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
60 if (!features
.test(i
))
64 *css
<< i
<< "=" << cephfs_feature_name(i
);
71 void cephfs_dump_features(ceph::Formatter
*f
, const feature_bitset_t
& features
)
73 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
74 if (!features
.test(i
))
76 f
->dump_string(fmt::format("feature_{}", i
),
77 cephfs_feature_name(i
));