From 63a2b3fe875e98a2617c9394c0546ad8669c41d8 Mon Sep 17 00:00:00 2001 From: vcrhonek Date: Wed, 7 Mar 2007 13:39:56 +0000 Subject: [PATCH] smartmontools-5.37-cloexec.patch --- smartmontools-5.37-cloexec.patch | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 smartmontools-5.37-cloexec.patch diff --git a/smartmontools-5.37-cloexec.patch b/smartmontools-5.37-cloexec.patch new file mode 100644 index 0000000..24d5251 --- /dev/null +++ b/smartmontools-5.37-cloexec.patch @@ -0,0 +1,51 @@ +--- smartmontools-5.37/os_linux.cpp.fix 2006-10-25 19:01:42.000000000 +0200 ++++ smartmontools-5.37/os_linux.cpp 2007-02-27 13:20:55.000000000 +0100 +@@ -190,14 +190,14 @@ + + // equivalent to open(path, flags) + int deviceopen(const char *pathname, char *type){ ++ int fd = -1; + if (!strcmp(type,"SCSI")) { +- int fd = open(pathname, O_RDWR | O_NONBLOCK); ++ fd = open(pathname, O_RDWR | O_NONBLOCK); + if (fd < 0 && errno == EROFS) + fd = open(pathname, O_RDONLY | O_NONBLOCK); +- return fd; + } + else if (!strcmp(type,"ATA")) +- return open(pathname, O_RDONLY | O_NONBLOCK); ++ fd = open(pathname, O_RDONLY | O_NONBLOCK); + else if (!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 +@@ -207,7 +207,7 @@ + errno=ENXIO; + return -1; + } +- return open(pathname, O_RDONLY | O_NONBLOCK); ++ fd = open(pathname, O_RDONLY | O_NONBLOCK); + } + else if (!strcmp(type,"ATA_3WARE_678K")) { + // the device nodes for this controller are dynamically assigned, +@@ -218,15 +218,19 @@ + errno=ENXIO; + return -1; + } +- return open(pathname, O_RDONLY | O_NONBLOCK); ++ fd = open(pathname, O_RDONLY | O_NONBLOCK); + } + else if(!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)