| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-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 // Contains the implementation of class Platform | 5 // Contains the implementation of class Platform |
| 6 | 6 |
| 7 #include "platform.h" | 7 #include "platform.h" |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <limits.h> | 10 #include <limits.h> |
| 11 #include <pwd.h> | 11 #include <pwd.h> |
| 12 #include <signal.h> | 12 #include <signal.h> |
| 13 #include <sys/mount.h> | 13 #include <sys/mount.h> |
| 14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
| 15 #include <sys/statvfs.h> |
| 15 #include <sys/types.h> | 16 #include <sys/types.h> |
| 16 | 17 |
| 17 #include <base/file_util.h> | 18 #include <base/file_util.h> |
| 18 #include <base/string_util.h> | 19 #include <base/string_util.h> |
| 19 | 20 |
| 20 // Included last to avoid redefinition problems | 21 // Included last to avoid redefinition problems |
| 21 extern "C" { | 22 extern "C" { |
| 22 #include <keyutils.h> | 23 #include <keyutils.h> |
| 23 } | 24 } |
| 24 | 25 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 std::vector<char> user_name_buf(user_name_length); | 360 std::vector<char> user_name_buf(user_name_length); |
| 360 if (getpwnam_r(user.c_str(), &user_info, &user_name_buf[0], | 361 if (getpwnam_r(user.c_str(), &user_info, &user_name_buf[0], |
| 361 user_name_length, &user_infop)) { | 362 user_name_length, &user_infop)) { |
| 362 return false; | 363 return false; |
| 363 } | 364 } |
| 364 *user_id = user_info.pw_uid; | 365 *user_id = user_info.pw_uid; |
| 365 *group_id = user_info.pw_gid; | 366 *group_id = user_info.pw_gid; |
| 366 return true; | 367 return true; |
| 367 } | 368 } |
| 368 | 369 |
| 370 int64 Platform::AmountOfFreeDiskSpace(const string& path) { |
| 371 struct statvfs stats; |
| 372 if (statvfs(path.c_str(), &stats) != 0) { |
| 373 return -1; |
| 374 } |
| 375 return static_cast<int64>(stats.f_bavail) * stats.f_frsize; |
| 376 } |
| 377 |
| 369 void Platform::ClearUserKeyring() { | 378 void Platform::ClearUserKeyring() { |
| 370 keyctl(KEYCTL_CLEAR, KEY_SPEC_USER_KEYRING); | 379 keyctl(KEYCTL_CLEAR, KEY_SPEC_USER_KEYRING); |
| 371 } | 380 } |
| 372 | 381 |
| 373 } // namespace cryptohome | 382 } // namespace cryptohome |
| OLD | NEW |