============
-
128 주차 진도를 복습하였습니다.
-
vfs_caches_init()
- start_kernel 1 ~/kernel/iamroot/linux-stable/init/main.c
- vfs_caches_init 925 ~/kernel/iamroot/linux-stable/init/main.c
- mnt_init 3807 ~/kernel/iamroot/linux-stable/fs/dcache.c
- sysfs_init 3496 err = sysfs_init();
- kern_mount 824 ~/kernel/iamroot/linux-stable/fs/sysfs/mount.c
- kern_mount_data 1962 ~/kernel/iamroot/linux-stable/include/linux/fs.h
- vfs_kern_mount 3949 mnt = vfs_kern_mount(type, MS_KERNMOUNT, type->name, data);
-
128주차 함수 호출 구조
-
call: start_kernel()->vfs_caches_init()
-
vfs_caches_init()
- min()
- kmem_cache_create() : names_caches
- dcache_init()
- inode_init()
- files_init(): mempages
- mnt_init()
- kmem_cache_create(): mnt_cache
- alloc_large_system_hash() : Mount_cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
-
sysfs_init()
- kmem_cache_create(): sysfs_dir_cache
- sysfs_inode_init()
- register_filesystem(): sysfs_fs_type
- kern_mount() : kern_mount_data()
- vfs_kern_mount()
-
vfs_kern_mount()
- alloc_vfsmnt(): sysfs
- kmem_cache_zalloc()
- mnt_alloc_id()
- alloc_percpu()
- INIT_HLIST_NODE(): mnt_hash
- INIT_LIST_HEAD(): mnt_child
- INIT_LIST_HEAD(): mnt_mounts
- INIT_LIST_HEAD(): mnt_list
- INIT_LIST_HEAD(): mnt_expire
- INIT_LIST_HEAD(): mnt_share
- INIT_LIST_HEAD(): mnt_slave_list
- INIT_LIST_HEAD(): mnt_slave
- INIT_LIST_HEAD(): mnt_fsnotify_marks
- mount_fs(): sysfs
- alloc_vfsmnt(): sysfs
-
mount_fs(): sysfs_mount()
- kzalloc(): sysfs_super_info
- sget()
- spin_lock(): sb_lock
- hlist_for_eash_entry()
- spin_unlock()
- alloc_super()
- kzalloc(): super_block
- security_sb_alloc()
- percpu_counter_init()
- lockdep_init_map()
- init_waitqueue_head(): s_writers.wait
- init_waitqueue_head: s_writers.wait_unfrozen
- INIT_HLIST_NODE(): s_instances
- INIT_HLIST_BL_HEAD(): s_anon
- INIT_LIST_HEAD: s_inodes
- list_lru_init(): s_dentry_lru
- list_lru_init(): s_inode_lru
- INIT_LIST_HEAD: s_mounts
- init_rwsem(): s_umount
- lockdep_set_class(): s_umount
- down_write_nested(): s_umount
- atomic_set(): s_active
- mutext_init(): s_vfs_rename_mutex
- lockdep_set_class(): s_vfs_rename_key
- mutex_init(): s_dquot.dpio_mutex
- mutext_init(): s_dquot.dqonoff_mutex
- init_rwsem(): s_dquot.dqptr_sem
- set()
- strlcpy(): s_id, sysfs
- list_add_tail(): s_list
- hlist_add_head(): s_instances
- spin_unlock(): sb_lock
- get_filesystem(type)
- register_shrinker()
- IS_ERR(): sb
- sysfs_fill_super()
- mutex_lock(): sysfs_mutex
- sysfs_get_inode(): super_block
- iget_locked(): super_block
- spin_lock(): inode_hash_lock
- find_inode_fast()
- spin_unlock: inode_hash_lock
- alloc_inode()
- kmem_cache_alloc(): inode
- inode_init_always(): inode
- atomic_set(): i_count
- i_uid_write()
- i_gid_write()
- atomic_set: i_writecount
- security_inode_alloc(): inode
- spin_lock_init(): i_lock
- spinlock_check()
- raw_spin_lock_init()
- lockdep_set_class(): s_type->i_lock_key
- mutex_init(): i_mutex
- lockdep_set_class(): s_type->i_mutex
- atomic_set(): i_dio_count
- mapping_set_gfp_mask(): inode
- INIT_HLIST_HEAD(): inode->i_dentry
- this_cpu_inc()
- spin_lock(): inode_hash_lock
- fine_inode_fast()
- spin_lock(): inode->i_lock
- hlist_add_head(): inode->i_hash
- spin_unlock(): inode->i_lock
- sysfs_init_inode(): sysfs_root
- iget_locked(): super_block
- mutex_unlock()
- d_make_root()
- __d_alloc(): super_block
- kmem_cache_alloc(): dentry
- memcpy(): d_iname: name->name, (&name)->name: "/", (&name)->len
- swp_wmb()
- spin_lock_init(): dentry_d_lock
- seqcount_init(): d_seq
- INIT_HLIST_BL_NODE(): dentry->d_fsdata
- INIT_LIST_HEAD(): dentry->d_lru
- INIT_LIST_HEAD(): dentry->d_subdirs
- INIT_HLIST_NODE(): dentry->d_alias
- INIT_LIST_HEAD(): dentry->d_u.d_child
- d_set_d_op(): dentry->d_sb->s_d_op
- this_cpu_inc()
- d_instantiate(): dentry
- BUG_ON: hlist_unhased(): entry->d_alias
- sping_lock(): inode->i_lock
- __d_instantiate()
- spin_lock(): dentry->d_lock
- hlist_add_head(): dentry->d_alias
- dentry_rcuwalk_barrier(): dentry
- assert_spin_locked(): assert_raw_spin_locked() : BUG_ON(!raw_spin_is_locked(x))
- write_seqcount_barrier()
- swp_wmb()
- spin_unlock(): dentry->d_lock
- fsnotify_d_instantiate()
- spin_unlock()
- __d_alloc(): super_block
- mutext_lock(): sysfs_mutex
- sysfs_get_inode(): sfsfs_get_inode
- iget_locked(): super_block
- spin_lock(): inode_hash_lock
- find_inode_fast(): super_block
- spin_unlock(): inode_hash_lock
- alloc_inode()
- kmem_cache_alloc(): inode
- inode_init_always(): inode
- atomic_set(): i_count
- i_uid_write()
- i_gid_write()
- atomic_set: i_writecount
- security_inode_alloc(): inode
- spin_lock_init(): i_lock
- spinlock_check()
- raw_spin_lock_init()
- lockdep_set_class(): s_type->i_lock_key
- mutex_init(): i_mutex
- lockdep_set_class(): s_type->i_mutex
- atomic_set(): i_dio_count
- mapping_set_gfp_mask(): inode
- INIT_HLIST_HEAD(): inode->i_dentry
- this_cpu_inc()
- spin_lock(): inode_hash_lock
- find_inode_fast()
- spin_lock(): i_lock
- hlist_add_head(): i_hash
- spin_unlock(): i_lock
- inode_sb_list_add(): inode
- spin_unlock(): inode_hash_lock
- alloc_inode()
- sysfs_init_inode(): sysfs_root
- sysfs_get(): sysfs_root
- set_default_inode_attr()
- sysfs_refresh_inode(): sysfs_root
- sysfs_type(): sysfs_root
- unlock_new_inode(): inode
- iget_locked(): super_block
- dget(): s_root
- lockref_get(): dentry->d_lockref
-
vfs_kern_mount()
- alloc_vfsmnt(): sysfs
- kmem_cache_zalloc()
- mnt_alloc_id()
- alloc_percpu()
- INIT_HLIST_NODE(): mnt_hash
- INIT_LIST_HEAD(): mnt_child
- INIT_LIST_HEAD(): mnt_mounts
- INIT_LIST_HEAD(): mnt_list
- INIT_LIST_HEAD(): mnt_expire
- INIT_LIST_HEAD(): mnt_share
- INIT_LIST_HEAD(): mnt_slave_list
- INIT_LIST_HEAD(): mnt_slave
- INIT_LIST_HEAD(): mnt_fsnotify_marks
- mount_fs(): sysfs
- IS_ERR(): root
- BUG_ON(): super_block
- WARN_ON(): super_block->s_bdi
- WARN_ON(): super_block->s_bdi == default_backing_dev_info
- security_sb_kern_mount()
- WARN(): super_block->s_maxbytes
- up_write(): super_block->s_umount
- free_secdata()
- alloc_vfsmnt(): sysfs
- call: start_kernel()->vfs_caches_init()
asmlinkage void __init start_kernel(void)
{
char * command_line;
extern const struct kernel_param __start___param[], __stop___param[];
// ATAG,DTB 정보로 사용
...
proc_caches_init();
// sighand_struct, signal_struct, files_struct, fs_struct, mm_struct, vm_area_struct, nsproxy
// 를 사용하기 위한 kmem_cache 할당자 및 percpu list 초기화 수행
buffer_init();
// buffer_head 를 사용하기 위한 kmem_cache 할당자 및 max_buffer_heads 값 초기화 수행
key_init(); // null funtion
security_init(); // null funtion
dbg_late_init(); // null funtion
// totalram_pages: 총 free된 page 수
vfs_caches_init(totalram_pages);
- call: start_kernel()
- vfs_caches_init()
// ARM10C 20151003
// totalram_pages: 총 free된 page 수
void __init vfs_caches_init(unsigned long mempages)
{
unsigned long reserve;
// mempages: 총 free된 page 수, nr_free_pages(): 현재의 free pages 수
reserve = min((mempages - nr_free_pages()) * 3/2, mempages - 1);
// reserve: XXX
// mempages: 총 free된 page 수, reserve: XXX
mempages -= reserve;
// mempages: 총 free된 page 수 - XXX
// PATH_MAX: 4096
// SLAB_HWCACHE_ALIGN: 0x00002000UL, SLAB_PANIC: 0x00040000UL
// kmem_cache_create("names_cache", 4096, 0, 0x42000, NULL): kmem_cache#6
names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
// names_cachep: kmem_cache#6
dcache_init();
inode_init();
// mempages: 총 free된 page 수 - XXX
files_init(mempages);
mnt_init();
- call: start_kernel()->vfs_caches_init()
- mnt_init()
// ARM10C 20151024
void __init mnt_init(void)
{
unsigned u;
int err;
// sizeof(struct mount): 152 bytes, SLAB_HWCACHE_ALIGN: 0x00002000UL, SLAB_PANIC: 0x00040000UL
// kmem_cache_create("mnt_cache", 152, 0, 0x42000, NULL): kmem_cache#2
mnt_cache = kmem_cache_create("mnt_cache", sizeof(struct mount),
0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
// mnt_cache: kmem_cache#2
// sizeof(struct hlist_head): 4 bytes, mhash_entries: 0
// alloc_large_system_hash("Mount-cache", 4, 0, 19, 0, &m_hash_shift, &m_hash_mask, 0, 0): 16kB만큼 할당받은 메모리 주소
mount_hashtable = alloc_large_system_hash("Mount-cache",
sizeof(struct hlist_head),
mhash_entries, 19,
0,
&m_hash_shift, &m_hash_mask, 0, 0);
// mount_hashtable: 16kB만큼 할당받은 메모리 주소
// sizeof(struct hlist_head): 4 bytes, mphash_entries: 0
// alloc_large_system_hash("Mountpoint-cache", 4, 0, 19, 0, &m_hash_shift, &m_hash_mask, 0, 0): 16kB만큼 할당받은 메모리 주소
mountpoint_hashtable = alloc_large_system_hash("Mountpoint-cache",
sizeof(struct hlist_head),
mphash_entries, 19,
0,
&mp_hash_shift, &mp_hash_mask, 0, 0);
// mountpoint_hashtable: 16kB만큼 할당받은 메모리 주소
// mount_hashtable: 16kB만큼 할당받은 메모리 주소, mountpoint_hashtable: 16kB만큼 할당받은 메모리 주소
if (!mount_hashtable || !mountpoint_hashtable)
panic("Failed to allocate mount hash table\n");
// m_hash_mask: 0xFFF
for (u = 0; u <= m_hash_mask; u++)
// u: 0
INIT_HLIST_HEAD(&mount_hashtable[u]);
// INIT_HLIST_HEAD 에서 한일:
// ((&mount_hashtable[0])->first = NULL)
// u: 1...4095 까지 loop 수행
// mp_hash_mask: 0xFFF
for (u = 0; u <= mp_hash_mask; u++)
// u: 0
INIT_HLIST_HEAD(&mountpoint_hashtable[u]);
// INIT_HLIST_HEAD 에서 한일:
// ((&mountpoint_hashtable[0])->first = NULL)
// u: 1...4095 까지 loop 수행
// sysfs_init(): 0
err = sysfs_init();
// err: 0
// err: 0
if (err)
printk(KERN_WARNING "%s: sysfs_init error: %d\n",
__func__, err);
fs_kobj = kobject_create_and_add("fs", NULL);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
// ARM10C 20160109
// "fs", NULL
struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
{
struct kobject *kobj;
int retval;
// kobject_create(): kmem_cache#30-oX (struct kobject)
kobj = kobject_create();
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
// ARM10C 20160109
struct kobject *kobject_create(void)
{
struct kobject *kobj;
// sizeof(struct kobject): 36 bytes, GFP_KERNEL: 0xD0
// kzalloc(36, GFP_KERNEL: 0xD0): kmem_cache#30-oX (struct kobject)
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
// kobj: kmem_cache#30-oX (struct kobject)
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return NULL;
// kobj: kmem_cache#30-oX (struct kobject)
kobject_init(kobj, &dynamic_kobj_ktype);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
// ARM10C 20160109
struct kobject *kobject_create(void)
{
struct kobject *kobj;
// sizeof(struct kobject): 36 bytes, GFP_KERNEL: 0xD0
// kzalloc(36, GFP_KERNEL: 0xD0): kmem_cache#30-oX (struct kobject)
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
// kobj: kmem_cache#30-oX (struct kobject)
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return NULL;
// kobj: kmem_cache#30-oX (struct kobject)
kobject_init(kobj, &dynamic_kobj_ktype);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), &dynamic_kobj_ktype
void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
{
char *err_str;
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj) {
err_str = "invalid kobject pointer!";
goto error;
}
// ktype: &dynamic_kobj_ktype
if (!ktype) {
err_str = "must have a ktype to be initialized properly!\n";
goto error;
}
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 0
if (kobj->state_initialized) {
/* do not error out as sometimes we can recover */
printk(KERN_ERR "kobject (%p): tried to init an initialized "
"object, something is seriously wrong.\n", kobj);
dump_stack();
}
// kobj: kmem_cache#30-oX (struct kobject)
kobject_init_internal(kobj);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject)
static void kobject_init_internal(struct kobject *kobj)
{
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return;
// &kobj->kref: &(kmem_cache#30-oX (struct kobject))->kref
kref_init(&kobj->kref);
- kref_init()
// ARM10C 20160109
// &kobj->kref: &(kmem_cache#30-oX (struct kobject))->kref
static inline void kref_init(struct kref *kref)
{
atomic_set(&kref->refcount, 1);
}
- kref_init에서 한일:
- (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1
- INIT_LIST_HEAD에서 한일:
- (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry
- (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject)
static void kobject_init_internal(struct kobject *kobj)
{
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return;
// &kobj->kref: &(kmem_cache#30-oX (struct kobject))->kref
kref_init(&kobj->kref);
// kref_init에서 한일:
// (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1
// &kobj->entry: &(kmem_cache#30-oX (struct kobject))->entry
INIT_LIST_HEAD(&kobj->entry);
// INIT_LIST_HEAD에서 한일:
// (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry
// (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
// kobj->state_in_sysfs: (kmem_cache#30-oX (struct kobject))->state_in_sysfs
kobj->state_in_sysfs = 0;
// kobj->state_in_sysfs: (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0
// kobj->state_add_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent
kobj->state_add_uevent_sent = 0;
// kobj->state_add_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0
// kobj->state_remove_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent
kobj->state_remove_uevent_sent = 0;
// kobj->state_remove_uevent_sent: (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized
kobj->state_initialized = 1;
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 1
}
- kobject_init_internal에서 한일:
- (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1
- (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry
- (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
- (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0
- (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_initialized: 1
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), &dynamic_kobj_ktype
void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
{
char *err_str;
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj) {
err_str = "invalid kobject pointer!";
goto error;
}
// ktype: &dynamic_kobj_ktype
if (!ktype) {
err_str = "must have a ktype to be initialized properly!\n";
goto error;
}
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 0
if (kobj->state_initialized) {
/* do not error out as sometimes we can recover */
printk(KERN_ERR "kobject (%p): tried to init an initialized "
"object, something is seriously wrong.\n", kobj);
dump_stack();
}
// kobj: kmem_cache#30-oX (struct kobject)
kobject_init_internal(kobj);
// kobj->ktype: (kmem_cache#30-oX (struct kobject))->ktype, ktype: &dynamic_kobj_ktype
kobj->ktype = ktype;
// kobj->ktype: (kmem_cache#30-oX (struct kobject))->ktype: &dynamic_kobj_ktype
return;
// return
error:
printk(KERN_ERR "kobject (%p): %s\n", kobj, err_str);
dump_stack();
}
EXPORT_SYMBOL(kobject_init);
- kobject_init에서 한일:
- (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1
- (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry
- (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
- (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0
- (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_initialized: 1
- (kmem_cache#30-oX (struct kobject))->ktype: &dynamic_kobj_ktype
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_create()
// ARM10C 20160109
struct kobject *kobject_create(void)
{
struct kobject *kobj;
// sizeof(struct kobject): 36 bytes, GFP_KERNEL: 0xD0
// kzalloc(36, GFP_KERNEL: 0xD0): kmem_cache#30-oX (struct kobject)
kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
// kobj: kmem_cache#30-oX (struct kobject)
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return NULL;
// kobj: kmem_cache#30-oX (struct kobject)
kobject_init(kobj, &dynamic_kobj_ktype);
// kobj: kmem_cache#30-oX (struct kobject)
return kobj;
// return kmem_cache#30-oX (struct kobject)
}
-
return kmem_cache#30-oX (struct kobject)
-
kobject_create에서 한일:
- struct kobject의 메모리를 할당받음 kmem_cache#30-oX (struct kobject)
- (&(kmem_cache#30-oX (struct kobject))->kref)->refcount: 1
- (&(kmem_cache#30-oX (struct kobject))->entry)->next: &(kmem_cache#30-oX (struct kobject))->entry
- (&(kmem_cache#30-oX (struct kobject))->entry)->prev: &(kmem_cache#30-oX (struct kobject))->entry
- (kmem_cache#30-oX (struct kobject))->state_in_sysfs: 0
- (kmem_cache#30-oX (struct kobject))->state_add_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_remove_uevent_sent: 0
- (kmem_cache#30-oX (struct kobject))->state_initialized: 1
- (kmem_cache#30-oX (struct kobject))->ktype: &dynamic_kobj_ktype
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_create()
// ARM10C 20160109
// "fs", NULL
struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
{
struct kobject *kobj;
int retval;
// kobject_create(): kmem_cache#30-oX (struct kobject)
kobj = kobject_create();
// kobj: kmem_cache#30-oX (struct kobject)
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return NULL;
// kobj: kmem_cache#30-oX (struct kobject), parent: NULL, name: "fs"
retval = kobject_add(kobj, parent, "%s", name);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), parent: NULL, "%s", name: "fs"
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...)
{
va_list args;
int retval;
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return -EINVAL;
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 1
if (!kobj->state_initialized) {
printk(KERN_ERR "kobject '%s' (%p): tried to add an "
"uninitialized object, something is seriously wrong.\n",
kobject_name(kobj), kobj);
dump_stack();
return -EINVAL;
}
// fmt: "%s"
va_start(args, fmt);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_create()
// ARM10C 20160109
// _AUPBND: 3
// _bnd("%s",3): 4
//
// #define va_start(args, "%s"):
// (void) ((args) = (((char *) &("%s")) + 4))
#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,_AUPBND))))
// ARM10C 20160109
// #define _bnd("%s", 3):
// (((sizeof ("%s")) + (3)) & (~(3)))
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
// ARM10C 20160109
#define va_end(ap) (ap = (va_list) NULL)
- va_start에서 한일:
- (args): (((char *) &("%s")) + 4): "fs"
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), parent: NULL, "%s", name: "fs"
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...)
{
va_list args;
int retval;
// kobj: kmem_cache#30-oX (struct kobject)
if (!kobj)
return -EINVAL;
// kobj->state_initialized: (kmem_cache#30-oX (struct kobject))->state_initialized: 1
if (!kobj->state_initialized) {
printk(KERN_ERR "kobject '%s' (%p): tried to add an "
"uninitialized object, something is seriously wrong.\n",
kobject_name(kobj), kobj);
dump_stack();
return -EINVAL;
}
// fmt: "%s"
va_start(args, fmt);
// va_start에서 한일:
// (args): (((char *) &("%s")) + 4): "fs"
// kobj: kmem_cache#30-oX (struct kobject), parent: NULL, fmt: "%s", args: "fs"
retval = kobject_add_varg(kobj, parent, fmt, args);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_varg() : kobj, fs
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), parent: NULL, fmt: "%s", args: "fs"
static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
const char *fmt, va_list vargs)
{
int retval;
// kobj: kmem_cache#30-oX (struct kobject), fmt: "%s", vargs: "fs"
retval = kobject_set_name_vargs(kobj, fmt, vargs);
- call: start_kernel()->vfs_caches_init()->mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_varg() : kobj, fs
- kobject_set_name_vargs()
- kobject_create()
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
const char *old_name = kobj->name;
// old_name: NULL
char *s;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL, fmt: "%s"
if (kobj->name && !fmt)
return 0;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
// kvasprintf(GFP_KERNEL: 0xD0, "%s", "fs"): kmem_cache#30-oX: "fs"
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
// ap: "fs"
va_copy(aq, ap);
- va_copy() 에서 한일
- aq: "fs"
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
// ap: "fs"
va_copy(aq, ap);
// va_copy에서 한일:
// aq: "fs"
// fmt: "%s", aq: "fs"
// vsnprintf(NULL, 0, "%s", "fs"): 2
len = vsnprintf(NULL, 0, fmt, aq);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// p: kmem_cache#30-oX, len: 2, fmt: "%s", ap: "fs"
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
unsigned long long num;
char *str, *end;
struct printf_spec spec = {0};
/* Reject out-of-range values early. Large positive sizes are
used for unknown buffer sizes. */
// size: 0
if (WARN_ON_ONCE((int) size < 0))
return 0;
// buf: NULL
str = buf;
// str: NULL
// buf: NULL
end = buf + size;
// end: NULL
/* Make sure end is always >= buf */
// end: NULL, buf: NULL
if (end < buf) {
end = ((void *)-1);
size = end - buf;
}
// *fmt: '%'
while (*fmt) {
// fmt: "%s"
const char *old_fmt = fmt;
// old_fmt: "%s"
// fmt: "%s", format_decode("%s", &spec): 2
int read = format_decode(fmt, &spec);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- format_decode()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// fmt: "%s", &spec
static noinline_for_stack
int format_decode(const char *fmt, struct printf_spec *spec)
{
// fmt: "%s"
const char *start = fmt;
// start: "%s"
/* we finished early by reading the field width */
// spec->type: (&spec)->type: 0, FORMAT_TYPE_WIDTH: 1
if (spec->type == FORMAT_TYPE_WIDTH) {
if (spec->field_width < 0) {
spec->field_width = -spec->field_width;
spec->flags |= LEFT;
}
spec->type = FORMAT_TYPE_NONE;
goto precision;
}
/* we finished early by reading the precision */
// spec->type: (&spec)->type: 0, FORMAT_TYPE_PRECISION: 2
if (spec->type == FORMAT_TYPE_PRECISION) {
if (spec->precision < 0)
spec->precision = 0;
spec->type = FORMAT_TYPE_NONE;
goto qualifier;
}
/* By default */
// spec->type: (&spec)->type: 0, FORMAT_TYPE_NONE: 0
spec->type = FORMAT_TYPE_NONE;
// spec->type: (&spec)->type: 0
// fmt: "%s"
for (; *fmt ; ++fmt) {
// *fmt: '%'
if (*fmt == '%')
break;
// break 수행
}
/* Return the current non-format string */
// fmt: "%s", start: "%s", *fmt: '%'
if (fmt != start || !*fmt)
return fmt - start;
/* Process flags */
// spec->flags: (&spec)->flags
spec->flags = 0;
// spec->flags: (&spec)->flags: 0
while (1) { /* this also skips first '%' */
bool found = true;
// found: true
// fmt: "%s"
++fmt;
// fmt: "s"
// *fmt: 's'
switch (*fmt) {
case '-': spec->flags |= LEFT; break;
case '+': spec->flags |= PLUS; break;
case ' ': spec->flags |= SPACE; break;
case '#': spec->flags |= SPECIAL; break;
case '0': spec->flags |= ZEROPAD; break;
default: found = false;
// found: false
}
// found: false
if (!found)
break;
// break 수행
}
/* get field width */
// spec->field_width: (&spec)->field_width
spec->field_width = -1;
// spec->field_width: (&spec)->field_width: -1
// *fmt: 's', isdigit('s'): 0
if (isdigit(*fmt))
spec->field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
/* it's the next argument */
spec->type = FORMAT_TYPE_WIDTH;
return ++fmt - start;
}
precision:
/* get the precision */
// spec->precision: (&spec)->precision
spec->precision = -1;
// spec->precision: (&spec)->precision: -1
// *fmt: 's'
if (*fmt == '.') {
++fmt;
if (isdigit(*fmt)) {
spec->precision = skip_atoi(&fmt);
if (spec->precision < 0)
spec->precision = 0;
} else if (*fmt == '*') {
/* it's the next argument */
spec->type = FORMAT_TYPE_PRECISION;
return ++fmt - start;
}
}
qualifier:
/* get the conversion qualifier */
// spec->qualifier: (&spec)->qualifier
spec->qualifier = -1;
// spec->qualifier: (&spec)->qualifier: -1
// *fmt: 's', _tolower('s'): 's'
if (*fmt == 'h' || _tolower(*fmt) == 'l' ||
_tolower(*fmt) == 'z' || *fmt == 't') {
spec->qualifier = *fmt++;
if (unlikely(spec->qualifier == *fmt)) {
if (spec->qualifier == 'l') {
spec->qualifier = 'L';
++fmt;
} else if (spec->qualifier == 'h') {
spec->qualifier = 'H';
++fmt;
}
}
}
/* default base */
// spec->base: (&spec)->base
spec->base = 10;
// spec->base: (&spec)->base: 10
// *fmt: 's'
switch (*fmt) {
case 'c':
spec->type = FORMAT_TYPE_CHAR;
return ++fmt - start;
case 's':
// spec->type: (&spec)->type, FORMAT_TYPE_STR: 4
spec->type = FORMAT_TYPE_STR;
// spec->type: (&spec)->type: 4
// fmt: "s", start: "%s"
return ++fmt - start;
// return 2
case 'p':
spec->type = FORMAT_TYPE_PTR;
return fmt - start;
/* skip alnum */
case 'n':
spec->type = FORMAT_TYPE_NRCHARS;
return ++fmt - start;
case '%':
spec->type = FORMAT_TYPE_PERCENT_CHAR;
return ++fmt - start;
/* integer number formats - set up the flags and "break" */
case 'o':
spec->base = 8;
break;
case 'x':
spec->flags |= SMALL;
case 'X':
spec->base = 16;
break;
case 'd':
case 'i':
spec->flags |= SIGN;
case 'u':
break;
default:
spec->type = FORMAT_TYPE_INVALID;
return fmt - start;
}
if (spec->qualifier == 'L')
spec->type = FORMAT_TYPE_LONG_LONG;
else if (spec->qualifier == 'l') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_LONG;
else
spec->type = FORMAT_TYPE_ULONG;
} else if (_tolower(spec->qualifier) == 'z') {
spec->type = FORMAT_TYPE_SIZE_T;
} else if (spec->qualifier == 't') {
spec->type = FORMAT_TYPE_PTRDIFF;
} else if (spec->qualifier == 'H') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_BYTE;
else
spec->type = FORMAT_TYPE_UBYTE;
} else if (spec->qualifier == 'h') {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_SHORT;
else
spec->type = FORMAT_TYPE_USHORT;
} else {
if (spec->flags & SIGN)
spec->type = FORMAT_TYPE_INT;
else
spec->type = FORMAT_TYPE_UINT;
}
return ++fmt - start;
}
- format_decode에서 한일:
- (&spec)->type: 0
- (&spec)->flags: 0
- (&spec)->field_width: -1
- (&spec)->precision: -1
- (&spec)->qualifier: -1
- (&spec)->base: 10
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- format_decode()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// NULL, 0, fmt: "%s", aq: "fs"
// ARM10C 20160109
// p: kmem_cache#30-oX, len: 2, fmt: "%s", ap: "fs"
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
unsigned long long num;
char *str, *end;
struct printf_spec spec = {0};
/* Reject out-of-range values early. Large positive sizes are
used for unknown buffer sizes. */
// size: 0
if (WARN_ON_ONCE((int) size < 0))
return 0;
// buf: NULL
str = buf;
// str: NULL
// buf: NULL
end = buf + size;
// end: NULL
/* Make sure end is always >= buf */
// end: NULL, buf: NULL
if (end < buf) {
end = ((void *)-1);
size = end - buf;
}
// *fmt: '%'
while (*fmt) {
// fmt: "%s"
const char *old_fmt = fmt;
// old_fmt: "%s"
// fmt: "%s", format_decode("%s", &spec): 2
int read = format_decode(fmt, &spec);
// read: 2
// fmt: "%s", read: 2
fmt += read;
// fmt: NULL
// spec.type: 0
switch (spec.type) {
case FORMAT_TYPE_NONE: { // FORMAT_TYPE_NONE: 0
// read: 2
int copy = read;
// copy: 2
// str: NULL, end: NULL
if (str < end) {
if (copy > end - str)
copy = end - str;
memcpy(str, old_fmt, copy);
}
// str: NULL, read: 2
str += read;
// str: 2
break;
// break 수행
}
case FORMAT_TYPE_WIDTH:
spec.field_width = va_arg(args, int);
break;
case FORMAT_TYPE_PRECISION:
spec.precision = va_arg(args, int);
break;
case FORMAT_TYPE_CHAR: {
char c;
if (!(spec.flags & LEFT)) {
while (--spec.field_width > 0) {
if (str < end)
*str = ' ';
++str;
}
}
c = (unsigned char) va_arg(args, int);
if (str < end)
*str = c;
++str;
while (--spec.field_width > 0) {
if (str < end)
*str = ' ';
++str;
}
break;
}
case FORMAT_TYPE_STR:
str = string(str, end, va_arg(args, char *), spec);
break;
case FORMAT_TYPE_PTR:
str = pointer(fmt+1, str, end, va_arg(args, void *),
spec);
while (isalnum(*fmt))
fmt++;
break;
case FORMAT_TYPE_PERCENT_CHAR:
if (str < end)
*str = '%';
++str;
break;
case FORMAT_TYPE_INVALID:
if (str < end)
*str = '%';
++str;
break;
case FORMAT_TYPE_NRCHARS: {
/*
* Since %n poses a greater security risk than
* utility, ignore %n and skip its argument.
*/
void *skip_arg;
WARN_ONCE(1, "Please remove ignored %%n in '%s'\n",
old_fmt);
skip_arg = va_arg(args, void *);
break;
}
default:
switch (spec.type) {
case FORMAT_TYPE_LONG_LONG:
num = va_arg(args, long long);
break;
case FORMAT_TYPE_ULONG:
num = va_arg(args, unsigned long);
break;
case FORMAT_TYPE_LONG:
num = va_arg(args, long);
break;
case FORMAT_TYPE_SIZE_T:
if (spec.flags & SIGN)
num = va_arg(args, ssize_t);
else
num = va_arg(args, size_t);
break;
case FORMAT_TYPE_PTRDIFF:
num = va_arg(args, ptrdiff_t);
break;
case FORMAT_TYPE_UBYTE:
num = (unsigned char) va_arg(args, int);
break;
case FORMAT_TYPE_BYTE:
num = (signed char) va_arg(args, int);
break;
case FORMAT_TYPE_USHORT:
num = (unsigned short) va_arg(args, int);
break;
case FORMAT_TYPE_SHORT:
num = (short) va_arg(args, int);
break;
case FORMAT_TYPE_INT:
num = (int) va_arg(args, int);
break;
default:
num = va_arg(args, unsigned int);
}
str = number(str, end, num, spec);
}
}
// size: 0
if (size > 0) {
if (str < end)
*str = '\0';
else
end[-1] = '\0';
}
/* the trailing null byte doesn't count towards the total */
// str: 2, buf: NULL
return str-buf;
// return 2
}
EXPORT_SYMBOL(vsnprintf);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- format_decode()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
// ap: "fs"
va_copy(aq, ap);
// va_copy에서 한일:
// aq: "fs"
// fmt: "%s", aq: "fs"
// vsnprintf(NULL, 0, "%s", "fs"): 2
len = vsnprintf(NULL, 0, fmt, aq);
// len: 11 "kmalloc-192"의 길이
// len: 2
// aq: "fs"
va_end(aq);
- va_end(aq);
#define va_end(ap) (ap = (va_list) NULL)
- va_end에서 한일:
- aq: NULL
// ARM10C 20160109
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
// ap: "fs"
va_copy(aq, ap);
// va_copy에서 한일:
// aq: "fs"
// fmt: "%s", aq: "fs"
// vsnprintf(NULL, 0, "%s", "fs"): 2
len = vsnprintf(NULL, 0, fmt, aq);
// len: 11 "kmalloc-192"의 길이
// len: 2
// aq: "fs"
va_end(aq);
// va_end에서 한일:
// aq: NULL
// len: 11, gfp: GFP_NOWAIT: 0
// kmalloc_track_caller(12, GFP_NOWAIT: 0): kmem_cache#30-o0
// len: 2, GFP_KERNEL: 0xD0
p = kmalloc_track_caller(len+1, gfp);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- va_copy()
- vsnprintf()
- format_decode()
- va_end()
- kmalloc_track_caller()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// len: 3, GFP_KERNEL: 0xD0
#define kmalloc_track_caller(size, flags) \
__kmalloc_track_caller(size, flags, _RET_IP_)
// ARM10C 20160109
// len: 3, GFP_KERNEL: 0xD0, _RET_IP_
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
{
struct kmem_cache *s;
void *ret;
// size: 16, KMALLOC_MAX_CACHE_SIZE: 0x2000
if (unlikely(size > KMALLOC_MAX_CACHE_SIZE))
return kmalloc_large(size, gfpflags);
// size: 16, gfpflags: GFP_KERNEL: 0xD0
// kmalloc_slab(16, 0xD0): kmem_cache#30
s = kmalloc_slab(size, gfpflags);
// s: kmem_cache#30
// s: kmem_cache#30, ZERO_OR_NULL_PTR(kmem_cache#30): 0
if (unlikely(ZERO_OR_NULL_PTR(s)))
return s;
// s: kmem_cache#30, gfpflags: GFP_KERNEL: 0xD0, _RET_IP_
// slab_alloc(kmem_cache#30, GFP_NOWAIT: 0, _RET_IP_):
// kmem_cache#30-oX
ret = slab_alloc(s, gfpflags, caller);
// ret: kmem_cache#30-o17
/* Honor the call site pointer we received. */
trace_kmalloc(caller, ret, size, s->size, gfpflags);
// ret: kmem_cache#30-o17
return ret;
// return kmem_cache#30-o17
}
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- va_copy()
- vsnprintf()
- format_decode()
- va_end()
- kmalloc_track_caller()
- kvasprintf()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
{
unsigned int len;
char *p;
va_list aq;
// ap: "fs"
va_copy(aq, ap);
// va_copy에서 한일:
// aq: "fs"
// fmt: "%s", aq: "fs"
// vsnprintf(NULL, 0, "%s", "fs"): 2
len = vsnprintf(NULL, 0, fmt, aq);
// len: 11 "kmalloc-192"의 길이
// len: 2
// aq: "fs"
va_end(aq);
// va_end에서 한일:
// aq: NULL
// len: 11, gfp: GFP_NOWAIT: 0
// kmalloc_track_caller(12, GFP_NOWAIT: 0): kmem_cache#30-o0
// len: 2, GFP_KERNEL: 0xD0
p = kmalloc_track_caller(len+1, gfp);
// p: kmem_cache#30-o0
// p: kmem_cache#30-oX
// p: kmem_cache#30-o0
// p: kmem_cache#30-oX
if (!p)
return NULL;
// p: kmem_cache#30-oX, len: 2, fmt: "%s", ap: "fs"
vsnprintf(p, len+1, fmt, ap);
// vsnprintf에서 한일:
// p: kmem_cache#30-oX: "fs"
// p: kmem_cache#30-o0
// p: kmem_cache#30-oX: "fs"
return p;
// return kmem_cache#30-o0
// return kmem_cache#30-oX: "fs"
}
EXPORT_SYMBOL(kvasprintf);
- call: start_kernel()->vfs_caches_init()
- mnt_init()
- kmem_cache_create()
- alloc_large_system_hash() : mnt_cache
- alloc_large_system_hash() : Mount-cache
- alloc_large_system_hash() : Mountpoint-cache
- INIT_HLIST_HEAD() : &mount_hashtable[u]
- INIT_HLIST_HEAD() : &mountpoint_hashtable[u]
- sysfs_init()
- kobject_create_and_add() : fs
- kobject_create()
- kobject_init()
- kobject_init_internal() : kobj
- kobject_init()
- kobject_add()
- va_start()
- kobject_add_vargs() : kobj, fs
- kobject_set_name_vargs()
- kvasprintf()
- va_copy()
- vsnprintf()
- format_decode()
- va_end()
- kmalloc_track_caller()
- kvasprintf()
- ret: kobject_set_name_vargs()
- kvasprintf()
- kobject_set_name_vargs()
- kobject_create()
// ARM10C 20160109
// kobj: kmem_cache#30-oX (struct kobject), fmt: "%s", vargs: "fs"
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
const char *old_name = kobj->name;
// old_name: NULL
char *s;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL, fmt: "%s"
if (kobj->name && !fmt)
return 0;
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: NULL
// GFP_KERNEL: 0xD0, fmt: "%s", vargs: "fs"
// kvasprintf(GFP_KERNEL: 0xD0, "%s", "fs"): kmem_cache#30-oX: "fs"
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: kmem_cache#30-oX: "fs"
// kobj->name: (kmem_cache#30-oX (struct kobject))->name: kmem_cache#30-oX: "fs"
if (!kobj->name)
return -ENOMEM;
// 2016/01/09 종료
- kernel object
- .ko로 확장자로 끝나는 파일들.
- kernel 2.6 이후 사용.
- 1st log
c68141d..7b4f179 master -> origin/master
Updating c68141d..7b4f179
Fast-forward
fs/dcache.c | 276 ++++++++++++++++++++++-----------------------
fs/inode.c | 458 +++++++++++++++++++++++++++++++++++++-------------------------------------
fs/mount.h | 24 ++++
fs/namespace.c | 626 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
fs/super.c | 218 ++++++++++++++++++------------------
fs/sysfs/inode.c | 222 ++++++++++++++++++------------------
fs/sysfs/mount.c | 814 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
include/linux/err.h | 9 ++
include/linux/fs.h | 1 +
include/linux/kernel.h | 1 +
include/linux/list.h | 2 +
include/linux/lockdep.h | 2 +
include/linux/seqlock.h | 126 +++++++++++++++++++++
include/linux/spinlock.h | 4 +
include/linux/spinlock_types.h | 12 ++
include/uapi/asm-generic/errno-base.h | 1 +
16 files changed, 1872 insertions(+), 924 deletions(-)
- 2nd log
7b4f179..f8705f2 master -> origin/master
Updating 7b4f179..f8705f2
Fast-forward
README.md | 3 +
fs/namespace.c | 425 ++++++++++++++++++++++++++++++++++++++
include/acpi/actypes.h | 5 +-
include/acpi/platform/acenv.h | 14 ++
include/acpi/platform/aclinux.h | 3 +
include/asm-generic/bitsperlong.h | 1 +
include/linux/ctype.h | 13 ++
include/linux/gfp.h | 1 +
include/linux/kobject.h | 2 +
include/linux/kref.h | 2 +
include/linux/list.h | 2 +
include/linux/slab.h | 4 +
lib/ctype.c | 1 +
lib/kasprintf.c | 25 +++
lib/kobject.c | 118 +++++++++++
lib/vsprintf.c | 91 +++++++-
mm/slub.c | 2 +
17 files changed, 708 insertions(+), 4 deletions(-)