From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7358338671440822272 X-Received: by 2002:ac8:5ac6:0:b0:436:b19d:c482 with SMTP id d6-20020ac85ac6000000b00436b19dc482mr6287679qtd.10.1713336606497; Tue, 16 Apr 2024 23:50:06 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:622a:24c:b0:437:2b27:29a1 with SMTP id c12-20020a05622a024c00b004372b2729a1ls2915629qtx.1.-pod-prod-09-us; Tue, 16 Apr 2024 23:50:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1P7J5U9t+E5fyYaLUl1n2XtcyU4LbYbMg7ff5u4aIskg2vguI9sG2OUpIsJl+TX1ljYW4GTzgjA== X-Received: by 2002:a05:620a:c42:b0:78e:e4f0:b51c with SMTP id u2-20020a05620a0c4200b0078ee4f0b51cmr641931qki.2.1713336605327; Tue, 16 Apr 2024 23:50:05 -0700 (PDT) X-Google-Web-Client: true Date: Tue, 16 Apr 2024 23:50:05 -0700 (PDT) From: Zhibin Dong To: isar-users Message-Id: In-Reply-To: <20240417064600.12133-1-zhibin.dong@siemens.com> References: <20240416051222.3344127-1-zhibin.dong@siemens.com> <20240417064600.12133-1-zhibin.dong@siemens.com> Subject: Re: [PATCH] image: check if the file is core dump MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_17510_683625708.1713336605092" X-TUID: PTGxg366viVT ------=_Part_17510_683625708.1713336605092 Content-Type: multipart/alternative; boundary="----=_Part_17511_66391011.1713336605092" ------=_Part_17511_66391011.1713336605092 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable How about using `--mime-type`? =E5=9C=A82024=E5=B9=B44=E6=9C=8817=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC+= 8 14:47:25 =E5=86=99=E9=81=93=EF=BC=9A > The previous code does a wrong judgement in two cases: > 1. a file is suffixed by .core but is not a core dump file > 2. a file is a core dump file but is not suffixed by .core > > The new code uses `file` to determine the type of files, which is more > accurate. > > Signed-off-by: Zhibin Dong > --- > meta/classes/image.bbclass | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 98741da0..2b0995d2 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -444,7 +444,7 @@ EOSUDO > > # Sometimes qemu-user-static generates coredumps in chroot, move them > # to work temporary directory and inform user about it. > - for f in $(sudo find ${ROOTFSDIR} -type f -name *.core); do > + for f in $(sudo find ${ROOTFSDIR} -type f -exec file --mime-type {} \; = |=20 > grep 'application/x-coredump' | cut -d: -f1); do > sudo mv "${f}" "${WORKDIR}/temp/" > bbwarn "found core dump in rootfs, check it in ${WORKDIR}/temp/${f##*/}" > done > --=20 > 2.39.2 > > ------=_Part_17511_66391011.1713336605092 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable How about using `--mime-type`?

=E5=9C=A82024=E5=B9=B44=E6=9C=8817=E6=97= =A5=E6=98=9F=E6=9C=9F=E4=B8=89 UTC+8 14:47:25<Zhibin Dong> =E5=86=99=E9= =81=93=EF=BC=9A
The previous code does a wrong judgement in two cases:
1. a file is suffixed by .core but is not a core dump file
2. a file is a core dump file but is not suffixed by .core

The new code uses `file` to determine the type of files, which is more
accurate.

Signed-off-by: Zhibin Dong <zhibi...@siemens.com>
---
meta/classes/image.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 98741da0..2b0995d2 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -444,7 +444,7 @@ EOSUDO
=20
# Sometimes qemu-user-static generates coredumps in chroot, move t= hem
# to work temporary directory and inform user about it.
- for f in $(sudo find ${ROOTFSDIR} -type f -name *.core); do
+ for f in $(sudo find ${ROOTFSDIR} -type f -exec file --mime-type {= } \; | grep 'application/x-coredump' | cut -d: -f1); do
sudo mv "${f}" "${WORKDIR}/temp/"
bbwarn "found core dump in rootfs, check it in ${WORKDIR}= /temp/${f##*/}"
done
--=20
2.39.2

------=_Part_17511_66391011.1713336605092-- ------=_Part_17510_683625708.1713336605092--