From: František Dvořák Date: Mon, 14 Oct 2013 20:16:03 +0000 (+0200) Subject: Relaxed reaction on User Extended Attributes errors: X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=e85bb100afe2c2ccba2dd7d6ef56420ab52d0a29;p=dmlite-plugins-vfs-old.git Relaxed reaction on User Extended Attributes errors: - catch and cancel exeption from vfsGetXattrs() - returns VFS_UID_NONE or VFS_GID_NONE (currently it keeps original filesystem values) It's good for dangling symlinks (they're always followed for xattrs). --- diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 83e4db5..37fad78 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -159,6 +159,8 @@ std::string VfsCatalog::getWorkingDir(void) throw (DmException) void VfsCatalog::vfsUpdateStat(ExtendedStat &xStat, Extensible xattrs) throw (DmException) { if (xattrs.hasField(VFS_XATTR "acl")) xStat.acl = Acl(xattrs.getString(VFS_XATTR "acl")); + else + xStat.acl = Acl(); xStat.stat.st_gid = xattrs.getUnsigned(VFS_XATTR "group", VFS_GID_NONE); xStat.stat.st_uid = xattrs.getUnsigned(VFS_XATTR "owner", VFS_UID_NONE); } @@ -192,14 +194,15 @@ ExtendedStat VfsCatalog::vfsSimpleStat(const std::string& name, const std::strin xStat.acl = Acl(); if (perms) { - xattrs = vfsGetXattrs(path, lpath, true, VFS_XATTR_TYPE_PERMS); - vfsUpdateStat(xStat, xattrs); - } else { - xStat.acl = Acl(); - xStat.stat.st_uid = VFS_UID_NONE; - xStat.stat.st_gid = VFS_GID_NONE; + try { + xattrs = vfsGetXattrs(path, lpath, true, VFS_XATTR_TYPE_PERMS); + } catch (DmException& e) { + // ignore - default owner and no ACLs + } } + vfsUpdateStat(xStat, xattrs); + return xStat; } @@ -258,7 +261,11 @@ ExtendedStat VfsCatalog::extendedStat(const std::string& path, bool follow) thro // owner, permissions and other atributes like the original file anyway. // ==> always follow the symlinks. // - xattrs = vfsGetXattrs(path, getLocalPath(path), true, VFS_XATTR_TYPE_ALL); + try { + xattrs = vfsGetXattrs(path, getLocalPath(path), true, VFS_XATTR_TYPE_ALL); + } catch (DmException& e) { + // ignore - default owner and no ACLs + } // copy non-VFS attributes for (it = xattrs.begin(); it != xattrs.end(); it++) {