If you don't understand math, you can learn it from a textbook, or you can learn it from a video, or you can learn it form a lecture - all valid ways. But at the end of the day you understand math.
I thought you have a single big diff file? That's what you say in your first post.
You seem to insist on wasting your own time instead of reading the description in man page, you absolutely didn't have to do that,yes,I have it. But I have splitted the patches inside the big file into small files / patches. Because the paths inside the big file are different,so I've found that I can patch every file by placing the single patches inside the directories where the files to patch are.
patch
understands the format you had in that diff and can apply to different paths without issues.You seem to insist on wasting your own time instead of reading the description in man page, you absolutely didn't have to do that,patch
understands the format you had in that diff and can apply to different paths without issues.
It's not about about the diff file location, it's about your current directory where you run patch command, you could even useUnfortunately not. I have placed the diff file in various locations and it never worked.
-d
option (I'm always forgetting about it!). -p2
.Won't all the patches be applied to arm/arm? What does
show?Code:/usr/src # < patch
/mnt/zroot2/zroot2/OS/BSD/FreeBSD/arm64/img/Radxa-3W/Stuff/covacat/usr/src # patch -C -p2 < RK356X-diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- trunk/stable-14/sys/arm/arm/generic_timer.c 2025-03-19 20:49:43.139887000 +0100
|+++ branches/stable-14-deepcore/sys/arm/arm/generic_timer.c 2025-03-19 20:22:23.334267000 +0100
--------------------------
Patching file sys/arm/arm/generic_timer.c using Plan A...
Hunk #1 succeeded at 185.
Hunk #2 succeeded at 207.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|
|--- trunk/stable-14/sys/arm/arm/pmu.c 2025-03-19 20:49:43.176176000 +0100
|+++ branches/stable-14-deepcore/sys/arm/arm/pmu.c 2025-03-19 20:22:23.363676000 +0100
--------------------------
Patching file sys/arm/arm/pmu.c using Plan A...
Hunk #1 succeeded at 67.
Hunk #2 succeeded at 83.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|
|--- trunk/stable-14/sys/arm64/arm64/machdep.c 2025-03-19 20:49:44.977546000 +0100
|+++ branches/stable-14-deepcore/sys/arm64/arm64/machdep.c 2025-03-19 20:22:25.074352000 +0100
--------------------------
Patching file sys/arm64/arm64/machdep.c using Plan A...
Hunk #1 succeeded at 719.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|
|--- trunk/stable-14/sys/arm64/arm64/undefined.c 2025-03-19 20:49:45.003419000 +0100
|+++ branches/stable-14-deepcore/sys/arm64/arm64/undefined.c 2025-03-19 20:22:25.097413000 +0100
--------------------------
Patching file sys/arm64/arm64/undefined.c using Plan A...
Hunk #1 succeeded at 119.
Hunk #2 succeeded at 170.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|
|--- trunk/stable-14/sys/arm64/conf/RADXA3W 1970-01-01 01:00:00.000000000 +0100
|+++ branches/stable-14-deepcore/sys/arm64/conf/RADXA3W 2025-06-10 19:46:29.526693000 +0200
--------------------------
(Creating file sys/arm64/conf/RADXA3W...)
Patching file sys/arm64/conf/RADXA3W using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
What does that even mean?By this I mean rebuild base system man pages with a ML/DL framework
It means technical mumbo jumbo stuff and tldr voo doo black magic stuff. BasicallyWhat does that even mean?
It means technical mumbo jumbo stuff and tldr voo doo black magic stuff. Basically
For me this was the way I first understood how to read them. so I thought it could also help you if it did help me back then. Because you said you don't understand them. Another thing useful to know is how to use the pager to move around while reading them:Do you want my honest opinion ?
man less
For me this was the way I first understood how to read them. so I thought it could also help you if it did help me back then. Because you said you don't understand them. Another thing useful to know is how to use the pager to move around while reading them:man less
1) I thought it could also help you if it did help me back then.
2) Because you said you don't understand them. Another thing useful to know is how to use the pager to move around while reading them: man less
You have to read them to understand them. Every option or parameter of a specific command is described within it's man pages.This is because there are no practical examples that show me what happens when a command is formed in a certain way.
The manpage of man that I gave you explain everything you need to know to understand the man pages. I don't think you can't understand them, I think your just don't want to read them, it's natural, but you have to go counter nature here. They are not so complex, but you have to get used to it. At first your brain wont like it, but if you really have a motivation you'll go over that and you'll discipline yourself and even if you don't get it at first glance you'll insist and keep coming back at it, until you reach understanding, try to focus on the first thing you don't understand isolate it and focus on it, it could be the meaning of a technical word that you'll have to search. Also the manpages are not like a book on one topic. the manpage contain sections, or chapter related to one specific general technical subject. You have to be aware of what sections of the manpages you need to search.Finally, man man doubles the initial difficulty, because it creates an additional level of complexity, since it tries to explain what I didn't understand at the beginning without simplifying the language.
You have to read them to understand them. Every option or parameter of a specific command is described within it's man pages.
The manpage of man that I gave you explain everything you need to know to understand the man pages. I don't think you can't understand them, I think your just don't want to read them, it's natural, but you have to go counter nature here. They are not so complex, but you have to get used to it. At first your brain wont like it, but if you really have a motivation you'll go over that and you'll discipline yourself and even if you don't get it at first glance you'll insist and keep coming back at it, until you reach understanding, try to focus on the first thing you don't understand isolate it and focus on it, it could be the meaning of a technical word that you'll have to search. Also the manpages are not like a book on one topic. the manpage contain sections, or chapter related to one specific general technical subject. You have to be aware of what sections of the manpages you need to search.
here is another resources for you : https://medium.com/better-programming/man-pages-the-complete-guide-800ad93425fe
diff -u sys/sys/param.h.orig sys/sys/param.h
at /usr/src, it would show something like below. (Example on stable/14 at commit fad4064226b2aa3de6a6c83adb7e0e0108e69bd3)--- sys/sys/param.h.orig
+++ sys/sys/param.h
@@ -75,7 +75,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1403502
+#define __FreeBSD_version 1403503
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
cd /usr/src ; patch -i /path/to/patch/file
or cd /usr/src ; patch -p0 -i /path/to/patch/file
would apply it. cd /usr/ports ; patch -p1 -i /path/to/patch/file
also worked (already impossible on latest main branch of ports tree, as it is already landed).diff -ubr /mnt/da7p2/usr-no/src/sys/sys-142-cheri /mnt/da7p2/usr-no/src/sys/sys-143-original > diffs-143.patch
patch < diffs-143.patch
marietto# ./apply-patches
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/fpu.c 2024-11-29 01:03:43.000000000 +0100
|+++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200
--------------------------
File to patch:
--- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/fpu.c 2024-11-29 01:03:43.000000000 +0100
+++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200
@@ -1069,10 +1069,6 @@
/* Device interface */
DEVMETHOD(device_probe, fpupnp_probe),
DEVMETHOD(device_attach, fpupnp_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
{ 0, 0 }
};
--- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/machdep.c 2024-11-29 01:03:43.000000000 +0100
+++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/machdep.c 2025-09-13 18:45:21.024910000 +0200
@@ -984,10 +984,11 @@
if (physmap[i + 1] < end)
end = trunc_page(physmap[i + 1]);
for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) {
- int tmp, page_bad, full;
int *ptr = (int *)CADDR1;
+ int tmp;
+ bool full, page_bad;
- full = FALSE;
+ full = false;
/*
* block out kernel memory as not available.
*/
@@ -1002,7 +1003,7 @@
&& pa < dcons_addr + dcons_size)
goto do_dump_avail;
- page_bad = FALSE;
+ page_bad = false;
if (memtest == 0)
goto skip_memtest;
@@ -1026,25 +1027,25 @@
*/
*(volatile int *)ptr = 0xaaaaaaaa;
if (*(volatile int *)ptr != 0xaaaaaaaa)
- page_bad = TRUE;
+ page_bad = true;
/*
* Test for alternating 0's and 1's
*/
*(volatile int *)ptr = 0x55555555;
if (*(volatile int *)ptr != 0x55555555)
- page_bad = TRUE;
+ page_bad = true;
/*
* Test for all 1's
*/
*(volatile int *)ptr = 0xffffffff;
if (*(volatile int *)ptr != 0xffffffff)
- page_bad = TRUE;
+ page_bad = true;
/*
* Test for all 0's
*/
*(volatile int *)ptr = 0x0;
if (*(volatile int *)ptr != 0x0)
- page_bad = TRUE;
+ page_bad = true;
/*
* Restore original value.
*/
@@ -1054,7 +1055,7 @@
/*
* Adjust array of valid/good pages.
*/
- if (page_bad == TRUE)
+ if (page_bad == true)
continue;
/*
* If this good page is a continuation of the
@@ -1075,7 +1076,7 @@
printf(
"Too many holes in the physical address space, giving up\n");
pa_indx--;
- full = TRUE;
+ full = true;
goto do_dump_avail;
}
phys_avail[pa_indx++] = pa; /* start */
@@ -1689,6 +1690,27 @@
CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
efi_map_sysctl_handler, "S,efi_map_header",
"Raw EFI Memory Map");
+
+static int
+efi_arch_sysctl_handler(SYSCTL_HANDLER_ARGS)
+{
+ char *arch;
+ caddr_t kmdp;
+
+ kmdp = preload_search_by_type("elf kernel");
+ if (kmdp == NULL)
+ kmdp = preload_search_by_type("elf64 kernel");
+
+ arch = (char *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_EFI_ARCH);
+ if (arch == NULL)
+ return (0);
+
+ return (SYSCTL_OUT_STR(req, arch));
+}
+SYSCTL_PROC(_machdep, OID_AUTO, efi_arch,
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
+ efi_arch_sysctl_handler, "A", "EFI Firmware Architecture");
void
spinlock_enter(void)
and so on.
Lines starting withI would like to patch the sys directory of the original FreeBSD 14.3-R with the patches and the code used inside the sys directory of CheriBSD,based on 14.2-R. The first thing that I did has been to extract the differences between the two dirs using this command :
Code:diff -ubr /mnt/da7p2/usr-no/src/sys/sys-142-cheri /mnt/da7p2/usr-no/src/sys/sys-143-original > diffs-143.patch
then,I tried to apply the diffs to sys-143-original using this command :
Code:patch < diffs-143.patch
But the error is :
Code:marietto# ./apply-patches Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |--- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/fpu.c 2024-11-29 01:03:43.000000000 +0100 |+++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200 -------------------------- File to patch:
I don't understand why. This is how diffs-143.patch looks like :
Code:--- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/fpu.c 2024-11-29 01:03:43.000000000 +0100 +++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200 @@ -1069,10 +1069,6 @@ /* Device interface */ DEVMETHOD(device_probe, fpupnp_probe), DEVMETHOD(device_attach, fpupnp_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), { 0, 0 } }; --- /mnt/da7p2/usr-no/src/sys/sys-142-cheri/amd64/amd64/machdep.c 2024-11-29 01:03:43.000000000 +0100 +++ /mnt/da7p2/usr-no/src/sys/sys-143-original/amd64/amd64/machdep.c 2025-09-13 18:45:21.024910000 +0200 @@ -984,10 +984,11 @@ if (physmap[i + 1] < end) end = trunc_page(physmap[i + 1]); for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) { - int tmp, page_bad, full; int *ptr = (int *)CADDR1; + int tmp; + bool full, page_bad; - full = FALSE; + full = false; /* * block out kernel memory as not available. */ @@ -1002,7 +1003,7 @@ && pa < dcons_addr + dcons_size) goto do_dump_avail; - page_bad = FALSE; + page_bad = false; if (memtest == 0) goto skip_memtest; @@ -1026,25 +1027,25 @@ */ *(volatile int *)ptr = 0xaaaaaaaa; if (*(volatile int *)ptr != 0xaaaaaaaa) - page_bad = TRUE; + page_bad = true; /* * Test for alternating 0's and 1's */ *(volatile int *)ptr = 0x55555555; if (*(volatile int *)ptr != 0x55555555) - page_bad = TRUE; + page_bad = true; /* * Test for all 1's */ *(volatile int *)ptr = 0xffffffff; if (*(volatile int *)ptr != 0xffffffff) - page_bad = TRUE; + page_bad = true; /* * Test for all 0's */ *(volatile int *)ptr = 0x0; if (*(volatile int *)ptr != 0x0) - page_bad = TRUE; + page_bad = true; /* * Restore original value. */ @@ -1054,7 +1055,7 @@ /* * Adjust array of valid/good pages. */ - if (page_bad == TRUE) + if (page_bad == true) continue; /* * If this good page is a continuation of the @@ -1075,7 +1076,7 @@ printf( "Too many holes in the physical address space, giving up\n"); pa_indx--; - full = TRUE; + full = true; goto do_dump_avail; } phys_avail[pa_indx++] = pa; /* start */ @@ -1689,6 +1690,27 @@ CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, efi_map_sysctl_handler, "S,efi_map_header", "Raw EFI Memory Map"); + +static int +efi_arch_sysctl_handler(SYSCTL_HANDLER_ARGS) +{ + char *arch; + caddr_t kmdp; + + kmdp = preload_search_by_type("elf kernel"); + if (kmdp == NULL) + kmdp = preload_search_by_type("elf64 kernel"); + + arch = (char *)preload_search_info(kmdp, + MODINFO_METADATA | MODINFOMD_EFI_ARCH); + if (arch == NULL) + return (0); + + return (SYSCTL_OUT_STR(req, arch)); +} +SYSCTL_PROC(_machdep, OID_AUTO, efi_arch, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + efi_arch_sysctl_handler, "A", "EFI Firmware Architecture"); void spinlock_enter(void) and so on.
---
and +++
really matters!--- sys/sys-142-cheri/amd64/amd64/fpu.c.orig 2024-11-29 01:03:43.000000000 +0100
+++ sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200
@@ -1069,10 +1069,6 @@
--- a/sys/sys-142-cheri/amd64/amd64/fpu.c 2024-11-29 01:03:43.000000000 +0100
+++ b/sys/sys-143-original/amd64/amd64/fpu.c 2025-09-13 18:45:21.023888000 +0200
@@ -1069,10 +1069,6 @@
a/
and b/
.# cd /usr/src
# patch -C < [patch file]
(Confirm it applies sanely or not by dry run. Proceed after confirming succeeded)
# patch <
-p1
option to the command line.