This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH RFC] Fix failure of signing modules on XFS


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]