| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 #if defined(OS_OPENBSD) | 9 #if defined(OS_OPENBSD) |
| 10 #include <sys/exec_elf.h> | 10 #include <sys/exec_elf.h> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // the current architecture (e.g. 32-bit ELF on 32-bit build). | 166 // the current architecture (e.g. 32-bit ELF on 32-bit build). |
| 167 // Returns false on other errors as well. | 167 // Returns false on other errors as well. |
| 168 bool ELFMatchesCurrentArchitecture(const base::FilePath& filename) { | 168 bool ELFMatchesCurrentArchitecture(const base::FilePath& filename) { |
| 169 // First make sure we can open the file and it is in fact, a regular file. | 169 // First make sure we can open the file and it is in fact, a regular file. |
| 170 struct stat stat_buf; | 170 struct stat stat_buf; |
| 171 // Open with O_NONBLOCK so we don't block on pipes. | 171 // Open with O_NONBLOCK so we don't block on pipes. |
| 172 int fd = open(filename.value().c_str(), O_RDONLY|O_NONBLOCK); | 172 int fd = open(filename.value().c_str(), O_RDONLY|O_NONBLOCK); |
| 173 if (fd < 0) | 173 if (fd < 0) |
| 174 return false; | 174 return false; |
| 175 bool ret = (fstat(fd, &stat_buf) >= 0 && S_ISREG(stat_buf.st_mode)); | 175 bool ret = (fstat(fd, &stat_buf) >= 0 && S_ISREG(stat_buf.st_mode)); |
| 176 if (HANDLE_EINTR(close(fd)) < 0) | 176 if (IGNORE_EINTR(close(fd)) < 0) |
| 177 return false; | 177 return false; |
| 178 if (!ret) | 178 if (!ret) |
| 179 return false; | 179 return false; |
| 180 | 180 |
| 181 const size_t kELFBufferSize = 5; | 181 const size_t kELFBufferSize = 5; |
| 182 char buffer[kELFBufferSize]; | 182 char buffer[kELFBufferSize]; |
| 183 if (!file_util::ReadFile(filename, buffer, kELFBufferSize)) | 183 if (!file_util::ReadFile(filename, buffer, kELFBufferSize)) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 if (buffer[0] != ELFMAG0 || | 186 if (buffer[0] != ELFMAG0 || |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 584 } |
| 585 | 585 |
| 586 // TODO(evanm): prefer the newest version of flash, etc. here? | 586 // TODO(evanm): prefer the newest version of flash, etc. here? |
| 587 | 587 |
| 588 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); | 588 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); |
| 589 | 589 |
| 590 return true; | 590 return true; |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace content | 593 } // namespace content |
| OLD | NEW |