我正在尝试在 bash 中修补这样的文件:
cat << ''EOF | patch --dry-run
> --- urancid 2017-12-06 09:56:33.000000000 -0600 patch --dry-run
> +++ /tmp/urancid 2017-12-06 15:06:57.000000000 -0600
> @@ -393,7 +393,7 @@
> last if (/^$prompt/);
> next if (/-ac\.\s*/);
> next if (/-fs\.\s*/);
> - next if (/set date\s*/)
> + next if (/set date\s*/);
> next if (/^(\s*|\s*$cmd\s*)$/);
> if ( ! /^$prompt/) {
> if ( ! $skipprocess ) {
> EOF
Run Code Online (Sandbox Code Playgroud)
但我得到的只是
patching file urancid
Hunk #1 FAILED at 393. …Run Code Online (Sandbox Code Playgroud) 在过去几年中,各种实时内核修补技术在努力确保系统正常运行时间的系统管理员中变得流行起来。
为了使该过程成为可能,人们需要准备自定义补丁,然后通常将其分发给付费客户,有时甚至免费分发给家庭用户。
为什么不能使用正在运行的内核版本的源代码和可用的最新版本的源代码之间的差异自动创建这些补丁?据我了解,可以从中获益最多的服务器内核通常每两年只进行一次重大更改,否则只会收到重大错误修复和安全更新,这似乎使这变得更加容易。同样,如果稳定性是问题,那么建立一个系统似乎很简单,在该系统中,运行重要性相对较低的机器的志愿者首先构建他们的补丁,然后自动报告他们的工作情况。
然而,这一切都不会发生。我在那里缺少什么使情况如此?
我正在尝试将 seek-for-android 项目提供的补丁应用于我从 Cyanogenmod 下载的代码。用make编译成功的代码,所以我知道所有的文件都在那里。我只是无法了解补丁正在做什么或者它是否正在工作。我尝试了 -verbose 选项。我不知道补丁需要多长时间才能遍历目录并查找要更新的文件。我在我的 CPU 中没有看到太多活动。以下是我遵循的说明: 在此处输入链接描述这是我所看到的屏幕截图:
root@ubuntu:~/android/system# ls
abi cm-11-2 docs Makefile sdk
android cm-11-3 external ndk smartcard-api-3_1_0
art cts frameworks out smartcard-api-3_1_0.tgz
bionic dalvik hardware packages system
bootable developers kernel pdk tools
build development libcore prebuilt vendor
cm-11 device libnativehelper prebuilts
root@ubuntu:~/android/system# cd smartcard-api-3_1_0
root@ubuntu:~/android/system/smartcard-api-3_1_0# cd ..
root@ubuntu:~/android/system# patch -p1 smartcard-api-3_1_0/smartcard-api.patch ^C
root@ubuntu:~/android/system# patch -p1 -R smartcard-api-3_1_0/smartcard- api.patch
^C
root@ubuntu:~/android/system# patch -p1 -verbose smartcard- api-3_1_0/smartcard-
api.patch
patch 2.6.1
Copyright (C) 1988 …Run Code Online (Sandbox Code Playgroud) 我即将为名为Compat Wireless 的无线驱动程序安装补丁,以解决我的Ubuntu Linux v12.04和Kali Linux v1.0.9上的 WiFi 通道(它锁定不存在的 -1 通道)的问题。
但首先我想知道这个补丁是否已经安装(为什么要安装我有的东西?)。
我已经做了一些研究,但我找不到一种方法来知道我的补丁是否已经存在,也找不到列出已安装补丁的通用方法。我什至不知道是否有可能从正在运行的 Linux 获取此类信息。
有什么想法吗?
我需要应用以下补丁,而且我不想弄乱我目前拥有的东西。下面我把我在网上找到的完整内容贴出来,这是某人对与我类似的问题的回答。
在 2007 年 3 月 20 日星期二 14:32 -0500,James Bottomley 写道:
MODULE 是否设置为“n”?看起来符号导出
#ifdef MODULE出于某种原因受到保护......除此之外 ,我无法解释这一点。事实上,这就是错误......模块化配置是MODULES而不是MODULE。你能试试这个吗:
---
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 0949145..a67f315 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -181,10 +181,8 @@ int scsi_complete_async_scans(void)
return 0;
}
-#ifdef MODULE
/* Only exported for the benefit of scsi_wait_scan */
EXPORT_SYMBOL_GPL(scsi_complete_async_scans);
-#endif
/**
* scsi_unlock_floptical - unlock device via a special MODE SENSE command
Run Code Online (Sandbox Code Playgroud)
我在网上找到了上面的代码作为我遇到的问题的解决方案。我正在尝试为我自己的内核构建模块。我的问题是如何应用上述补丁?我想我必须在一个我可以看到的目录中/drivers,对吗?请问之后我该怎么办?
这是当我发出“make modules”来构建我的内核和相关的设备驱动程序时得到的错误:
sansari@ubuntu:~/WORKING_DIRECTORY$ make modules
scripts/kconfig/conf --silentoldconfig Kconfig …Run Code Online (Sandbox Code Playgroud) 在工作中,我们的任务是(即在检查或审计期间)显示系统上次修补的时间。这就是所问的一切。
当然,我问检查员你希望我如何向你展示这个...你希望我输入什么,而答复是...不是我的工作,我不知道,你应该知道。
那么我是否应该编写 c 代码,在运行时仅显示 5 天前的日期以及其他一些官方术语?
我只知道uname -a并说 go 参考这个内核版本以及 redhat 发布的版本和日期列表,并rpm -qa在这里说 go 参考所有 2000+ rpm 版本的最新版本。
是否有一些yum命令可以正确回答这个问题:您上次修补系统是什么时候?
这是在 RHEL 7.9 x86_64 上
我有一个大约 1500 行的 Linux 内核补丁——引入了一个新的文件系统。
我在将补丁直接发布到内核邮件列表时遇到了很多问题(gmail 破坏了补丁/它很长/除了手动等之外,没有很容易分解补丁的方法)
我不想使用 git format-patch,因为它会生成一长串的补丁,其中很多都是垃圾(例如调试 printks 等),我目前无法建议人们取消我的 git(我在路上,它在没有固定 IP 的笔记本电脑上等等)。
那么,最好的方法是什么?我担心这太大而无法在 github 上托管(是吗?)或者是否有一种简单的方法可以让人们能够以 LKML 上的人们可以接受的方式拉取补丁进行测试?
当 patch 命令找不到要修补的文件时,它会要求输入文件名。
有没有办法让它使用选项卡完成?
能够深入研究软件历史并为代码找到适当的理由是很棒的。
我想我第一次看到这些是在 Linux 补丁中 - 预源代码控制。很明显,在编写 Git 时,它支持补丁描述。但在 Git 之前,像 Subversion 或 CVS 这样的系统在编写时就考虑到了单行消息。
是否有其他影响我们可以追溯到这一点,或者它主要来自 Linux 开发?
我尝试添加有关最后一个内核的补丁,但不知道为什么不起作用..想法?谢谢
openwrtt$ patch -p1 < kernel.patch
patching file include/kernel-version.mk
Hunk #1 FAILED at 7.
1 out of 1 hunk FAILED -- saving rejects to file include/kernel-version.mk.rej
patching file target/linux/bcm27xx/patches-5.10/950-0139-xhci-implement-xhci_fixup_endpoint-for-interval-adju.patch
patching file target/linux/bcm27xx/patches-5.10/950-0151-hid-usb-Add-device-quirks-for-Freeway-Airmouse-T3-an.patch
patching file target/linux/bcm27xx/patches-5.10/950-0249-kbuild-Disable-gcc-plugins.patch
patching file target/linux/bcm27xx/patches-5.10/950-0323-media-i2c-Add-driver-for-Sony-IMX477-sensor.patch
patching file target/linux/bcm27xx/patches-5.10/950-0657-Documentation-devicetree-Add-documentation-for-imx37.patch
patching file target/linux/bcm27xx/patches-5.10/950-0733-usb-xhci-workaround-for-bogus-SET_DEQ_PENDING-endpoi.patch
Hunk #1 FAILED at 26.
1 out of 1 hunk FAILED -- saving rejects to file target/linux/bcm27xx/patches-5.10/950-0733-usb-xhci-workaround-for-bogus-SET_DEQ_PENDING-endpoi.patch.rej
patching file target/linux/generic/backport-5.10/610-v5.13-57-netfilter-flowtable-Set-offload-timeouts-according-t.patch
patching file target/linux/generic/backport-5.10/732-net-next-1-of-net-pass-the-dst-buffer-to-of_get_mac_address.patch
patching file target/linux/generic/pending-5.10/834-ledtrig-libata.patch
patching file target/linux/oxnas/patches-5.10/999-libata-hacks.patch
patching file target/linux/realtek/patches-5.10/008-5.17-watchdog-add-realtek-otto-watchdog-timer.patch
Run Code Online (Sandbox Code Playgroud) 我正在阅读 Peter Jay Salzman 的“Linux 内核模块编程”,在那本书中他们说
sys_call_table 不再在 2.6.x 内核中导出。如果你真的想尝试这个 DANGEROUS 模块,你必须对当前内核应用提供的补丁并重新编译它。
任何人都可以向我解释“补丁”的含义,以及重新编译内核的含义。
patch ×11
kernel ×2
linux-kernel ×2
android ×1
autocomplete ×1
development ×1
filenames ×1
history ×1
linux ×1
make ×1
openwrt ×1
rhel ×1
security ×1
terminology ×1
ubuntu ×1
yum ×1