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

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 void MOS_CONCAT (__slab_autoinit_, __COUNTER__)
 
 MOS_INIT (SLAB_AUTOINIT, MOS_CONCAT(__slab_autoinit_, __COUNTER__))
 
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 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)
 
static phyframe_tcpio_fill_cache (inode_cache_t *cache, off_t pgoff)
 
static FILESYSTEM_DEFINE (fs_cpiofs, "cpiofs", cpio_mount, NULL)
 
 FILESYSTEM_AUTOREGISTER (fs_cpiofs)
 

Variables

static filesystem_t fs_cpiofs
 
static const inode_ops_t cpio_dir_inode_ops
 
static const inode_ops_t cpio_file_inode_ops
 
static const file_ops_t cpio_file_ops
 
static const inode_cache_ops_t cpio_icache_ops
 
static const superblock_ops_t cpio_sb_ops
 
static const file_ops_t cpio_noop_file_ops = { 0 }
 
static slab_tcpio_inode_cache = NULL
 

Macro Definition Documentation

◆ CPIO_MODE_FILE_TYPE

#define CPIO_MODE_FILE_TYPE   0170000

Definition at line 22 of file cpio.c.

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.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_SYMLINK

#define CPIO_MODE_SYMLINK   0120000

Definition at line 24 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_FILE

#define CPIO_MODE_FILE   0100000

Definition at line 25 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_BLOCKDEV

#define CPIO_MODE_BLOCKDEV   0060000

Definition at line 26 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_DIR

#define CPIO_MODE_DIR   0040000

Definition at line 27 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_CHARDEV

#define CPIO_MODE_CHARDEV   0020000

Definition at line 28 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_FIFO

#define CPIO_MODE_FIFO   0010000

Definition at line 29 of file cpio.c.

Referenced by cpio_modebits_to_filetype().

◆ CPIO_MODE_SUID

#define CPIO_MODE_SUID   0004000

Definition at line 30 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ CPIO_MODE_SGID

#define CPIO_MODE_SGID   0002000

Definition at line 31 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ CPIO_MODE_STICKY

#define CPIO_MODE_STICKY   0001000

Definition at line 32 of file cpio.c.

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"  )

◆ MOS_CONCAT()

static void MOS_CONCAT ( __slab_autoinit_ ,
__COUNTER__  )
static

Definition at line 75 of file cpio.c.

◆ MOS_INIT()

MOS_INIT ( SLAB_AUTOINIT ,
MOS_CONCAT(__slab_autoinit_, __COUNTER__)  )

◆ initrd_read()

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

Definition at line 77 of file cpio.c.

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()

static file_type_t cpio_modebits_to_filetype ( u32 modebits)
static

Definition at line 85 of file cpio.c.

Referenced by cpio_i_iterate_dir(), and cpio_inode_trycreate().

◆ cpio_read_metadata()

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 )
static

Definition at line 103 of file cpio.c.

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 161 of file cpio.c.

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

◆ cpio_inode_trycreate()

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

Definition at line 168 of file cpio.c.

Referenced by cpio_i_lookup(), and cpio_mount().

+ Here is the call graph for this function:

◆ cpio_mount()

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

Definition at line 210 of file cpio.c.

+ Here is the call graph for this function:

◆ cpio_i_lookup()

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

Definition at line 238 of file cpio.c.

+ Here is the call graph for this function:

◆ cpio_i_iterate_dir()

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

Definition at line 253 of file cpio.c.

+ Here is the call graph for this function:

◆ cpio_i_readlink()

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

Definition at line 326 of file cpio.c.

+ Here is the call graph for this function:

◆ cpio_sb_drop_inode()

static bool cpio_sb_drop_inode ( inode_t * inode)
static

Definition at line 332 of file cpio.c.

+ Here is the call graph for this function:

◆ cpio_fill_cache()

static phyframe_t * cpio_fill_cache ( inode_cache_t * cache,
off_t pgoff )
static

Definition at line 355 of file cpio.c.

+ Here is the call graph for this function:

◆ FILESYSTEM_DEFINE()

static FILESYSTEM_DEFINE ( fs_cpiofs ,
"cpiofs" ,
cpio_mount ,
NULL  )
static

◆ FILESYSTEM_AUTOREGISTER()

FILESYSTEM_AUTOREGISTER ( fs_cpiofs )

Variable Documentation

◆ fs_cpiofs

filesystem_t fs_cpiofs
static

Definition at line 56 of file cpio.c.

Referenced by cpio_mount().

◆ cpio_dir_inode_ops

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

Definition at line 67 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ cpio_file_inode_ops

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

Definition at line 68 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ cpio_file_ops

static const file_ops_t cpio_file_ops
static
Initial value:
= {
}
ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.c:95

Definition at line 69 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ cpio_icache_ops

static const inode_cache_ops_t cpio_icache_ops
static
Initial value:
= {
.fill_cache = cpio_fill_cache,
}
static phyframe_t * cpio_fill_cache(inode_cache_t *cache, off_t pgoff)
Definition cpio.c:355

Definition at line 70 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ cpio_sb_ops

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

Definition at line 71 of file cpio.c.

Referenced by cpio_mount().

◆ cpio_noop_file_ops

const file_ops_t cpio_noop_file_ops = { 0 }
static

Definition at line 72 of file cpio.c.

Referenced by cpio_inode_trycreate().

◆ cpio_inode_cache

slab_t* cpio_inode_cache = NULL
static

Definition at line 74 of file cpio.c.

Referenced by cpio_inode_trycreate().