Merge feat/p4-devices

# Conflicts:
#	src/client/client_send.c
#	src/server/receiver.c
#	src/shared/chunk.c
#	src/shared/file.c
#	src/shared/file_receive.c
#	src/shared/file_receive.h
#	src/shared/file_types.h
#	src/shared/protocol.h
#	tests/test_chunk.c
This commit is contained in:
2026-09-08 22:33:52 +02:00
23 changed files with 910 additions and 29 deletions
+21
View File
@@ -25,6 +25,26 @@ static void test_file_create() {
file_destroy(f);
}
/* rdev/type validation shared by the wire path and the secure recreation site:
* a legal char/block major/minor pair is accepted, out-of-range / negative
* values and non-device entries carrying an rdev are rejected. */
static void test_file_special_rdev_valid() {
mode_t fake_char = S_IFCHR | 0600;
mode_t fake_blk = S_IFBLK | 0600;
mode_t fake_fifo = S_IFIFO | 0600;
/* char/block devices: accept a legal pair, reject negative / oversized. */
EXPECT_TRUE(file_special_rdev_valid(1, 3, fake_char));
EXPECT_TRUE(file_special_rdev_valid(0xffff, 0x00ffffff, fake_blk));
EXPECT_FALSE(file_special_rdev_valid(-1, 3, fake_char));
EXPECT_FALSE(file_special_rdev_valid(1, -1, fake_char));
EXPECT_FALSE(file_special_rdev_valid(0x10000, 3, fake_char));
EXPECT_FALSE(file_special_rdev_valid(1, 0x1000000, fake_char));
/* FIFOs/sockets must carry an empty rdev. */
EXPECT_TRUE(file_special_rdev_valid(0, 0, fake_fifo));
EXPECT_FALSE(file_special_rdev_valid(1, 0, fake_fifo));
EXPECT_FALSE(file_special_rdev_valid(0, 0, (mode_t)(S_IFREG | 0600)));
}
static void test_file_destroy_null() {
file_destroy(NULL);
}
@@ -1004,6 +1024,7 @@ static void test_dir_entry_save_to_disk() {
void test_file() {
test_file_create();
test_file_special_rdev_valid();
test_file_destroy_null();
test_file_destroy_normal();
test_file_load_data();