rpms/smartmontools/devel smartmontools-5.38-cloexec.patch,NONE,1.1

Tomas Smetana (tsmetana) fedora-extras-commits at redhat.com
Mon Mar 10 12:41:06 UTC 2008


Author: tsmetana

Update of /cvs/pkgs/rpms/smartmontools/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21557

Added Files:
	smartmontools-5.38-cloexec.patch 
Log Message:
add cloexec patch

smartmontools-5.38-cloexec.patch:

--- NEW FILE smartmontools-5.38-cloexec.patch ---
diff -up smartmontools-5.38/os_linux.cpp.cloexec smartmontools-5.38/os_linux.cpp
--- smartmontools-5.38/os_linux.cpp.cloexec	2008-03-10 10:01:25.000000000 +0100
+++ smartmontools-5.38/os_linux.cpp	2008-03-10 10:09:26.000000000 +0100
@@ -171,7 +171,7 @@ static char prev_scsi_dev[128];
 
 // equivalent to open(path, flags)
 int deviceopen(const char *pathname, char *type){
-  int fd;
+  int fd = -1;
 
   if (0 == strcmp(type,"SCSI")) {
     strncpy(prev_scsi_dev, pathname, sizeof(prev_scsi_dev) - 1);
@@ -186,9 +186,9 @@ int deviceopen(const char *pathname, cha
     // The purpose of the next code line is to limit the scope of
     // this change as a release is pending (and smartd needs a rewrite).
     if (0 == strncmp(pathname, prev_scsi_dev, sizeof(prev_scsi_dev)))
-      return open(pathname, O_RDWR | O_NONBLOCK);
+      fd = open(pathname, O_RDWR | O_NONBLOCK);
     else
-      return open(pathname, O_RDONLY | O_NONBLOCK);
+      fd = open(pathname, O_RDONLY | O_NONBLOCK);
   } else if (0 == strcmp(type,"ATA_3WARE_9000")) {
     // the device nodes for this controller are dynamically assigned,
     // so we need to check that they exist with the correct major
@@ -198,7 +198,7 @@ int deviceopen(const char *pathname, cha
         errno=ENXIO;
       return -1;
     }
-    return open(pathname, O_RDONLY | O_NONBLOCK);
+    fd = open(pathname, O_RDONLY | O_NONBLOCK);
   }
   else if (0 == strcmp(type,"ATA_3WARE_678K")) {
     // the device nodes for this controller are dynamically assigned,
@@ -209,15 +209,17 @@ int deviceopen(const char *pathname, cha
         errno=ENXIO;
       return -1;
     }
-    return open(pathname, O_RDONLY | O_NONBLOCK);
+    fd = open(pathname, O_RDONLY | O_NONBLOCK);
   }
   else if(0 == strcmp(type, "CCISS")) {
     // the device is a cciss smart array device.
-    return open(pathname, O_RDWR | O_NONBLOCK);
+    fd = open(pathname, O_RDWR | O_NONBLOCK);
   }
-  else
-    return -1;
 
+  if (fd != -1) {
+    fcntl(fd, F_SETFD, FD_CLOEXEC);
+  }
+  return fd;
 }
 
 // equivalent to close(file descriptor)




More information about the fedora-extras-commits mailing list