}
vfsUpdateStat(meta, xattrs);
+ meta.stat.st_size = xattrs.getU64(VFS_XATTR "size", 0);
meta["pool"] = std::string("vfs");
void VfsCatalog::setSize(const std::string& path, size_t newSize) throw (DmException)
{
- ExtendedStat file;
+ ExtendedStat meta;
+ char buf[20];
if (vfsCheckPermissions(path, S_IWRITE))
vfsThrow(EACCES, "not enough permissions for '%s'", clientName.c_str());
- file = this->vfsExtendedStat(path);
- if (S_ISDIR(file.stat.st_mode))
- vfsThrow(EISDIR, "'%s' is directory, can not truncate", path.c_str());
- if (getUid(this->secCtx_) != file.stat.st_uid &&
- checkPermissions(this->secCtx_, file.acl, file.stat, S_IWRITE) != 0) {
- vfsThrow(EACCES, "not enough permissions for '%s' to truncate '%s'", clientName.c_str(), path.c_str());
+ meta = this->vfsExtendedStat(path);
+
+ if (S_ISDIR(meta.stat.st_mode))
+ vfsThrow(EISDIR, "'%s' is directory, can not set size", path.c_str());
+
+ if (getUid(this->secCtx_) != meta.stat.st_uid &&
+ checkPermissions(this->secCtx_, meta.acl, meta.stat, S_IWRITE) != 0) {
+ vfsThrow(EACCES, "not enough permissions for '%s' to set size of '%s'", clientName.c_str(), path.c_str());
}
- wrapCall(truncate(getLocalPath(path).c_str(), newSize));
+
+ snprintf(buf, sizeof buf, "%zu", newSize);
+ vfsSetXattr(path, getLocalPath(path), VFS_XATTR "size", buf, 0);
}