@@ -223,6 +223,7 @@ fi
AC_MANUAL_FORMAT
AC_HAVE_LIBURCU_ATOMIC64
AC_USE_RADIX_TREE_FOR_INUMS
+AC_HAVE_FSVERITY_DESCRIPTOR
AC_CONFIG_FILES([include/builddefs])
AC_OUTPUT
@@ -78,6 +78,10 @@ LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
CFLAGS += -DENABLE_EDITLINE
endif
+ifeq ($(HAVE_FSVERITY_DESCR),yes)
+CFLAGS += -DHAVE_FSVERITY_DESCR
+endif
+
default: depend $(LTCOMMAND)
include $(BUILDRULES)
@@ -40,6 +40,7 @@ static int attr3_remote_merkledata_count(void *obj, int startoff);
static int attr_leaf_name_local_merkledata_count(void *obj, int startoff);
static int attr_leaf_name_local_merkleoff_count(void *obj, int startoff);
static int attr_leaf_name_remote_merkleoff_count(void *obj, int startoff);
+static int attr_leaf_vdesc_count(void *obj, int startoff);
const field_t attr_hfld[] = {
{ "", FLDT_ATTR, OI(0), C1, 0, TYP_NONE },
@@ -151,6 +152,8 @@ const field_t attr_leaf_name_flds[] = {
attr_leaf_name_remote_name_count, FLD_COUNT, TYP_NONE },
{ "merkle_pos", FLDT_UINT64X, OI(MKROFF(mk_pos)),
attr_leaf_name_remote_merkleoff_count, FLD_COUNT, TYP_NONE },
+ { "vdesc", FLDT_FSVERITY_DESCR, attr_leaf_name_local_value_offset,
+ attr_leaf_vdesc_count, FLD_COUNT|FLD_OFFSET, TYP_NONE },
{ NULL }
};
@@ -717,6 +720,34 @@ attr_leaf_name_remote_merkleoff_count(
return attr_leaf_entry_walk(obj, startoff, __leaf_remote_merkleoff_count);
}
+static int
+__leaf_vdesc_count(
+ struct xfs_attr_leafblock *leaf,
+ struct xfs_attr_leaf_entry *e,
+ int i)
+{
+ struct xfs_attr_leaf_name_local *l;
+
+ if (!(e->flags & XFS_ATTR_LOCAL))
+ return 0;
+ if ((e->flags & XFS_ATTR_NSP_ONDISK_MASK) != XFS_ATTR_VERITY)
+ return 0;
+
+ l = xfs_attr3_leaf_name_local(leaf, i);
+ if (l->namelen != XFS_VERITY_DESCRIPTOR_NAME_LEN)
+ return 0;
+
+ return 1;
+}
+
+static int
+attr_leaf_vdesc_count(
+ void *obj,
+ int startoff)
+{
+ return attr_leaf_entry_walk(obj, startoff, __leaf_vdesc_count);
+}
+
int
attr_size(
void *obj,
@@ -22,6 +22,7 @@ static int attr_sf_entry_pptr_count(void *obj, int startoff);
static int attr_sf_entry_merkleoff_count(void *obj, int startoff);
static int attr_sf_entry_merkledata_count(void *obj, int startoff);
+static int attr_sf_entry_vdesc_count(void *obj, int startoff);
const field_t attr_shortform_flds[] = {
{ "hdr", FLDT_ATTR_SF_HDR, OI(0), C1, 0, TYP_NONE },
@@ -66,6 +67,8 @@ const field_t attr_sf_entry_flds[] = {
attr_sf_entry_merkledata_count, FLD_COUNT | FLD_OFFSET, TYP_NONE },
{ "value", FLDT_CHARNS, attr_sf_entry_value_offset,
attr_sf_entry_value_count, FLD_COUNT|FLD_OFFSET, TYP_NONE },
+ { "vdesc", FLDT_FSVERITY_DESCR, attr_sf_entry_value_offset,
+ attr_sf_entry_vdesc_count, FLD_COUNT | FLD_OFFSET, TYP_NONE },
{ NULL }
};
@@ -112,8 +115,7 @@ attr_sf_entry_value_count(
if ((e->flags & XFS_ATTR_NSP_ONDISK_MASK) == XFS_ATTR_PARENT)
return 0;
- if ((e->flags & XFS_ATTR_NSP_ONDISK_MASK) == XFS_ATTR_VERITY &&
- e->namelen == sizeof(struct xfs_merkle_key))
+ if ((e->flags & XFS_ATTR_NSP_ONDISK_MASK) == XFS_ATTR_VERITY)
return 0;
return e->valuelen;
@@ -233,3 +235,19 @@ attr_sf_entry_merkledata_count(
return 0;
}
+
+static int
+attr_sf_entry_vdesc_count(
+ void *obj,
+ int startoff)
+{
+ struct xfs_attr_sf_entry *e;
+
+ ASSERT(bitoffs(startoff) == 0);
+ e = (struct xfs_attr_sf_entry *)((char *)obj + byteize(startoff));
+ if ((e->flags & XFS_ATTR_NSP_ONDISK_MASK) == XFS_ATTR_VERITY &&
+ e->namelen == XFS_VERITY_DESCRIPTOR_NAME_LEN)
+ return 1;
+
+ return 0;
+}
@@ -33,6 +33,25 @@ const field_t parent_flds[] = {
};
#undef PPOFF
+#ifdef HAVE_FSVERITY_DESCR
+# define OFF(f) bitize(offsetof(struct fsverity_descriptor, f))
+const field_t vdesc_flds[] = {
+ { "version", FLDT_UINT8D, OI(OFF(version)), C1, 0, TYP_NONE },
+ { "hash_algorithm", FLDT_UINT8D, OI(OFF(hash_algorithm)), C1, 0, TYP_NONE },
+ { "log_blocksize", FLDT_UINT8D, OI(OFF(log_blocksize)), C1, 0, TYP_NONE },
+ { "salt_size", FLDT_UINT8D, OI(OFF(salt_size)), C1, 0, TYP_NONE },
+ { "data_size", FLDT_UINT64D_LE, OI(OFF(data_size)), C1, 0, TYP_NONE },
+ { "root_hash", FLDT_HEXSTRING, OI(OFF(root_hash)), CI(64), 0, TYP_NONE },
+ { "salt", FLDT_HEXSTRING, OI(OFF(salt)), CI(32), 0, TYP_NONE },
+ { NULL }
+};
+# undef OFF
+#else
+const field_t vdesc_flds[] = {
+ { NULL }
+};
+#endif
+
const ftattr_t ftattrtab[] = {
{ FLDT_AGBLOCK, "agblock", fp_num, "%u", SI(bitsz(xfs_agblock_t)),
FTARG_DONULL, fa_agblock, NULL },
@@ -440,6 +459,16 @@ const ftattr_t ftattrtab[] = {
{ FLDT_RGSUMMARY, "rgsummary", NULL, (char *)rgsummary_flds,
btblock_size, FTARG_SIZE, NULL, rgsummary_flds },
+ { FLDT_UINT64D_LE, "uint64d_le", fp_num, "%llu", SI(bitsz(uint64_t)),
+ FTARG_LE, NULL, NULL },
+
+#ifdef HAVE_FSVERITY_DESCR
+ { FLDT_FSVERITY_DESCR, "verity", NULL, (char *)vdesc_flds,
+ SI(bitsz(struct fsverity_descriptor)), 0, NULL, vdesc_flds },
+#else
+ { FLDT_FSVERITY_DESCR, "verity", NULL, NULL, 0, 0, NULL, NULL },
+#endif
+
{ FLDT_ZZZ, NULL }
};
@@ -211,6 +211,9 @@ typedef enum fldt {
FLDT_SUMINFO,
FLDT_RGSUMMARY,
+ FLDT_UINT64D_LE,
+ FLDT_FSVERITY_DESCR,
+
FLDT_ZZZ /* mark last entry */
} fldt_t;
@@ -114,6 +114,7 @@ HAVE_UDEV = @have_udev@
UDEV_RULE_DIR = @udev_rule_dir@
HAVE_LIBURCU_ATOMIC64 = @have_liburcu_atomic64@
USE_RADIX_TREE_FOR_INUMS = @use_radix_tree_for_inums@
+HAVE_FSVERITY_DESCR = @have_fsverity_descr@
GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
# -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -174,4 +174,8 @@ static inline size_t __ab_c_size(size_t a, size_t b, size_t c)
# define barrier() __memory_barrier()
#endif
+#ifdef HAVE_FSVERITY_DESCR
+# include <linux/fsverity.h>
+#endif
+
#endif /* __XFS_PLATFORM_DEFS_H__ */
@@ -237,3 +237,21 @@ AC_DEFUN([AC_USE_RADIX_TREE_FOR_INUMS],
AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
AC_SUBST(use_radix_tree_for_inums)
])
+
+#
+# Check if linux/fsverity.h defines the verity descriptor
+#
+AC_DEFUN([AC_HAVE_FSVERITY_DESCRIPTOR],
+ [ AC_MSG_CHECKING([for fsverity_descriptor in linux/fsverity.h ])
+ AC_COMPILE_IFELSE(
+ [ AC_LANG_PROGRAM([[
+#include <linux/types.h>
+#include <linux/fsverity.h>
+ ]], [[
+struct fsverity_descriptor m = { };
+ ]])
+ ], have_fsverity_descr=yes
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+ AC_SUBST(have_fsverity_descr)
+ ])