///
+/// Update all ExtendedStat fields.
+/// Requires user extended attributes retrieved with VFS_XATTR_TYPE_ALL.
+///
+/// @param xStat Updated ExtendedStat class.
+/// @param xattrs User extended attributes (requires all).
+///
+void VfsCatalog::vfsUpdateExtendedStat(ExtendedStat &xStat, Extensible xattrs) throw (DmException) {
+ Extensible::const_iterator it;
+ std::string key;
+
+ // ownership and permissions parts
+ vfsUpdateStat(xStat, xattrs);
+
+ // copy non-VFS attributes
+ for (it = xattrs.begin(); it != xattrs.end(); it++) {
+ key = it->first;
+ if (!IS_VFS_XATTR(key.c_str()))
+ xStat[key] = xattrs[key];
+ }
+
+ // use VFS attributes
+ xStat.stat.st_size = xattrs.getU64(VFS_XATTR "size", 0);
+ if (xStat.hasField("checksum.md5")) {
+ xStat.csumtype = "MD";
+ xStat.csumvalue = xStat.getString("checksum.md5");
+ } else if (xStat.hasField("checksum.adler32")) {
+ xStat.csumtype = "AD";
+ xStat.csumvalue = xStat.getString("checksum.adler32");
+ } else if (xStat.hasField("checksum.crc32")) {
+ xStat.csumtype = "CS";
+ xStat.csumvalue = xStat.getString("checksum.crc32");
+ }
+
+ xStat["pool"] = std::string("vfs");
+}
+
+
+
+///
/// Do simple stat()/lstat() without setting st_nlink and checking permissions.
/// Optionally retrieves also the information related to permissions in
/// optimized way (using only attributes related to permissions).
// ignore - default owner and no ACLs
}
- // copy non-VFS attributes
- for (it = xattrs.begin(); it != xattrs.end(); it++) {
- key = it->first;
- if (!IS_VFS_XATTR(key.c_str()))
- meta[key] = xattrs[key];
- }
-
- vfsUpdateStat(meta, xattrs);
- meta.stat.st_size = xattrs.getU64(VFS_XATTR "size", 0);
- if (meta.hasField("checksum.md5")) {
- meta.csumtype = "MD";
- meta.csumvalue = meta.getString("checksum.md5");
- } else if (meta.hasField("checksum.adler32")) {
- meta.csumtype = "AD";
- meta.csumvalue = meta.getString("checksum.adler32");
- } else if (meta.hasField("checksum.crc32")) {
- meta.csumtype = "CS";
- meta.csumvalue = meta.getString("checksum.crc32");
- }
-
- meta["pool"] = std::string("vfs");
+ // use the retrieved xattrs
+ vfsUpdateExtendedStat(meta, xattrs);
#if 0
// XXX: black magic
ExtendedStat* VfsCatalog::readDirx(Directory* dir) throw (DmException)
{
PrivateDir *privateDir = static_cast<PrivateDir*>(dir);
+ Extensible xattrs;
struct dirent *ent = this->readDir(dir);
if (ent == NULL) return NULL;
privateDir->stat.status = ExtendedStat::kOnline;
privateDir->stat.parent = 0;
+ try {
+ xattrs = vfsGetXattrs(privateDir->path + '/' + ent->d_name, privateDir->lpath + '/' + ent->d_name, false, VFS_XATTR_TYPE_ALL);
+ } catch (DmException& e) {
+ // ignore - default owner and no ACLs
+ }
+ vfsUpdateExtendedStat(privateDir->stat, xattrs);
+
return &(privateDir->stat);
}
/// Relative paths are unchanged.
const std::string getLocalPath(const std::string &path);
void vfsUpdateStat(ExtendedStat &xStat, Extensible xattrs) throw (DmException);
+ void vfsUpdateExtendedStat(ExtendedStat &xStat, Extensible xattrs) throw (DmException);
ExtendedStat vfsSimpleStat(const std::string& name, const std::string& path, const std::string& lpath, bool follow, bool perms) throw (DmException);
ExtendedStat vfsExtendedStat(const std::string& path, bool follow = true, bool perms = true) throw (DmException);
PrivateDir* vfsOpenDir(const std::string& lpath, const std::string& path) throw (DmException);