OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "crash-reporter/crash_collector.h" | 5 #include "crash-reporter/crash_collector.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <pwd.h> // For struct passwd. | 8 #include <pwd.h> // For struct passwd. |
9 #include <sys/types.h> // for mode_t. | 9 #include <sys/types.h> // for mode_t. |
10 | 10 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "crash-reporter/system_logging.h" | 14 #include "crash-reporter/system_logging.h" |
15 | 15 |
16 static const char kDefaultUserName[] = "chronos"; | 16 static const char kDefaultUserName[] = "chronos"; |
17 static const char kSystemCrashPath[] = "/var/spool/crash"; | 17 static const char kSystemCrashPath[] = "/var/spool/crash"; |
18 static const char kUserCrashPath[] = "/home/chronos/user/crash"; | 18 static const char kUserCrashPath[] = "/home/chronos/user/crash"; |
19 | 19 |
20 // Directory mode of the user crash spool directory. | 20 // Directory mode of the user crash spool directory. |
21 static const mode_t kUserCrashPathMode = 0755; | 21 static const mode_t kUserCrashPathMode = 0755; |
22 | 22 |
23 // Directory mode of the system crash spool directory. | 23 // Directory mode of the system crash spool directory. |
24 static const mode_t kSystemCrashPathMode = 01755; | 24 static const mode_t kSystemCrashPathMode = 01755; |
25 | 25 |
26 static const uid_t kRootOwner = 0; | 26 static const uid_t kRootOwner = 0; |
27 static const uid_t kRootGroup = 0; | 27 static const uid_t kRootGroup = 0; |
28 | 28 |
29 // Maximum of 8 crash reports per directory. | 29 // Maximum crash reports per crash spool directory. Note that this is |
30 const int CrashCollector::kMaxCrashDirectorySize = 8; | 30 // a separate maximum from the maximum rate at which we upload these |
| 31 // diagnostics. The higher this rate is, the more space we allow for |
| 32 // core files, minidumps, and kcrash logs, and equivalently the more |
| 33 // processor and I/O bandwidth we dedicate to handling these crashes when |
| 34 // many occur at once. Also note that if core files are configured to |
| 35 // be left on the file system, we stop adding crashes when either the |
| 36 // number of core files or minidumps reaches this number. |
| 37 const int CrashCollector::kMaxCrashDirectorySize = 32; |
31 | 38 |
32 CrashCollector::CrashCollector() : forced_crash_directory_(NULL) { | 39 CrashCollector::CrashCollector() : forced_crash_directory_(NULL) { |
33 } | 40 } |
34 | 41 |
35 CrashCollector::~CrashCollector() { | 42 CrashCollector::~CrashCollector() { |
36 } | 43 } |
37 | 44 |
38 void CrashCollector::Initialize( | 45 void CrashCollector::Initialize( |
39 CrashCollector::CountCrashFunction count_crash_function, | 46 CrashCollector::CountCrashFunction count_crash_function, |
40 CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function, | 47 CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 "Crash directory %s already full with %d pending reports", | 193 "Crash directory %s already full with %d pending reports", |
187 crash_directory.value().c_str(), | 194 crash_directory.value().c_str(), |
188 kMaxCrashDirectorySize); | 195 kMaxCrashDirectorySize); |
189 full = true; | 196 full = true; |
190 break; | 197 break; |
191 } | 198 } |
192 } | 199 } |
193 closedir(dir); | 200 closedir(dir); |
194 return !full; | 201 return !full; |
195 } | 202 } |
OLD | NEW |