kernels/linux-2.4.0/mm/shmem.c
/*
 * shmem_file_setup - get an unlinked file living in shmem fs
 *
 * @name: name for dentry (to be seen in /proc/<pid>/maps
 * @size: size to be set for the file
 *
 */
get an unlinked file living in shmem fs
@name: name for dentry (to be seen in /proc//maps
@size: size to be set for the file
get an unlinked file living in shmem fs @name : name for dentry ( to be seen in / proc // maps @size : size to be set for the file
struct file *shmem_file_setup(char * name, loff_t size)
{
	int error;
	struct file *file;
	struct inode * inode;
	struct dentry *dentry, *root;
	struct qstr this;
	int vm_enough_memory(long pages);
	error = -ENOMEM;
	if (!vm_enough_memory((size) >> PAGE_SHIFT))
		goto out;
	this.name = name;
	this.len = strlen(name);
	this.hash = 0; 
	root = shmem_fs_type.kern_mnt->mnt_root;
	dentry = d_alloc(root, &this);
	if (!dentry)
		goto out;
	error = -ENFILE;
	file = get_empty_filp();
	if (!file)
		goto put_dentry;
	error = -ENOSPC;
	inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0);
	if (!inode) 
		goto close_file;
	d_instantiate(dentry, inode);
	dentry->d_inode->i_size = size;
	file->f_vfsmnt = mntget(shmem_fs_type.kern_mnt);
	file->f_dentry = dentry;
	file->f_op = &shmem_file_operations;
	file->f_mode = FMODE_WRITE | FMODE_READ;
	inode->i_nlink = 0;	
	return(file);
close_file:
	put_filp(file);
put_dentry:
	dput (dentry);
out:
	return ERR_PTR(error);	
}
struct file * shmem_file_setup ( char * name , loff_t size ) { int error ; struct file * file ; struct inode * inode ; struct dentry * dentry , * root ; struct qstr this ; int vm_enough_memory ( long pages ) ; error = - ENOMEM ; if ( ! vm_enough_memory ( ( size ) >> PAGE_SHIFT ) ) goto out ; this . name = name ; this . len = strlen ( name ) ; this . hash = 0 ; root = shmem_fs_type . kern_mnt -> mnt_root ; dentry = d_alloc ( root , & this ) ; if ( ! dentry ) goto out ; error = - ENFILE ; file = get_empty_filp ( ) ; if ( ! file ) goto put_dentry ; error = - ENOSPC ; inode = shmem_get_inode ( root -> d_sb , S_IFREG | S_IRWXUGO , 0 ) ; if ( ! inode ) goto close_file ; d_instantiate ( dentry , inode ) ; dentry -> d_inode -> i_size = size ; file -> f_vfsmnt = mntget ( shmem_fs_type . kern_mnt ) ; file -> f_dentry = dentry ; file -> f_op = & shmem_file_operations ; file -> f_mode = FMODE_WRITE | FMODE_READ ; inode -> i_nlink = 0 ; return ( file ) ; close_file : put_filp ( file ) ; put_dentry : dput ( dentry ) ; out : return ERR_PTR ( error ) ; }
shmem_file_setup - get an unlinked file living in shmem fs
 @name: name for dentry (to be seen in /proc/<pid>/maps
 @size: size to be set for the file
shmem_file_setup - get an unlinked file living in shmem fs @name : name for dentry ( to be seen in / proc / <pid > / maps @size : size to be set for the file
/* will go */ /* It is unlinked */