if (oldXattrs.hasField(key)) {
oldvalue = Extensible::anyToString(oldXattrs[key]);
- if (oldvalue != value) {
- syslog(LOG_DEBUG, "%s: replacing '%s' from '%s' to '%s' on '%s'", __func__, key.c_str(), oldvalue.c_str(), value.c_str(), lpath.c_str());
- wrapCall(attr_set(lpath.c_str(), key.c_str(), value.c_str(), value.size(), ATTR_REPLACE), "could not replace extended attribute '%s' on '%s'", key.c_str(), path.c_str());
- }
+ if (oldvalue != value)
+ vfsSetXattr(path, lpath, key, value, ATTR_REPLACE);
oldXattrs.erase(key);
} else {
- syslog(LOG_DEBUG, "%s: creating '%s' = '%s' on '%s'", __func__, key.c_str(), value.c_str(), lpath.c_str());
- wrapCall(attr_set(lpath.c_str(), key.c_str(), value.c_str(), value.size(), ATTR_CREATE), "could not create extended attribute '%s' on '%s'", key.c_str(), path.c_str());
+ vfsSetXattr(path, lpath, key, value, ATTR_CREATE);
}
}
for (it = oldXattrs.begin(); it != oldXattrs.end(); it++) {
+void VfsCatalog::vfsSetXattr(const std::string& path, const std::string& lpath, const std::string key, const std::string value, int flags) {
+ switch (flags & (ATTR_REPLACE | ATTR_CREATE)) {
+ case ATTR_REPLACE:
+ syslog(LOG_DEBUG, "%s: replacing '%s' -> '%s' on '%s'", __func__, key.c_str(), value.c_str(), lpath.c_str());
+ wrapCall(attr_set(lpath.c_str(), key.c_str(), value.c_str(), value.size(), flags), "could not replace extended attribute '%s' on '%s'", key.c_str(), path.c_str());
+ break;
+ case ATTR_CREATE:
+ syslog(LOG_DEBUG, "%s: creating '%s' -> '%s' on '%s'", __func__, key.c_str(), value.c_str(), lpath.c_str());
+ wrapCall(attr_set(lpath.c_str(), key.c_str(), value.c_str(), value.size(), flags), "could not create extended attribute '%s' on '%s'", key.c_str(), path.c_str());
+ break;
+ default:
+ syslog(LOG_DEBUG, "%s: setting '%s' -> '%s' on '%s'", __func__, key.c_str(), value.c_str(), lpath.c_str());
+ wrapCall(attr_set(lpath.c_str(), key.c_str(), value.c_str(), value.size(), flags), "could not set extended attribute '%s' on '%s'", key.c_str(), path.c_str());
+ break;
+ }
+}
+
+
+
regex_t *VfsCatalog::vfsCompileRegex(const char *name, const std::string value) throw (DmException) {
regex_t regex;
int ret;
ExtendedStat vfsExtendedStat(const std::string& name, const std::string& path, bool follow) throw (DmException);
PrivateDir* vfsOpenDir(const std::string& lpath, const std::string& path) throw (DmException);
Extensible vfsGetXattrs(const std::string& path, const std::string& lpath, bool follow) throw (DmException);
+ void vfsSetXattr(const std::string& path, const std::string& lpath, const std::string key, const std::string value, int flags);
regex_t *vfsCompileRegex(const char *name, const std::string value) throw (DmException);
bool vfsEvalRegex(regex_t *allowRegex, regex_t *denyRegex, const char *subj);