MOS Source Code
Loading...
Searching...
No Matches
cpio.cpp File Reference
Include dependency graph for cpio.cpp:

Go to the source code of this file.

Classes

struct  cpio_newc_header_t
struct  cpio_inode_t

Macros

#define CPIO_MODE_FILE_TYPE   0170000
#define CPIO_MODE_SOCKET   0140000
#define CPIO_MODE_SYMLINK   0120000
#define CPIO_MODE_FILE   0100000
#define CPIO_MODE_BLOCKDEV   0060000
#define CPIO_MODE_DIR   0040000
#define CPIO_MODE_CHARDEV   0020000
#define CPIO_MODE_FIFO   0010000
#define CPIO_MODE_SUID   0004000
#define CPIO_MODE_SGID   0002000
#define CPIO_MODE_STICKY   0001000

Functions

 MOS_STATIC_ASSERT (sizeof(cpio_newc_header_t)==110, "cpio_newc_header has wrong size")
static size_t initrd_read (void *buf, size_t size, size_t offset)
static file_type_t cpio_modebits_to_filetype (u32 modebits)
static bool cpio_read_metadata (const char *target, cpio_newc_header_t *header, size_t *header_offset, size_t *name_offset, size_t *name_length, size_t *data_offset, size_t *data_length)
should_inline cpio_inode_tCPIO_INODE (inode_t *inode)
static cpio_inode_tcpio_inode_trycreate (const char *path, superblock_t *sb)
static PtrResult< dentry_tcpio_mount (filesystem_t *fs, const char *dev_name, const char *mount_options)
static bool cpio_i_lookup (inode_t *parent_dir, dentry_t *dentry)
static void cpio_i_iterate_dir (dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
static size_t cpio_i_readlink (dentry_t *dentry, char *buffer, size_t buflen)
static bool cpio_sb_drop_inode (inode_t *inode)
PtrResult< phyframe_tcpio_fill_cache (inode_cache_t *cache, uint64_t pgoff)
static FILESYSTEM_DEFINE (fs_cpiofs, "cpiofs", cpio_mount, NULL)
 FILESYSTEM_AUTOREGISTER (fs_cpiofs)

Variables

const inode_ops_t cpio_dir_inode_ops
const inode_ops_t cpio_file_inode_ops
const file_ops_t cpio_file_ops
const inode_cache_ops_t cpio_icache_ops
const superblock_ops_t cpio_sb_ops
const file_ops_t cpio_noop_file_ops = { 0 }

Macro Definition Documentation

◆ CPIO_MODE_FILE_TYPE

#define CPIO_MODE_FILE_TYPE   0170000

Definition at line 22 of file cpio.cpp.

Referenced by cpio_i_iterate_dir(), cpio_inode_trycreate(), and cpio_modebits_to_filetype().

◆ CPIO_MODE_SOCKET

#define CPIO_MODE_SOCKET   0140000

Definition at line 23 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_SYMLINK

#define CPIO_MODE_SYMLINK   0120000

Definition at line 24 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_FILE

#define CPIO_MODE_FILE   0100000

Definition at line 25 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_BLOCKDEV

#define CPIO_MODE_BLOCKDEV   0060000

Definition at line 26 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_DIR

#define CPIO_MODE_DIR   0040000

Definition at line 27 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_CHARDEV

#define CPIO_MODE_CHARDEV   0020000

Definition at line 28 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_FIFO

#define CPIO_MODE_FIFO   0010000

Definition at line 29 of file cpio.cpp.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_SUID

#define CPIO_MODE_SUID   0004000

Definition at line 30 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ CPIO_MODE_SGID

#define CPIO_MODE_SGID   0002000

Definition at line 31 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ CPIO_MODE_STICKY

#define CPIO_MODE_STICKY   0001000

Definition at line 32 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

Function Documentation

◆ MOS_STATIC_ASSERT()

MOS_STATIC_ASSERT ( sizeof(cpio_newc_header_t) = =110,
"cpio_newc_header has wrong size"  )

◆ initrd_read()

size_t initrd_read ( void * buf,
size_t size,
size_t offset )
static

Definition at line 72 of file cpio.cpp.

Referenced by cpio_fill_cache(), cpio_i_iterate_dir(), cpio_i_readlink(), and cpio_read_metadata().

Here is the call graph for this function:

◆ cpio_modebits_to_filetype()

file_type_t cpio_modebits_to_filetype ( u32 modebits)
static

Definition at line 80 of file cpio.cpp.

Referenced by cpio_i_iterate_dir(), and cpio_inode_trycreate().

◆ cpio_read_metadata()

bool cpio_read_metadata ( const char * target,
cpio_newc_header_t * header,
size_t * header_offset,
size_t * name_offset,
size_t * name_length,
size_t * data_offset,
size_t * data_length )
static

Definition at line 98 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

Here is the call graph for this function:

◆ CPIO_INODE()

should_inline cpio_inode_t * CPIO_INODE ( inode_t * inode)

Definition at line 156 of file cpio.cpp.

Referenced by cpio_fill_cache(), cpio_i_iterate_dir(), cpio_i_readlink(), and cpio_sb_drop_inode().

◆ cpio_inode_trycreate()

cpio_inode_t * cpio_inode_trycreate ( const char * path,
superblock_t * sb )
static

Definition at line 163 of file cpio.cpp.

Referenced by cpio_i_lookup(), and cpio_mount().

Here is the call graph for this function:

◆ cpio_mount()

PtrResult< dentry_t > cpio_mount ( filesystem_t * fs,
const char * dev_name,
const char * mount_options )
static

Definition at line 205 of file cpio.cpp.

Referenced by FILESYSTEM_DEFINE().

Here is the call graph for this function:

◆ cpio_i_lookup()

bool cpio_i_lookup ( inode_t * parent_dir,
dentry_t * dentry )
static

Definition at line 231 of file cpio.cpp.

Here is the call graph for this function:

◆ cpio_i_iterate_dir()

void cpio_i_iterate_dir ( dentry_t * dentry,
vfs_listdir_state_t * state,
dentry_iterator_op add_record )
static

Definition at line 245 of file cpio.cpp.

Here is the call graph for this function:

◆ cpio_i_readlink()

size_t cpio_i_readlink ( dentry_t * dentry,
char * buffer,
size_t buflen )
static

Definition at line 318 of file cpio.cpp.

Here is the call graph for this function:

◆ cpio_sb_drop_inode()

bool cpio_sb_drop_inode ( inode_t * inode)
static

Definition at line 324 of file cpio.cpp.

Here is the call graph for this function:

◆ cpio_fill_cache()

PtrResult< phyframe_t > cpio_fill_cache ( inode_cache_t * cache,
uint64_t pgoff )

Definition at line 347 of file cpio.cpp.

Here is the call graph for this function:

◆ FILESYSTEM_DEFINE()

FILESYSTEM_DEFINE ( fs_cpiofs ,
"cpiofs" ,
cpio_mount ,
NULL  )
static
Here is the call graph for this function:

◆ FILESYSTEM_AUTOREGISTER()

FILESYSTEM_AUTOREGISTER ( fs_cpiofs )

Variable Documentation

◆ cpio_dir_inode_ops

const inode_ops_t cpio_dir_inode_ops
Initial value:
= {
.iterate_dir = cpio_i_iterate_dir,
.lookup = cpio_i_lookup,
}
static void cpio_i_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition cpio.cpp:245
static bool cpio_i_lookup(inode_t *parent_dir, dentry_t *dentry)
Definition cpio.cpp:231

Definition at line 334 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ cpio_file_inode_ops

const inode_ops_t cpio_file_inode_ops
Initial value:
= {
.readlink = cpio_i_readlink,
}
static size_t cpio_i_readlink(dentry_t *dentry, char *buffer, size_t buflen)
Definition cpio.cpp:318

Definition at line 339 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ cpio_file_ops

const file_ops_t cpio_file_ops
Initial value:
= {
}
ssize_t vfs_generic_read(const FsBaseFile *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.cpp:93

Definition at line 343 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ cpio_icache_ops

const inode_cache_ops_t cpio_icache_ops
Initial value:
= {
.fill_cache = cpio_fill_cache,
}
PtrResult< phyframe_t > cpio_fill_cache(inode_cache_t *cache, uint64_t pgoff)
Definition cpio.cpp:347

Definition at line 367 of file cpio.cpp.

Referenced by cpio_inode_trycreate().

◆ cpio_sb_ops

const superblock_ops_t cpio_sb_ops
Initial value:
= {
.drop_inode = cpio_sb_drop_inode,
}
static bool cpio_sb_drop_inode(inode_t *inode)
Definition cpio.cpp:324

Definition at line 330 of file cpio.cpp.

Referenced by cpio_mount().

◆ cpio_noop_file_ops

const file_ops_t cpio_noop_file_ops = { 0 }
extern

Referenced by cpio_inode_trycreate().