for ( ; ; ++i) {
candidate = lfn_get_short_name(hoid, i);
candidate_path = get_full_path(path, candidate);
- r = do_getxattr(candidate_path.c_str(), LFN_ATTR.c_str(), buf, sizeof(buf));
+ r = do_getxattr(candidate_path.c_str(), get_lfn_attr().c_str(), buf, sizeof(buf));
if (r < 0) {
if (errno != ENODATA && errno != ENOENT)
return -errno;
return 0;
string full_path = get_full_path(path, mangled_name);
string full_name = lfn_generate_object_name(hoid);
- return do_setxattr(full_path.c_str(), LFN_ATTR.c_str(),
+ return do_setxattr(full_path.c_str(), get_lfn_attr().c_str(),
full_name.c_str(), full_name.size());
}
// Get lfn_attr
string full_path = get_full_path(path, short_name);
char attr[PATH_MAX];
- int r = do_getxattr(full_path.c_str(), LFN_ATTR.c_str(), attr, sizeof(attr) - 1);
+ int r = do_getxattr(full_path.c_str(), get_lfn_attr().c_str(), attr, sizeof(attr) - 1);
if (r < 0)
return -errno;
if (r < (int)sizeof(attr))
protected:
const uint32_t index_version;
+private:
+ string lfn_attribute;
+
public:
/// Constructor
LFNIndex(
const char *base_path, ///< [in] path to Index root
- int index_version)
- : base_path(base_path), index_version(index_version) {}
+ uint32_t index_version)
+ : base_path(base_path), index_version(index_version) {
+ if (index_version == HASH_INDEX_TAG) {
+ lfn_attribute = LFN_ATTR;
+ } else {
+ char buf[100];
+ snprintf(buf, sizeof(buf), "%d", index_version);
+ lfn_attribute = LFN_ATTR + string(buf);
+ }
+ }
/// Virtual destructor
virtual ~LFNIndex() {}
private:
/* lfn translation functions */
+
+ /**
+ * Gets the version specific lfn attribute tag
+ */
+ const string &get_lfn_attr() const {
+ return lfn_attribute;
+ }
+
/**
* Gets the filename corresponsing to hoid in path.
*