!42 同步上游社区补丁

From: @dongyuzhen 
Reviewed-by: @hubin95 
Signed-off-by: @hubin95
This commit is contained in:
openeuler-ci-bot 2023-06-14 08:22:46 +00:00 committed by Gitee
commit 7020426af3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,72 @@
From 19c6e483982456b9cf78c87b9cf3c90e98d63024 Mon Sep 17 00:00:00 2001
From: Masatake YAMATO <yamato@redhat.com>
Date: Sun, 23 Apr 2023 14:48:46 +0800
Subject: [PATCH] backport fix Fo option
-Fo option is for printing file offset. For regular files,
the option didn't work.
Here is a command session demonstrating the fix:
# ./lsof -Fo -o0| grep ^o | sort | uniq -c
90586 o0t0
87 o0t101
84 o0t103
...
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Reference:https://github.com/lsof-org/lsof/commit/6435e7667cbf5b1a616606aa019892df43f3ade1
Conflict:NA
---
main.c | 4 ++++
tests/case-20-offset-field.bash | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 tests/case-20-offset-field.bash
diff --git a/main.c b/main.c
index 169e334..9e3bbd8 100644
--- a/main.c
+++ b/main.c
@@ -554,6 +554,10 @@ main(argc, argv)
if (i == LSOF_FIX_TERM)
Terminator = '\0';
+
+ if (i == LSOF_FIX_OFFSET)
+ Foffset = 1;
+
break;
}
}
diff --git a/tests/case-20-offset-field.bash b/tests/case-20-offset-field.bash
new file mode 100644
index 0000000..a5dc369
--- /dev/null
+++ b/tests/case-20-offset-field.bash
@@ -0,0 +1,24 @@
+name=$(basename $0 .bash)
+lsof=$1
+report=$2
+base=$(pwd)
+
+t=/tmp/lsof-test-reg-file-$$
+p=/tmp/lsof-test-reg-fifo-$$
+
+mkfifo $p
+{
+ printf "%d" 1
+ read < $p &
+} | cat > $t &
+
+r=1
+if [ "$($lsof -Fo $t | grep '^o')" = o0t1 ]; then
+ echo > $p
+ r=0
+fi
+
+rm /tmp/lsof-test-reg-file-$$
+rm /tmp/lsof-test-reg-fifo-$$
+
+exit $r
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: lsof
Version: 4.93.2
Release: 9
Release: 10
Summary: A tool for list open files
License: zlib and Sendmail and LGPLv2+
URL: https://people.freebsd.org/~abe/
@ -10,6 +10,7 @@ Patch1: 0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch
Patch2: 0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch
Patch3: Handle-ffff-ffff-in-ipv6-addr-correctly.patch
Patch4: backport-Fill-the-buffer-using-pipe-communication-with-zero.patch
Patch5: backport-fix-Fo-option.patch
BuildRequires: gcc git libtirpc-devel libselinux-devel
@ -55,6 +56,9 @@ popd
%{_mandir}/man*/*
%changelog
* Wed Jun 14 2023 dongyuzhen <dongyuzhen@h-partners.com> - 4.93.2-10
- backport upstream patches
* Thu Feb 16 2023 hubin <hubin73@huawei.com> - 4.93.2-9
- Type:testcode
- ID:NA