aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libufs/Makefile4
-rw-r--r--lib/libufs/cgroup.c5
-rw-r--r--lib/libufs/libufs.h5
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index c1948b3a0f0f..c80183d3b428 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -5,7 +5,7 @@ LIB= ufs
SHLIBDIR?= /lib
SHLIB_MAJOR= 6
-SRCS= block.c cgroup.c inode.c sblock.c type.c ffs_subr.c ffs_tables.c
+SRCS= block.c cgroup.c crc32.c inode.c sblock.c type.c ffs_subr.c ffs_tables.c
INCS= libufs.h
MAN= bread.3 cgread.3 libufs.3 sbread.3 ufs_disk_close.3
@@ -18,7 +18,7 @@ MLINKS+= ufs_disk_close.3 ufs_disk_fillout.3
MLINKS+= ufs_disk_close.3 ufs_disk_fillout_blank.3
MLINKS+= ufs_disk_close.3 ufs_disk_write.3
-.PATH: ${SRCTOP}/sys/ufs/ffs
+.PATH: ${SRCTOP}/sys/libkern ${SRCTOP}/sys/ufs/ffs
WARNS?= 2
diff --git a/lib/libufs/cgroup.c b/lib/libufs/cgroup.c
index dfb10d3feb94..622df059bb10 100644
--- a/lib/libufs/cgroup.c
+++ b/lib/libufs/cgroup.c
@@ -214,6 +214,11 @@ cgwrite1(struct uufsd *disk, int c)
struct fs *fs;
fs = &disk->d_fs;
+ if ((fs->fs_metackhash & CK_CYLGRP) != 0) {
+ disk->d_cg.cg_ckhash = 0;
+ disk->d_cg.cg_ckhash =
+ calculate_crc32c(~0L, (void *)&disk->d_cg, fs->fs_cgsize);
+ }
if (bwrite(disk, fsbtodb(fs, cgtod(fs, c)),
disk->d_cgunion.d_buf, fs->fs_bsize) == -1) {
ERROR(disk, "unable to write cylinder group");
diff --git a/lib/libufs/libufs.h b/lib/libufs/libufs.h
index ddc5c9b6b055..4a79207a519d 100644
--- a/lib/libufs/libufs.h
+++ b/lib/libufs/libufs.h
@@ -144,6 +144,11 @@ int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
void ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
+/*
+ * crc32c.c
+ */
+uint32_t calculate_crc32c(uint32_t, const void *, size_t);
+
__END_DECLS
#endif /* __LIBUFS_H__ */