This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH RFC] Fix failure of signing modules on XFS
- From: qiaonuohan <qiaonuohan at cn dot fujitsu dot com>
- To: David Smith <dsmith at redhat dot com>, <systemtap at sourceware dot org>
- Date: Tue, 7 Apr 2015 10:15:38 +0800
- Subject: Re: [PATCH RFC] Fix failure of signing modules on XFS
- Authentication-results: sourceware.org; auth=none
- References: <1428048726-4288-1-git-send-email-qiaonuohan at cn dot fujitsu dot com> <5522BD25 dot 6080209 at redhat dot com>
Hello David,
On 04/07/2015 01:06 AM, David Smith wrote:
But, I'd like to avoid the stat() syscall when possible. So, I tweaked
your patch a bit. The following compiles, but I haven't tried it.
Let me know if it works for you and I'll check it in.
Handleing DT_UNKNOWN seems better. And the following patch work well on my
machine. Thanks.
====
diff --git a/stap-serverd.cxx b/stap-serverd.cxx
index 40b3c39..98611c9 100644
--- a/stap-serverd.cxx
+++ b/stap-serverd.cxx
@@ -370,13 +370,28 @@ mok_dir_valid_p (string mok_fingerprint, bool verbose)
struct dirent *direntp;
while ((direntp = readdir (dirp)) != NULL)
{
- if (! priv_found && direntp->d_type == DT_REG
+ bool reg_file = false;
+
+ if (direntp->d_type == DT_REG)
+ reg_file = true;
+ else if (direntp->d_type == DT_UNKNOWN)
+ {
+ struct stat tmpstat;
+
+ // If the filesystem doesn't support d_type, we'll have to
+ // call stat().
+ stat((mok_dir + "/" + direntp->d_name).c_str (), &tmpstat);
+ if (S_ISREG(tmpstat.st_mode))
+ reg_file = true;
+ }
+
+ if (! priv_found && reg_file
&& strcmp (direntp->d_name, MOK_PRIVATE_CERT_NAME) == 0)
{
priv_found = true;
continue;
}
- if (! cert_found && direntp->d_type == DT_REG
+ if (! cert_found && reg_file
&& strcmp (direntp->d_name, MOK_PUBLIC_CERT_NAME) == 0)
{
cert_found = true;
====
--
Regards
Qiao Nuohan