[f2fs] Change file type table to const array
(comment: #13 https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/528754)
Test:
- fx test fs-tests large-fs-tests
Change-Id: I1d475a1bf4c625087e646e0ee95cf3cb24d287b9
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/540141
Reviewed-by: Brett Wilson <brettw@google.com>
diff --git a/dir.cc b/dir.cc
index ad3a2ea..174ac23 100644
--- a/dir.cc
+++ b/dir.cc
@@ -27,7 +27,7 @@
}
void Dir::SetDeType(DirEntry *de, VnodeF2fs *vnode) {
- de->file_type = type_by_mode[(vnode->i_mode_ & S_IFMT) >> kStatShift];
+ de->file_type = kTypeByMode[(vnode->i_mode_ & S_IFMT) >> kStatShift];
}
uint64_t Dir::DirBlockIndex(unsigned int level, unsigned int idx) {
@@ -588,7 +588,6 @@
uint64_t *pos_cookie = reinterpret_cast<uint64_t *>(cookie);
uint64_t pos = *pos_cookie;
uint64_t npages = DirBlocks();
- unsigned char *types = nullptr;
unsigned int bit_pos = 0, start_bit_pos = 0;
DentryBlock *dentry_blk = nullptr;
DirEntry *de = nullptr;
@@ -601,7 +600,7 @@
fbl::AutoLock lock(&i_mutex_);
- types = filetype_table;
+ const unsigned char *types = kFiletypeTable;
bit_pos = (pos % kNrDentryInBlock);
n = (pos / kNrDentryInBlock);
diff --git a/dir.h b/dir.h
index bedef67..c9db068 100644
--- a/dir.h
+++ b/dir.h
@@ -10,7 +10,7 @@
namespace f2fs {
-static unsigned char filetype_table[static_cast<uint8_t>(FileType::kFtMax)] = {
+const unsigned char kFiletypeTable[static_cast<uint8_t>(FileType::kFtMax)] = {
[static_cast<uint8_t>(FileType::kFtUnknown)] = DT_UNKNOWN,
[static_cast<uint8_t>(FileType::kFtRegFile)] = DT_REG,
[static_cast<uint8_t>(FileType::kFtDir)] = DT_DIR,
@@ -23,7 +23,7 @@
constexpr unsigned int kStatShift = 12;
-static unsigned char type_by_mode[S_IFMT >> kStatShift] = {
+const unsigned char kTypeByMode[S_IFMT >> kStatShift] = {
[S_IFREG >> kStatShift] = static_cast<uint8_t>(FileType::kFtRegFile),
[S_IFDIR >> kStatShift] = static_cast<uint8_t>(FileType::kFtDir),
[S_IFCHR >> kStatShift] = static_cast<uint8_t>(FileType::kFtChrdev),