代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/grub2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 9917f2b39a6a6cd1f8d3ec50773b445158f9b1ef Mon Sep 17 00:00:00 2001
From: Michael Chang <MChang@suse.com>
Date: Tue, 5 Nov 2019 09:19:26 +0000
Subject: [PATCH] hostdisk: Set linux file descriptor to O_CLOEXEC as default
We are often bothered by this sort of lvm warning while running grub-install
every now and then:
File descriptor 4 (/dev/vda1) leaked on vgs invocation. Parent PID 1991: /usr/sbin/grub2-install
The requirement related to the warning is dictated in the lvm man page:
"On invocation, lvm requires that only the standard file descriptors stdin,
stdout and stderr are available. If others are found, they get closed and
messages are issued warning about the leak. This warning can be suppressed by
setting the environment variable LVM_SUPPRESS_FD_WARNINGS."
While it could be disabled through settings, most Linux distributions seem to
enable it by default and the justification provided by the developer looks to
be valid to me: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466138#15
Rather than trying to close and reopen the file descriptor to the same file
multiple times, which is rather cumbersome, for the sake of no vgs invocation
could happen in between. This patch enables the close-on-exec flag (O_CLOEXEC)
for new file descriptor returned by the open() system call, making it closed
thus not inherited by the child process forked and executed by the exec()
family of functions.
Fixes Debian bug #466138.
Reference: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=42acdd3b405c44d08439a3bbfdbd3466049d172d
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/osdep/linux/hostdisk.c | 3 +++
grub-core/osdep/unix/hostdisk.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
index 370d027..7bc99ac 100644
--- a/grub-core/osdep/linux/hostdisk.c
+++ b/grub-core/osdep/linux/hostdisk.c
@@ -366,6 +366,9 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
#ifdef O_BINARY
flags |= O_BINARY;
#endif
+#ifdef O_CLOEXEC
+ flags |= O_CLOEXEC;
+#endif
/* Linux has a bug that the disk cache for a whole disk is not consistent
with the one for a partition of the disk. */
diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c
index 9115096..3a00d74 100644
--- a/grub-core/osdep/unix/hostdisk.c
+++ b/grub-core/osdep/unix/hostdisk.c
@@ -164,6 +164,9 @@ grub_util_fd_open (const char *os_dev, int flags)
#ifdef O_BINARY
flags |= O_BINARY;
#endif
+#ifdef O_CLOEXEC
+ flags |= O_CLOEXEC;
+#endif
return open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR);
}
--
2.19.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。