Skip to content

Commit 2d89d3b

Browse files
committed
sun: support ZFS without CTF on Solaris 11.4
1 parent 625aaef commit 2d89d3b

1 file changed

Lines changed: 72 additions & 8 deletions

File tree

‎lib/dialects/sun/dnode.c‎

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,6 +4899,71 @@ static int read_nvn(struct lsof_context *ctx, /* context */
48994899
}
49004900

49014901
#if defined(HAS_ZFS)
4902+
#if solaris >= 110000
4903+
/*
4904+
* Solaris 11.4 CBE ZFS has no znode/zfsvfs CTF types. The offsets below
4905+
* come from the kernel's own mdb type information:
4906+
*
4907+
* znode_t: z_zfsvfs=0x00, z_vnode=0x08, z_id=0x10,
4908+
* z_size=0xc0, z_links=0x118 (z_phys is absent)
4909+
* zfsvfs_t: z_vfs=0x00
4910+
*/
4911+
# define ZFS114_OFF_Z_ZFSVFS 0x00
4912+
# define ZFS114_OFF_Z_VNODE 0x08
4913+
# define ZFS114_OFF_Z_ID 0x10
4914+
# define ZFS114_OFF_Z_SIZE 0xc0
4915+
# define ZFS114_OFF_Z_LINKS 0x118
4916+
# define ZFS114_OFF_ZVFS_Z_VFS 0x00
4917+
4918+
static int read_znode114(struct lsof_context *ctx, KA_T na, KA_T nza,
4919+
znode_t *zn) {
4920+
char tbuf[32];
4921+
4922+
if (!nza) {
4923+
(void)snpf(Namech, Namechl - 1, "node at %s: no znode: %s",
4924+
print_kptr(na, tbuf, sizeof(tbuf)),
4925+
print_kptr(nza, (char *)NULL, 0));
4926+
Namech[Namechl - 1] = '\0';
4927+
enter_nm(ctx, Namech);
4928+
return (1);
4929+
}
4930+
if (kread(ctx, nza + ZFS114_OFF_Z_ZFSVFS, (char *)&zn->z_zfsvfs,
4931+
sizeof(zn->z_zfsvfs)) ||
4932+
kread(ctx, nza + ZFS114_OFF_Z_VNODE, (char *)&zn->z_vnode,
4933+
sizeof(zn->z_vnode)) ||
4934+
kread(ctx, nza + ZFS114_OFF_Z_ID, (char *)&zn->z_id,
4935+
sizeof(zn->z_id)) ||
4936+
kread(ctx, nza + ZFS114_OFF_Z_SIZE, (char *)&zn->z_size,
4937+
sizeof(zn->z_size)) ||
4938+
kread(ctx, nza + ZFS114_OFF_Z_LINKS, (char *)&zn->z_links,
4939+
sizeof(zn->z_links))) {
4940+
(void)snpf(Namech, Namechl - 1, "node at %s: can't read znode: %s",
4941+
print_kptr(na, tbuf, sizeof(tbuf)),
4942+
print_kptr(nza, (char *)NULL, 0));
4943+
Namech[Namechl - 1] = '\0';
4944+
enter_nm(ctx, Namech);
4945+
return (1);
4946+
}
4947+
zn->z_phys = (znode_phys_t *)NULL;
4948+
return (0);
4949+
}
4950+
4951+
static int read_zvfs114(struct lsof_context *ctx, KA_T nza, KA_T nzva,
4952+
zfsvfs_t *zv) {
4953+
char tbuf[32];
4954+
4955+
if (!nzva || kread(ctx, nzva + ZFS114_OFF_ZVFS_Z_VFS,
4956+
(char *)&zv->z_vfs, sizeof(zv->z_vfs))) {
4957+
(void)snpf(Namech, Namechl - 1, "znode at %s: can't read zfsvfs: %s",
4958+
print_kptr(nza, tbuf, sizeof(tbuf)),
4959+
print_kptr(nzva, (char *)NULL, 0));
4960+
Namech[Namechl - 1] = '\0';
4961+
enter_nm(ctx, Namech);
4962+
return (1);
4963+
}
4964+
return (0);
4965+
}
4966+
#endif /* solaris >= 110000 */
49024967
/*
49034968
* read_nzn() - read node's ZFS node
49044969
*/
@@ -4914,13 +4979,10 @@ static int read_nzn(struct lsof_context *ctx, /* context */
49144979
znode_phys_t zp; /* physical znode */
49154980

49164981
(void)CTF_init(ctx, &ZFS_ctfs, ZFS_MOD_FORMAT, ZFS_requests);
4917-
if (ZFS_ctfs < 0) {
4918-
(void)snpf(Namech, Namechl - 1, "node at %s: CTF information unavailable",
4919-
print_kptr(na, tbuf, sizeof(tbuf)));
4920-
Namech[Namechl - 1] = '\0';
4921-
enter_nm(ctx, Namech);
4922-
return (1);
4923-
}
4982+
#if solaris >= 110000
4983+
if (ZFS_ctfs < 0)
4984+
return read_znode114(ctx, na, nza, zn);
4985+
#endif /* solaris >= 110000 */
49244986
if (!nza || CTF_MEMBER_READ(nza, zn, znode_members, z_zfsvfs) ||
49254987
CTF_MEMBER_READ(nza, zn, znode_members, z_vnode) ||
49264988
CTF_MEMBER_READ(nza, zn, znode_members, z_id) ||
@@ -5016,8 +5078,10 @@ static int read_nzvfs(struct lsof_context *ctx, /* context */
50165078
char tbuf[32];
50175079

50185080
(void)CTF_init(ctx, &ZFS_ctfs, ZFS_MOD_FORMAT, ZFS_requests);
5081+
#if solaris >= 110000
50195082
if (ZFS_ctfs < 0)
5020-
return (1);
5083+
return read_zvfs114(ctx, nza, nzva, zv);
5084+
#endif /* solaris >= 110000 */
50215085
if (!nzva || CTF_MEMBER_READ(nzva, zv, zfsvfs_members, z_vfs)) {
50225086
(void)snpf(Namech, Namechl - 1, "znode at %s: can't read zfsvfs: %s",
50235087
print_kptr(nza, tbuf, sizeof(tbuf)),

0 commit comments

Comments
 (0)