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 "update_engine/extent_mapper.h" | 5 #include "update_engine/extent_mapper.h" |
6 | 6 |
7 #include <sys/ioctl.h> | 7 #include <sys/ioctl.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const int block_count = (stbuf.st_size + kBlockSize - 1) / kBlockSize; | 51 const int block_count = (stbuf.st_size + kBlockSize - 1) / kBlockSize; |
52 Extent current; | 52 Extent current; |
53 current.set_start_block(0); | 53 current.set_start_block(0); |
54 current.set_num_blocks(0); | 54 current.set_num_blocks(0); |
55 | 55 |
56 for (int i = 0; i < block_count; i++) { | 56 for (int i = 0; i < block_count; i++) { |
57 unsigned int block32 = i; | 57 unsigned int block32 = i; |
58 rc = ioctl(fd, FIBMAP, &block32); | 58 rc = ioctl(fd, FIBMAP, &block32); |
59 TEST_AND_RETURN_FALSE_ERRNO(rc == 0); | 59 TEST_AND_RETURN_FALSE_ERRNO(rc == 0); |
60 | 60 |
61 const uint64 block = (block32 == 0 ? kSparseHole : block32); | 61 const uint64_t block = (block32 == 0 ? kSparseHole : block32); |
62 | 62 |
63 graph_utils::AppendBlockToExtents(out, block); | 63 graph_utils::AppendBlockToExtents(out, block); |
64 } | 64 } |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 bool GetFilesystemBlockSize(const std::string& path, uint32* out_blocksize) { | 68 bool GetFilesystemBlockSize(const std::string& path, uint32_t* out_blocksize) { |
69 int fd = open(path.c_str(), O_RDONLY, 0); | 69 int fd = open(path.c_str(), O_RDONLY, 0); |
70 TEST_AND_RETURN_FALSE_ERRNO(fd >= 0); | 70 TEST_AND_RETURN_FALSE_ERRNO(fd >= 0); |
71 ScopedFdCloser fd_closer(&fd); | 71 ScopedFdCloser fd_closer(&fd); |
72 int rc = ioctl(fd, FIGETBSZ, out_blocksize); | 72 int rc = ioctl(fd, FIGETBSZ, out_blocksize); |
73 TEST_AND_RETURN_FALSE_ERRNO(rc != -1); | 73 TEST_AND_RETURN_FALSE_ERRNO(rc != -1); |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 } // namespace extent_mapper | 77 } // namespace extent_mapper |
78 | 78 |
79 } // namespace chromeos_update_engine | 79 } // namespace chromeos_update_engine |
OLD | NEW |