Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174749760
D60265.id188502.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D60265.id188502.diff
View Options
diff --git a/stand/libsa/zfs/zfsimpl.c b/stand/libsa/zfs/zfsimpl.c
--- a/stand/libsa/zfs/zfsimpl.c
+++ b/stand/libsa/zfs/zfsimpl.c
@@ -3829,6 +3829,69 @@
return (0);
}
+static int
+zfs_sa_lookup(struct zfsmount *mount, const void *buf, size_t buflen,
+ enum zfs_sa_attr_id attr, void *value, size_t *size)
+{
+ const sa_hdr_phys_t *hdr;
+ uint16_t layout[ZFS_SA_MAX_ATTRS];
+ char layout_name[16];
+ size_t hdrsize, length, offset;
+ unsigned int i, j, length_idx;
+ int error;
+
+ hdr = buf;
+ if (buflen < sizeof(*hdr) || hdr->sa_magic != SA_MAGIC)
+ return (EIO);
+ error = zfs_sa_load(mount);
+ if (error != 0)
+ return (error);
+
+ memset(layout, 0xff, sizeof(layout));
+ i = SA_HDR_LAYOUT_NUM(hdr);
+ if (i == 0)
+ i = 1;
+ snprintf(layout_name, sizeof(layout_name), "%u", i);
+ error = zap_lookup(mount->spa, &mount->sa_layouts, layout_name,
+ sizeof(layout[0]), nitems(layout), layout);
+ if (error != 0)
+ return (error);
+
+ hdrsize = SA_HDR_SIZE(hdr);
+ if (hdrsize < sizeof(*hdr) || hdrsize > buflen)
+ return (EIO);
+ offset = hdrsize;
+ length_idx = 0;
+ for (i = 0; i < nitems(layout) && layout[i] != UINT16_MAX; i++) {
+ for (j = 0; j < nitems(zfs_sa_attrs); j++) {
+ if (mount->sa_attrs[j] != UINT64_MAX &&
+ SA_ATTR_NUM(mount->sa_attrs[j]) == layout[i])
+ break;
+ }
+ if (j == nitems(zfs_sa_attrs))
+ return (EIO);
+ length = SA_ATTR_LENGTH(mount->sa_attrs[j]);
+ if (length == 0) {
+ if (offsetof(sa_hdr_phys_t, sa_lengths) +
+ (length_idx + 1) * sizeof(hdr->sa_lengths[0]) >
+ hdrsize)
+ return (EIO);
+ length = hdr->sa_lengths[length_idx++];
+ }
+ if (offset > buflen || length > buflen - offset)
+ return (EIO);
+ if (j == attr) {
+ if (*size < length)
+ return (EOVERFLOW);
+ memcpy(value, (const char *)buf + offset, length);
+ *size = length;
+ return (0);
+ }
+ offset = roundup2(offset + length, 8);
+ }
+ return (ENOENT);
+}
+
static int
zfs_dnode_stat(struct zfsmount *mount, dnode_phys_t *dn, struct stat *sb,
uint64_t fsid_guid, uint64_t objnum)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 6, 5:45 PM (9 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40152194
Default Alt Text
D60265.id188502.diff (2 KB)
Attached To
Mode
D60265: stand: Lookup the offsets for this SA bundle
Attached
Detach File
Event Timeline
Log In to Comment