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 "base/linux_util.h" | 5 #include "base/linux_util.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <glib.h> | 10 #include <glib.h> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // We do this check only once per process. If it fails, there's | 147 // We do this check only once per process. If it fails, there's |
148 // little reason to believe it will work if we attempt to run | 148 // little reason to believe it will work if we attempt to run |
149 // lsb_release again. | 149 // lsb_release again. |
150 std::vector<std::string> argv; | 150 std::vector<std::string> argv; |
151 argv.push_back("lsb_release"); | 151 argv.push_back("lsb_release"); |
152 argv.push_back("-d"); | 152 argv.push_back("-d"); |
153 std::string output; | 153 std::string output; |
154 base::GetAppOutput(CommandLine(argv), &output); | 154 base::GetAppOutput(CommandLine(argv), &output); |
155 if (output.length() > 0) { | 155 if (output.length() > 0) { |
156 // lsb_release -d should return: Description:<tab>Distro Info | 156 // lsb_release -d should return: Description:<tab>Distro Info |
157 static const std::string field = "Description:\t"; | 157 const char field[] = "Description:\t"; |
158 if (output.compare(0, field.length(), field) == 0) { | 158 if (output.compare(0, strlen(field), field) == 0) { |
159 SetLinuxDistro(output.substr(field.length())); | 159 SetLinuxDistro(output.substr(strlen(field))); |
160 } | 160 } |
161 } | 161 } |
162 distro_state_singleton->CheckFinished(); | 162 distro_state_singleton->CheckFinished(); |
163 return g_linux_distro; | 163 return g_linux_distro; |
164 } else if (STATE_CHECK_STARTED == state) { | 164 } else if (STATE_CHECK_STARTED == state) { |
165 // If the distro check above is in progress in some other thread, we're | 165 // If the distro check above is in progress in some other thread, we're |
166 // not going to wait for the results. | 166 // not going to wait for the results. |
167 return "Unknown"; | 167 return "Unknown"; |
168 } else { | 168 } else { |
169 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|. | 169 // In STATE_CHECK_FINISHED, no more writing to |linux_distro|. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 if (0 == strncmp(expected_data.c_str(), syscall_data.get(), | 297 if (0 == strncmp(expected_data.c_str(), syscall_data.get(), |
298 expected_data.length())) { | 298 expected_data.length())) { |
299 return current_tid; | 299 return current_tid; |
300 } | 300 } |
301 } | 301 } |
302 return -1; | 302 return -1; |
303 } | 303 } |
304 | 304 |
305 } // namespace base | 305 } // namespace base |
OLD | NEW |