Skip to content

Commit 49219f5

Browse files
committed
新增 squashfs 内核模块, 将 rootfs 挂载置换成 squashfs.
1 parent d5f8ee4 commit 49219f5

File tree

125 files changed

+19809
-28
lines changed

Some content is hidden

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

125 files changed

+19809
-28
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ include(tools/bootloader.cmake)
3939
add_subdirectory(module/e1000)
4040
add_subdirectory(module/fatfs)
4141
add_subdirectory(module/iso9660)
42+
add_subdirectory(module/squashfs)
4243

4344
add_executable(kernel)
4445

@@ -113,6 +114,7 @@ if (CPPCHECK)
113114
-DSIZE_MAX=0xFFFFFFFFFFFFFFFFUL
114115
${CPPCHECK_ARCH_DEFS}
115116
--suppress=missingIncludeSystem
117+
--suppress=*:${CMAKE_SOURCE_DIR}/module/squashfs/*
116118
--suppress=*:${CMAKE_SOURCE_DIR}/module/fatfs/*
117119
--suppress=*:${CMAKE_SOURCE_DIR}/module/iso9660/*
118120
--suppress=*:${CMAKE_SOURCE_DIR}/src/term/flanterm/*

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414

1515
---
1616

17-
I'm working on [flavortown](https://flavortown.hackclub.com/projects/10683)! And
18-
[www18845340923](https://flavortown.hackclub.com/users/6782) is xiaoyi1212!
19-
2017
Languages
2118
: *English*
2219
| [简体中文](readme/README-zh-CN.md)
@@ -50,6 +47,7 @@ You need to install them on your computer:
5047
- lld (for linking LTO objects)
5148
- openssl (kernel module key)
5249
- python3 `cryptography` (sign kernel module)
50+
- squashfs-tools
5351

5452
### Options
5553

assets/cp_rootfs.sfs

30.9 MB
Binary file not shown.

assets/initramfs.img

0 Bytes
Binary file not shown.

assets/limine.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ wallpaper: boot():/background.jpg
88
protocol: limine
99
kernel_path: boot():/cpkrnl_x64.elf
1010
module_path: boot():/readme.txt
11-
#module_path: boot():/e1000.km
11+
module_path: boot():/cp_rootfs.sfs
1212
module_path: boot():/fatfs.km
13-
#module_path: boot():/extfs.km
13+
module_path: boot():/squashfs.km
1414
module_path: boot():/iso9660.km
1515
module_path: boot():/initramfs.img
16-
module_path: boot():/minirootfs_x86_64.tar.zst
16+
#module_path: boot():/minirootfs_x86_64.tar.zst
1717
kernel_cmdline: console=tty0 mem=default init=/bin/sh
1818
kaslr: no
1919

module/all_include/cp_kernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#define assert(expr)
4+
35
#include "types/stdbool.h"
46
#include "types/stdint.h"
57
#include "types/stddef.h"

module/all_include/fs_subsystem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define S_ISGID 0002000
2727
#define S_ISVTX 0001000
2828

29+
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
30+
2931
#include "cp_kernel.h"
3032
#include "list.h"
3133
#include "llist.h"

module/squashfs/CMakeLists.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
set(SQUASHFS_SOURCES
2+
squashfs.c
3+
src/data_reader.c
4+
src/dir_reader.c
5+
src/frag_table.c
6+
src/id_table.c
7+
src/inode.c
8+
src/meta_reader.c
9+
src/misc.c
10+
src/read_inode.c
11+
src/read_super.c
12+
src/read_table.c
13+
src/readdir.c
14+
src/write_table_stub.c
15+
src/util/alloc.c
16+
src/util/array.c
17+
src/util/rbtree.c
18+
)
19+
20+
add_library(squashfs SHARED ${SQUASHFS_SOURCES})
21+
22+
set_target_properties(squashfs PROPERTIES
23+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/kmod
24+
)
25+
26+
target_include_directories(squashfs PUBLIC
27+
${CMAKE_SOURCE_DIR}/module/all_include
28+
${CMAKE_CURRENT_SOURCE_DIR}/include
29+
${CMAKE_CURRENT_SOURCE_DIR}
30+
)
31+
32+
target_compile_definitions(squashfs PRIVATE
33+
NO_CUSTOM_ALLOC
34+
)
35+
36+
target_compile_options(squashfs PRIVATE
37+
-fPIC
38+
-fvisibility=hidden
39+
-fno-stack-protector
40+
-Wno-incompatible-library-redeclaration
41+
)
42+
43+
target_link_options(squashfs PRIVATE
44+
-nostdlib
45+
-Wl,-Bsymbolic
46+
-Wl,-e,dlmain
47+
)

module/squashfs/config.h

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/* config.h. Generated from config.h.in by configure. */
2+
/* config.h.in. Generated from configure.ac by autoheader. */
3+
4+
/* Define to 1 if you have the <alloca.h> header file. */
5+
#define HAVE_ALLOCA_H 1
6+
7+
/* Define to 1 if you have the <bzlib.h> header file. */
8+
#define HAVE_BZLIB_H 1
9+
10+
/* Define to 1 if you have the <dlfcn.h> header file. */
11+
#define HAVE_DLFCN_H 1
12+
13+
/* Define to 1 if you have the 'fnmatch' function. */
14+
#define HAVE_FNMATCH 1
15+
16+
/* Define to 1 if you have the 'getopt' function. */
17+
#define HAVE_GETOPT 1
18+
19+
/* Define to 1 if you have the 'getopt_long' function. */
20+
#define HAVE_GETOPT_LONG 1
21+
22+
/* Define to 1 if you have the 'getsubopt' function. */
23+
#define HAVE_GETSUBOPT 1
24+
25+
/* Define to 1 if you have the <inttypes.h> header file. */
26+
#define HAVE_INTTYPES_H 1
27+
28+
/* Have PTHREAD_PRIO_INHERIT. */
29+
#define HAVE_PTHREAD_PRIO_INHERIT 1
30+
31+
/* Define to 1 if you have the 'sched_getaffinity' function. */
32+
#define HAVE_SCHED_GETAFFINITY 1
33+
34+
/* Define to 1 if you have the <selinux/label.h> header file. */
35+
/* #undef HAVE_SELINUX_LABEL_H */
36+
37+
/* Define to 1 if you have the <selinux/selinux.h> header file. */
38+
/* #undef HAVE_SELINUX_SELINUX_H */
39+
40+
/* Define to 1 if you have the <stdint.h> header file. */
41+
#define HAVE_STDINT_H 0
42+
43+
/* Define to 1 if you have the <stdio.h> header file. */
44+
#define HAVE_STDIO_H 0
45+
46+
/* Define to 1 if you have the <stdlib.h> header file. */
47+
#define HAVE_STDLIB_H 0
48+
49+
/* Define to 1 if you have the 'strchrnul' function. */
50+
#define HAVE_STRCHRNUL 0
51+
52+
/* Define to 1 if you have the <strings.h> header file. */
53+
#define HAVE_STRINGS_H 0
54+
55+
/* Define to 1 if you have the <string.h> header file. */
56+
#define HAVE_STRING_H 0
57+
58+
/* Define to 1 if you have the 'strndup' function. */
59+
#define HAVE_STRNDUP 0
60+
61+
/* Define to 1 if you have the <sys/stat.h> header file. */
62+
#define HAVE_SYS_STAT_H 1
63+
64+
/* Define to 1 if you have the <sys/types.h> header file. */
65+
#define HAVE_SYS_TYPES_H 1
66+
67+
/* Define to 1 if you have the <sys/xattr.h> header file. */
68+
#define HAVE_SYS_XATTR_H 1
69+
70+
/* Define to 1 if you have the <unistd.h> header file. */
71+
#define HAVE_UNISTD_H 1
72+
73+
/* Does zstd support stream compression? */
74+
#define HAVE_ZSTD_STREAM 1
75+
76+
/* Define to the sub-directory where libtool stores uninstalled libraries. */
77+
#define LT_OBJDIR ".libs/"
78+
79+
/* Name of package */
80+
#define PACKAGE "squashfs-tools-ng"
81+
82+
/* Define to the address where bug reports for this package should be sent. */
83+
#define PACKAGE_BUGREPORT "goliath@infraroot.at"
84+
85+
/* Define to the full name of this package. */
86+
#define PACKAGE_NAME "squashfs-tools-ng"
87+
88+
/* Define to the full name and version of this package. */
89+
#define PACKAGE_STRING "squashfs-tools-ng 1.2.0"
90+
91+
/* Define to the one symbol short name of this package. */
92+
#define PACKAGE_TARNAME "squashfs-tools-ng"
93+
94+
/* Define to the home page for this package. */
95+
#define PACKAGE_URL ""
96+
97+
/* Define to the version of this package. */
98+
#define PACKAGE_VERSION "1.2.0"
99+
100+
/* Define to necessary symbol if this constant uses a non-standard name on
101+
your system. */
102+
/* #undef PTHREAD_CREATE_JOINABLE */
103+
104+
/* Define to 1 if all of the C89 standard headers exist (not just the ones
105+
required in a freestanding environment). This macro is provided for
106+
backward compatibility; new code need not use it. */
107+
#define STDC_HEADERS 1
108+
109+
/* Version number of package */
110+
#define VERSION "1.2.0"
111+
112+
/* Number of bits in a file offset, on hosts where this is settable. */
113+
/* #undef _FILE_OFFSET_BITS */
114+
115+
/* Define to 1 on platforms where this makes off_t a 64-bit type. */
116+
/* #undef _LARGE_FILES */
117+
118+
/* Number of bits in time_t, on hosts where this is settable. */
119+
/* #undef _TIME_BITS */
120+
121+
/* Define to 1 on platforms where this makes time_t a 64-bit type. */
122+
/* #undef __MINGW_USE_VC2005_COMPAT */

module/squashfs/include/assert.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
#include "cp_kernel.h"

0 commit comments

Comments
 (0)