Skip to content

Commit 15b71f6

Browse files
committed
init
0 parents  commit 15b71f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+12421
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.o
2+
*.d
3+
4+
/src/sbin/hammer2/hammer2
5+
/src/sbin/newfs_hammer2/newfs_hammer2
6+
/src/sbin/mount_hammer2/mount_hammer2
7+
/src/sbin/fsck_hammer2/fsck_hammer2

CHANGES

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
v0.1.0
2+
======
3+
- Initial release
4+
- Add sbin/* commands for read-only support
5+
- VFS_MOUNT() returns EOPNOTSUPP

COPYRIGHT

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Copyright (c) 2023 Tomohiro Kusumi <[email protected]>
2+
Copyright (c) 2011-2023 The DragonFly Project. All rights reserved.
3+
4+
This code is derived from software contributed to The DragonFly Project
5+
by Matthew Dillon <[email protected]>
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions
9+
are met:
10+
11+
1. Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
2. Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in
15+
the documentation and/or other materials provided with the
16+
distribution.
17+
3. Neither the name of The DragonFly Project nor the names of its
18+
contributors may be used to endorse or promote products derived
19+
from this software without specific, prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32+
SUCH DAMAGE.

Makefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
SUBDIRS = src
2+
3+
.PHONY: all clean $(SUBDIRS)
4+
5+
all: $(SUBDIRS)
6+
$(SUBDIRS):
7+
$(MAKE) -C $@
8+
clean:
9+
for dir in $(SUBDIRS); do \
10+
$(MAKE) -C $$dir $@; \
11+
done
12+
install:
13+
sudo bash -x ./script/install.sh
14+
uninstall:
15+
sudo bash -x ./script/uninstall.sh
16+
prep:
17+
sudo bash -x ./script/prep.sh
18+
unprep:
19+
sudo bash -x ./script/unprep.sh

README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
OpenBSD [HAMMER2](https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/vfs/hammer2/DESIGN)
2+
========
3+
4+
## About
5+
6+
+ HAMMER2 file system for OpenBSD (read-only support)
7+
8+
+ OpenBSD version of https://github.com/kusumi/netbsd_hammer2
9+
10+
## Requirements
11+
12+
+ Recent OpenBSD
13+
14+
+ Compiles and tested with OpenBSD 7.2
15+
16+
+ Never compiled or tested with other releses or -CURRENT
17+
18+
+ OpenBSD src tree under /usr/src
19+
20+
+ Bash
21+
22+
## Build
23+
24+
$ cd openbsd_hammer2
25+
$ make
26+
27+
## Install
28+
29+
$ cd openbsd_hammer2
30+
$ make install
31+
32+
## Uninstall
33+
34+
$ cd openbsd_hammer2
35+
$ make uninstall
36+
37+
## OpenBSD kernel build
38+
39+
+ Apply [patch/openbsd72.patch](patch/openbsd72.patch) or equivalent diff against /usr/src.
40+
41+
+ Run *make prep* to create a symlink under /usr/src/sys which points to this repository. Run *make unprep* to undo.
42+
43+
$ cd openbsd_hammer2
44+
$ make prep
45+
46+
+ Build and install /usr/src/sys.
47+
48+
## Notes
49+
50+
+ Only read-only support is planned for OpenBSD.
51+
52+
+ Tags are merely for packaging, nothing directly to do with file system version.
53+
54+
+ [makefs(8) for Linux](https://github.com/kusumi/makefs) supports HAMMER2 image creation from a directory contents on Linux. There is currently no way to do this on OpenBSD.

patch/openbsd72.patch

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC
2+
index b524e4c00..635c51ad3 100644
3+
--- a/sys/conf/GENERIC
4+
+++ b/sys/conf/GENERIC
5+
@@ -42,6 +42,7 @@ option MSDOSFS # MS-DOS file system
6+
option FIFO # FIFOs; RECOMMENDED
7+
#option TMPFS # efficient memory file system
8+
option FUSE # FUSE
9+
+option HAMMER2 # HAMMER2 file system
10+
11+
option SOCKET_SPLICE # Socket Splicing for TCP and UDP
12+
option TCP_ECN # Explicit Congestion Notification for TCP
13+
diff --git a/sys/conf/files b/sys/conf/files
14+
index 3bd32d693..2e3a09ee8 100644
15+
--- a/sys/conf/files
16+
+++ b/sys/conf/files
17+
@@ -788,6 +788,7 @@ file tmpfs/tmpfs_vfsops.c tmpfs
18+
file tmpfs/tmpfs_vnops.c tmpfs
19+
file tmpfs/tmpfs_specops.c tmpfs
20+
file tmpfs/tmpfs_fifoops.c tmpfs & fifo
21+
+file hammer2/hammer2_vfsops.c hammer2
22+
file net/art.c
23+
file net/bpf.c bpfilter needs-count
24+
file net/bpf_filter.c bpfilter
25+
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
26+
index 84c00f0e4..59715d5d8 100644
27+
--- a/sys/kern/vfs_init.c
28+
+++ b/sys/kern/vfs_init.c
29+
@@ -100,6 +100,11 @@ static struct vfsconf vfsconflist[] = {
30+
{ &tmpfs_vfsops, MOUNT_TMPFS, 19, 0, MNT_LOCAL,
31+
sizeof(struct tmpfs_args) },
32+
#endif
33+
+
34+
+#ifdef HAMMER2
35+
+ { &hammer2_vfsops, "hammer2", 20, 0, MNT_LOCAL,
36+
+ sizeof(struct hammer2_args) },
37+
+#endif
38+
};
39+
40+
41+
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
42+
index 40c12e976..c31e7c17c 100644
43+
--- a/sys/sys/mount.h
44+
+++ b/sys/sys/mount.h
45+
@@ -257,6 +257,15 @@ struct fusefs_args {
46+
int allow_other;
47+
};
48+
49+
+/*
50+
+ * Arguments to mount HAMMER2 file systems
51+
+ * XXX sizeof can't exceed existing union mount_info size.
52+
+ */
53+
+struct hammer2_args {
54+
+ char volume[100]; /* was 1024, change this to pointer */
55+
+ int hflags; /* extended hammer2 mount flags */
56+
+};
57+
+
58+
/*
59+
* file system statistics
60+
*/
61+
@@ -273,6 +282,7 @@ union mount_info {
62+
struct msdosfs_args msdosfs_args;
63+
struct ntfs_args ntfs_args;
64+
struct tmpfs_args tmpfs_args;
65+
+ struct hammer2_args hammer2_args;
66+
char __align[160]; /* 64-bit alignment and room to grow */
67+
};
68+
69+
@@ -558,6 +568,7 @@ extern const struct vfsops ntfs_vfsops;
70+
extern const struct vfsops udf_vfsops;
71+
extern const struct vfsops fusefs_vfsops;
72+
extern const struct vfsops tmpfs_vfsops;
73+
+extern const struct vfsops hammer2_vfsops;
74+
75+
#include <net/radix.h>
76+
#include <sys/socket.h> /* XXX for AF_MAX */
77+
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
78+
index c9bb267e7..4b6aebca0 100644
79+
--- a/sys/sys/vnode.h
80+
+++ b/sys/sys/vnode.h
81+
@@ -66,13 +66,13 @@ enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
82+
enum vtagtype {
83+
VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS,
84+
VT_PORTAL, VT_PROCFS, VT_AFS, VT_ISOFS, VT_ADOSFS,
85+
- VT_EXT2FS, VT_VFS, VT_NTFS, VT_UDF, VT_FUSEFS, VT_TMPFS,
86+
+ VT_EXT2FS, VT_VFS, VT_NTFS, VT_UDF, VT_FUSEFS, VT_TMPFS, VT_HAMMER2,
87+
};
88+
89+
#define VTAG_NAMES \
90+
"NON", "UFS", "NFS", "MFS", "MSDOSFS", \
91+
"unused", "unused", "unused", "ISOFS", "unused", \
92+
- "EXT2FS", "VFS", "NTFS", "UDF", "FUSEFS", "TMPFS"
93+
+ "EXT2FS", "VFS", "NTFS", "UDF", "FUSEFS", "TMPFS", "HAMMER2"
94+
95+
/*
96+
* Each underlying filesystem allocates its own private area and hangs

script/install.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/local/bin/bash
2+
3+
set -e
4+
5+
DIR=$1
6+
if [ "${DIR}" = "" ]; then
7+
DIR=/usr/local
8+
fi
9+
10+
[ -e /usr/bin/install ] || exit 1
11+
[ -e /usr/bin/strip ] || exit 1
12+
13+
[ -d ${DIR} ] || /bin/mkdir -p ${DIR}
14+
[ -d ${DIR}/sbin ] || /bin/mkdir -p ${DIR}/sbin
15+
[ -d ${DIR}/man/man8 ] || /bin/mkdir -p ${DIR}/man/man8
16+
17+
/usr/bin/install -s -m 555 ./src/sbin/hammer2/hammer2 ${DIR}/sbin
18+
/usr/bin/install -s -m 555 ./src/sbin/newfs_hammer2/newfs_hammer2 ${DIR}/sbin
19+
/usr/bin/install -s -m 555 ./src/sbin/mount_hammer2/mount_hammer2 ${DIR}/sbin
20+
/usr/bin/install -s -m 555 ./src/sbin/fsck_hammer2/fsck_hammer2 ${DIR}/sbin
21+
22+
/usr/bin/install -m 444 ./src/sbin/hammer2/hammer2.8 ${DIR}/man/man8
23+
/usr/bin/install -m 444 ./src/sbin/newfs_hammer2/newfs_hammer2.8 ${DIR}/man/man8
24+
/usr/bin/install -m 444 ./src/sbin/mount_hammer2/mount_hammer2.8 ${DIR}/man/man8
25+
/usr/bin/install -m 444 ./src/sbin/fsck_hammer2/fsck_hammer2.8 ${DIR}/man/man8
26+
27+
/usr/bin/strip --strip-debug ${DIR}/sbin/hammer2
28+
/usr/bin/strip --strip-debug ${DIR}/sbin/newfs_hammer2
29+
/usr/bin/strip --strip-debug ${DIR}/sbin/mount_hammer2
30+
/usr/bin/strip --strip-debug ${DIR}/sbin/fsck_hammer2
31+
32+
echo "install success"

script/prep.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/local/bin/bash
2+
3+
set -e
4+
5+
DIR=$1
6+
if [ "${DIR}" = "" ]; then
7+
DIR=`pwd`
8+
fi
9+
10+
[ -d /usr/src/sys ] || exit 1
11+
[ -d ${DIR} ] || exit 1
12+
13+
HAMMER2_DIR=${DIR}/src/sys/fs/hammer2
14+
if [ ! -d ${HAMMER2_DIR} ]; then
15+
echo "${HAMMER2_DIR} does not exist"
16+
exit 1
17+
fi
18+
19+
HAMMER2_LNK=/usr/src/sys/hammer2
20+
if [ -e ${HAMMER2_LNK} ]; then
21+
echo "${HAMMER2_LNK} already exists"
22+
exit 1
23+
fi
24+
25+
/bin/ln -s ${HAMMER2_DIR} ${HAMMER2_LNK}
26+
/bin/ls -l ${HAMMER2_LNK}
27+
28+
echo "prep success"

script/uninstall.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/local/bin/bash
2+
3+
set -e
4+
5+
DIR=$1
6+
if [ "${DIR}" = "" ]; then
7+
DIR=/usr/local
8+
fi
9+
10+
[ ! -f ${DIR}/sbin/hammer2 ] || /bin/rm ${DIR}/sbin/hammer2
11+
[ ! -f ${DIR}/sbin/newfs_hammer2 ] || /bin/rm ${DIR}/sbin/newfs_hammer2
12+
[ ! -f ${DIR}/sbin/mount_hammer2 ] || /bin/rm ${DIR}/sbin/mount_hammer2
13+
[ ! -f ${DIR}/sbin/fsck_hammer2 ] || /bin/rm ${DIR}/sbin/fsck_hammer2
14+
# XXX rmdir ${DIR}/sbin if empty
15+
16+
[ ! -f ${DIR}/man/man8/hammer2.8 ] || /bin/rm ${DIR}/man/man8/hammer2.8
17+
[ ! -f ${DIR}/man/man8/hammer2.8.gz ] || /bin/rm ${DIR}/man/man8/hammer2.8.gz
18+
[ ! -f ${DIR}/man/man8/newfs_hammer2.8 ] || /bin/rm ${DIR}/man/man8/newfs_hammer2.8
19+
[ ! -f ${DIR}/man/man8/newfs_hammer2.8.gz ] || /bin/rm ${DIR}/man/man8/newfs_hammer2.8.gz
20+
[ ! -f ${DIR}/man/man8/mount_hammer2.8 ] || /bin/rm ${DIR}/man/man8/mount_hammer2.8
21+
[ ! -f ${DIR}/man/man8/mount_hammer2.8.gz ] || /bin/rm ${DIR}/man/man8/mount_hammer2.8.gz
22+
[ ! -f ${DIR}/man/man8/fsck_hammer2.8 ] || /bin/rm ${DIR}/man/man8/fsck_hammer2.8
23+
[ ! -f ${DIR}/man/man8/fsck_hammer2.8.gz ] || /bin/rm ${DIR}/man/man8/fsck_hammer2.8.gz
24+
# XXX rmdir ${DIR}/man/man8 if empty
25+
26+
echo "uninstall success"

script/unprep.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/local/bin/bash
2+
3+
set -e
4+
5+
DIR=$1
6+
if [ "${DIR}" = "" ]; then
7+
DIR=`pwd`
8+
fi
9+
10+
[ -d /usr/src/sys ] || exit 1
11+
[ -d ${DIR} ] || exit 1
12+
13+
HAMMER2_LNK=/usr/src/sys/hammer2
14+
if [ ! -e ${HAMMER2_LNK} ]; then
15+
echo "${HAMMER2_LNK} does not exist"
16+
exit 1
17+
fi
18+
19+
/bin/rm ${HAMMER2_LNK}
20+
21+
echo "unprep success"

src/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SUBDIRS = sbin/hammer2 sbin/newfs_hammer2 sbin/mount_hammer2 sbin/fsck_hammer2
2+
3+
.PHONY: all clean $(SUBDIRS)
4+
5+
all: $(SUBDIRS)
6+
$(SUBDIRS):
7+
$(MAKE) -C $@
8+
clean:
9+
for dir in $(SUBDIRS); do \
10+
$(MAKE) -C $$dir $@; \
11+
done

src/sbin/fsck_hammer2/Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.include <bsd.own.mk>
2+
3+
PROG= fsck_hammer2
4+
SRCS= fsck_hammer2.c test.c ondisk.c subs.c xxhash.c icrc32.c
5+
MAN= fsck_hammer2.8
6+
7+
.PATH: ../hammer2 ../../sys/libkern ../../sys/fs/hammer2/xxhash
8+
9+
WARNS= 5
10+
11+
CFLAGS+= -I../../sys
12+
CFLAGS+= -I../hammer2
13+
14+
DPADD+= ${LIBCRYPTO}
15+
LDADD+= -lcrypto
16+
17+
.include <bsd.prog.mk>

0 commit comments

Comments
 (0)