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 static const std::array feature_names
27 static_assert(feature_names
.size() == CEPHFS_FEATURE_MAX
+ 1);
29 std::string_view
cephfs_feature_name(size_t id
)
31 if (id
> feature_names
.size())
33 return feature_names
[id
];
36 int cephfs_feature_from_name(std::string_view name
)
38 if (name
== "reserved") {
41 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
42 if (name
== feature_names
[i
])
48 std::string
cephfs_stringify_features(const feature_bitset_t
& features
)
50 CachedStackStringStream css
;
53 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
54 if (!features
.test(i
))
58 *css
<< i
<< "=" << cephfs_feature_name(i
);
65 void cephfs_dump_features(ceph::Formatter
*f
, const feature_bitset_t
& features
)
67 for (size_t i
= 0; i
< feature_names
.size(); ++i
) {
68 if (!features
.test(i
))
71 snprintf(s
, sizeof(s
), "feature_%zu", i
);
72 f
->dump_string(s
, cephfs_feature_name(i
));