Android-cuttlefish cvd tool
Classes | Macros | Functions | Variables
libf2fs.c File Reference
#include <f2fs_fs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <libgen.h>
#include <time.h>
#include <sys/stat.h>
Include dependency graph for libf2fs.c:

Classes

struct  enc_flags
 

Macros

#define MODELINQUIRY   0x12,0x00,0x00,0x00,0x4A,0x00
 
#define O_BINARY   0
 
#define BITMAP_FIRST_BYTE_MASK(start)   (0xff << ((start) & (BITS_PER_BYTE - 1)))
 
#define DELTA   0x9E3779B9
 
#define CRCPOLY_LE   0xedb88320
 
#define ARRAY_SIZE(array)    (sizeof(array) / sizeof(array[0]))
 

Functions

static const char * utf8_to_wchar (const char *input, wchar_t *wc, size_t insize)
 
static uint16_t * wchar_to_utf16 (uint16_t *output, wchar_t wc, size_t outsize)
 
int utf8_to_utf16 (char *output, const char *input, size_t outsize, size_t insize)
 
static uint16_t * utf16_to_wchar (uint16_t *input, wchar_t *wc, size_t insize)
 
static char * wchar_to_utf8 (char *output, wchar_t wc, size_t outsize)
 
int utf16_to_utf8 (char *output, const char *input, size_t outsize, size_t insize)
 
int log_base_2 (uint32_t num)
 
int get_bits_in_byte (unsigned char n)
 
int test_and_set_bit_le (u32 nr, u8 *addr)
 
int test_and_clear_bit_le (u32 nr, u8 *addr)
 
int test_bit_le (u32 nr, const u8 *addr)
 
int f2fs_test_bit (unsigned int nr, const char *p)
 
int f2fs_set_bit (unsigned int nr, char *addr)
 
int f2fs_clear_bit (unsigned int nr, char *addr)
 
static u64 __ffs (u8 word)
 
static u64 _find_next_bit_le (const u8 *addr, u64 nbits, u64 start, char invert)
 
u64 find_next_bit_le (const u8 *addr, u64 size, u64 offset)
 
u64 find_next_zero_bit_le (const u8 *addr, u64 size, u64 offset)
 
static void TEA_transform (unsigned int buf[4], unsigned int const in[])
 
static void str2hashbuf (const unsigned char *msg, int len, unsigned int *buf, int num)
 
static f2fs_hash_t __f2fs_dentry_hash (const unsigned char *name, int len)
 
f2fs_hash_t f2fs_dentry_hash (int encoding, int casefolded, const unsigned char *name, int len)
 
unsigned int addrs_per_page (struct f2fs_inode *i, bool is_inode)
 
u64 f2fs_max_file_offset (struct f2fs_inode *i)
 
uint32_t f2fs_cal_crc32 (uint32_t crc, void *buf, int len)
 
int f2fs_crc_valid (uint32_t blk_crc, void *buf, int len)
 
__u32 f2fs_inode_chksum (struct f2fs_node *node)
 
__u32 f2fs_checkpoint_chksum (struct f2fs_checkpoint *cp)
 
int write_inode (struct f2fs_node *inode, u64 blkaddr, enum rw_hint whint)
 
char * get_rootdev ()
 
void f2fs_init_configuration (void)
 
int f2fs_dev_is_writable (void)
 
int f2fs_dev_is_umounted (char *path)
 
int f2fs_devs_are_umounted (void)
 
void get_kernel_version (__u8 *version)
 
void get_kernel_uname_version (__u8 *version)
 
static int open_check_fs (char *path, int flag)
 
int get_device_info (int i)
 
int f2fs_get_device_info (void)
 
int f2fs_get_f2fs_info (void)
 
unsigned int calc_extra_isize (void)
 
int f2fs_str2encoding (const char *string)
 
char * f2fs_encoding2str (const int encoding)
 
int f2fs_get_encoding_flags (int encoding)
 
int f2fs_str2encoding_flags (char **param, __u16 *flags)
 

Variables

static const int bits_in_byte [256]
 
struct {
   char *   name
 
   __u16   encoding_magic
 
   __u16   default_flags
 
f2fs_encoding_map []
 
static const struct enc_flags encoding_flags []
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   array)     (sizeof(array) / sizeof(array[0]))

◆ BITMAP_FIRST_BYTE_MASK

#define BITMAP_FIRST_BYTE_MASK (   start)    (0xff << ((start) & (BITS_PER_BYTE - 1)))

◆ CRCPOLY_LE

#define CRCPOLY_LE   0xedb88320

◆ DELTA

#define DELTA   0x9E3779B9

◆ MODELINQUIRY

#define MODELINQUIRY   0x12,0x00,0x00,0x00,0x4A,0x00

libf2fs.c

Copyright (c) 2013 Samsung Electronics Co., Ltd. http://www.samsung.com/

Dual licensed under the GPL or LGPL version 2 licenses.

◆ O_BINARY

#define O_BINARY   0

Function Documentation

◆ __f2fs_dentry_hash()

static f2fs_hash_t __f2fs_dentry_hash ( const unsigned char *  name,
int  len 
)
static

Return hash value of directory entry

Parameters
namedentry name
lenname lenth
Returns
return on success hash value, errno on failure

◆ __ffs()

static u64 __ffs ( u8  word)
inlinestatic

◆ _find_next_bit_le()

static u64 _find_next_bit_le ( const u8 addr,
u64  nbits,
u64  start,
char  invert 
)
static

◆ addrs_per_page()

unsigned int addrs_per_page ( struct f2fs_inode i,
bool  is_inode 
)

◆ calc_extra_isize()

unsigned int calc_extra_isize ( void  )

◆ f2fs_cal_crc32()

uint32_t f2fs_cal_crc32 ( uint32_t  crc,
void *  buf,
int  len 
)

◆ f2fs_checkpoint_chksum()

__u32 f2fs_checkpoint_chksum ( struct f2fs_checkpoint cp)

◆ f2fs_clear_bit()

int f2fs_clear_bit ( unsigned int  nr,
char *  addr 
)

◆ f2fs_crc_valid()

int f2fs_crc_valid ( uint32_t  blk_crc,
void *  buf,
int  len 
)

◆ f2fs_dentry_hash()

f2fs_hash_t f2fs_dentry_hash ( int  encoding,
int  casefolded,
const unsigned char *  name,
int  len 
)

◆ f2fs_dev_is_umounted()

int f2fs_dev_is_umounted ( char *  path)

◆ f2fs_dev_is_writable()

int f2fs_dev_is_writable ( void  )

◆ f2fs_devs_are_umounted()

int f2fs_devs_are_umounted ( void  )

◆ f2fs_encoding2str()

char * f2fs_encoding2str ( const int  encoding)

◆ f2fs_get_device_info()

int f2fs_get_device_info ( void  )

◆ f2fs_get_encoding_flags()

int f2fs_get_encoding_flags ( int  encoding)

◆ f2fs_get_f2fs_info()

int f2fs_get_f2fs_info ( void  )

◆ f2fs_init_configuration()

void f2fs_init_configuration ( void  )

◆ f2fs_inode_chksum()

__u32 f2fs_inode_chksum ( struct f2fs_node node)

◆ f2fs_max_file_offset()

u64 f2fs_max_file_offset ( struct f2fs_inode i)

◆ f2fs_set_bit()

int f2fs_set_bit ( unsigned int  nr,
char *  addr 
)

◆ f2fs_str2encoding()

int f2fs_str2encoding ( const char *  string)

◆ f2fs_str2encoding_flags()

int f2fs_str2encoding_flags ( char **  param,
__u16 flags 
)

◆ f2fs_test_bit()

int f2fs_test_bit ( unsigned int  nr,
const char *  p 
)

◆ find_next_bit_le()

u64 find_next_bit_le ( const u8 addr,
u64  size,
u64  offset 
)

◆ find_next_zero_bit_le()

u64 find_next_zero_bit_le ( const u8 addr,
u64  size,
u64  offset 
)

◆ get_bits_in_byte()

int get_bits_in_byte ( unsigned char  n)

◆ get_device_info()

int get_device_info ( int  i)

◆ get_kernel_uname_version()

void get_kernel_uname_version ( __u8 version)

◆ get_kernel_version()

void get_kernel_version ( __u8 version)

◆ get_rootdev()

char * get_rootdev ( )

◆ log_base_2()

int log_base_2 ( uint32_t  num)

◆ open_check_fs()

static int open_check_fs ( char *  path,
int  flag 
)
static

◆ str2hashbuf()

static void str2hashbuf ( const unsigned char *  msg,
int  len,
unsigned int *  buf,
int  num 
)
static

◆ TEA_transform()

static void TEA_transform ( unsigned int  buf[4],
unsigned int const  in[] 
)
static

◆ test_and_clear_bit_le()

int test_and_clear_bit_le ( u32  nr,
u8 addr 
)

◆ test_and_set_bit_le()

int test_and_set_bit_le ( u32  nr,
u8 addr 
)

◆ test_bit_le()

int test_bit_le ( u32  nr,
const u8 addr 
)

◆ utf16_to_utf8()

int utf16_to_utf8 ( char *  output,
const char *  input,
size_t  outsize,
size_t  insize 
)

◆ utf16_to_wchar()

static uint16_t * utf16_to_wchar ( uint16_t *  input,
wchar_t *  wc,
size_t  insize 
)
static

◆ utf8_to_utf16()

int utf8_to_utf16 ( char *  output,
const char *  input,
size_t  outsize,
size_t  insize 
)

◆ utf8_to_wchar()

static const char * utf8_to_wchar ( const char *  input,
wchar_t *  wc,
size_t  insize 
)
static

◆ wchar_to_utf16()

static uint16_t * wchar_to_utf16 ( uint16_t *  output,
wchar_t  wc,
size_t  outsize 
)
static

◆ wchar_to_utf8()

static char * wchar_to_utf8 ( char *  output,
wchar_t  wc,
size_t  outsize 
)
static

◆ write_inode()

int write_inode ( struct f2fs_node inode,
u64  blkaddr,
enum rw_hint  whint 
)

Variable Documentation

◆ bits_in_byte

const int bits_in_byte[256]
static
Initial value:
= {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
}

◆ default_flags

__u16 default_flags

◆ encoding_flags

const struct enc_flags encoding_flags[]
static
Initial value:
= {
{ F2FS_ENC_STRICT_MODE_FL, "strict" },
}
#define F2FS_ENC_STRICT_MODE_FL
Definition: f2fs_fs.h:686

◆ encoding_magic

__u16 encoding_magic

◆ 

const struct { ... } f2fs_encoding_map[]
Initial value:
= {
{
.encoding_magic = F2FS_ENC_UTF8_12_1,
.name = "utf8",
.default_flags = 0,
},
}
#define F2FS_ENC_UTF8_12_1
Definition: f2fs_fs.h:685

◆ name

char* name