Relaxed reaction on User Extended Attributes errors:
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 17 Oct 2013 19:44:45 +0000 (21:44 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 23 Feb 2014 13:16:18 +0000 (14:16 +0100)
- 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).

src/VfsNs.cpp

index 658546e..fee71c8 100644 (file)
@@ -161,6 +161,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);
 }
@@ -194,14 +196,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;
 }
 
@@ -260,7 +263,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++) {