tmpfs 코드의 대부분은 mm/shmem.c
입니다. 새 inode는
static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir,
int mode, dev_t dev, unsigned long flags)
으로 생성되지만 거의 모든 파일을 일반 파일 시스템 코드에 위임합니다.
/**
* new_inode - obtain an inode
* @sb: superblock
*
* Allocates a new inode for given superblock. The default gfp_mask
* for allocations related to inode->i_mapping is GFP_HIGHUSER_MOVABLE.
* If HIGHMEM pages are unsuitable or it is known that pages allocated
* for the page cache are not reclaimable or migratable,
* mapping_set_gfp_mask() must be called with suitable flags on the
* newly created inode's mapping
*
*/
struct inode *new_inode(struct super_block *sb)
{
/*
* On a 32bit, non LFS stat() call, glibc will generate an EOVERFLOW
* error if st_ino won't fit in target struct field. Use 32bit counter
* here to attempt to avoid that.
*/
static unsigned int last_ino;
struct inode *inode;
spin_lock_prefetch(&inode_lock);
inode = alloc_inode(sb);
if (inode) {
spin_lock(&inode_lock);
__inode_add_to_lists(sb, NULL, inode);
inode->i_ino = ++last_ino;
inode->i_state = 0;
spin_unlock(&inode_lock);
}
return inode;
}
을 그리고 그것은 참으로 단지 증분 카운터 (last_ino)를 사용 않습니다 특히
필드 i_ino
는 fs/inode.c
에 채워집니다.
대부분의 다른 파일 시스템은 디스크에있는 정보를 사용하여 나중에 i_ino
필드를 덮어 씁니다.
이 모든 것이 완전히 가능하다는 점에 유의하십시오. 커널에는 다양한 방식으로 채워지는 "생성"필드도 있습니다. mm/shmem.c
은 현재 시간을 사용합니다.
고마워요. '주위를 둘러 싸다'는 것은 무엇을 의미합니까? –
오버플로 발생시 0으로 되돌아갑니다. – slezica