| // Copyright 2021 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef F2FS_TYPES_H |
| #define F2FS_TYPES_H |
| |
| #include <sys/types.h> |
| #include <threads.h> |
| #include <zircon/types.h> |
| #include <zircon/listnode.h> |
| #include <stdatomic.h> |
| |
| namespace f2fs { |
| |
| // Fuchsia only runs on little endian (LE) CPU architectures |
| using __be32 = uint32_t; |
| using __be16 = uint16_t; |
| using __le64 = uint64_t; |
| using __le32 = uint32_t; |
| using __le16 = uint16_t; |
| using __s8 = uint8_t; |
| using __u8 = uint8_t; |
| using __u16 = uint16_t; |
| using __u32 = uint32_t; |
| using __u64 = uint64_t; |
| using sector_t = uint64_t; |
| using f2fs_hash_t = uint32_t; |
| using gfp_t = uint32_t; |
| using block_t = uint64_t; |
| using nid_t = uint32_t; |
| using ino_t = uint32_t; |
| using pgoff_t = unsigned long; |
| using atomic_t = atomic_int; |
| using umode_t = unsigned short; |
| |
| #define le16_to_cpu(x) ((__u16)(x)) |
| #define le32_to_cpu(x) ((__u32)(x)) |
| #define le64_to_cpu(x) ((__u64)(x)) |
| #define cpu_to_le16(x) ((__u16)(x)) |
| #define cpu_to_le32(x) ((__u32)(x)) |
| #define cpu_to_le64(x) ((__u64)(x)) |
| |
| #define PAGE_SIZE 4096 |
| #define PAGE_CACHE_SIZE 4096 |
| #define BITS_PER_BYTE 8 |
| #define PAGE_CACHE_SHIFT 12 |
| |
| #define REQ_SYNC (1 << __REQ_SYNC) |
| |
| struct Page { |
| uint8_t data[PAGE_CACHE_SIZE]; |
| uint32_t index; // metainode=lba, nodeinode=node id, fileinode=fileofs; |
| void *host; // metainode = null, nodeinode = null, fileinode = vnodef2fs |
| uint32_t |
| host_nid; // metapage = F2FS_META_INO(sbi), nodepage = F2FS_NODE_INO, filepage = host->nid_) |
| }; |
| |
| //////////////////////////////////////////////////////////// |
| // using arch_spinlock_t = struct { |
| // volatile unsigned int lock; |
| // }; |
| |
| // using raw_spinlock_t = struct raw_spinlock { |
| // arch_spinlock_t raw_lock; |
| // }; |
| |
| // using spinlock_t = struct raw_spinlock; |
| |
| // using arch_rwlock_t = struct { |
| // volatile unsigned int lock; |
| // }; |
| |
| // using rwlock_t = struct { |
| // arch_rwlock_t raw_lock; |
| // }; |
| |
| using spinlock_t = mtx_t; |
| using rwlock_t = mtx_t; |
| |
| struct rcu_head {}; |
| |
| // Radix Tree |
| #define radix_tree_root xarray |
| #define radix_tree_node xa_node |
| |
| struct xarray {}; |
| |
| struct xa_node {}; |
| |
| struct dentry {}; |
| |
| } // namespace f2fs |
| |
| #endif |