kernels/linux-2.4.0/fs/jffs/intrep.c
/* This function adds a virtual root node to the in-RAM representation.
   Called by jffs_build_fs().  */
This function adds a virtual root node to the in-RAM representation.
This function adds a virtual root node to the in - RAM representation .
static int
jffs_add_virtual_root(struct jffs_control *c)
{
	struct jffs_file *root;
	struct jffs_node *node;
	D2(printk("jffs_add_virtual_root(): "
		  "Creating a virtual root directory.\n"));
	if (!(root = (struct jffs_file *)kmalloc(sizeof(struct jffs_file),
						 GFP_KERNEL))) {
		return -ENOMEM;
	}
	DJM(no_jffs_file++);
	if (!(node = (struct jffs_node *)kmalloc(sizeof(struct jffs_node),
						 GFP_KERNEL))) {
		kfree(root);
		DJM(no_jffs_file--);
		return -ENOMEM;
	}
	DJM(no_jffs_node++);
	memset(node, 0, sizeof(struct jffs_node));
	node->ino = JFFS_MIN_INO;
	memset(root, 0, sizeof(struct jffs_file));
	root->ino = JFFS_MIN_INO;
	root->mode = S_IFDIR | S_IRWXU | S_IRGRP
		     | S_IXGRP | S_IROTH | S_IXOTH;
	root->atime = root->mtime = root->ctime = CURRENT_TIME;
	root->nlink = 1;
	root->c = c;
	root->version_head = root->version_tail = node;
	jffs_insert_file_into_hash(root);
	return 0;
}
static int jffs_add_virtual_root ( struct jffs_control * c ) { struct jffs_file * root ; struct jffs_node * node ; D2 ( printk ( " " " \n " ) ) ; if ( ! ( root = ( struct jffs_file * ) kmalloc ( sizeof ( struct jffs_file ) , GFP_KERNEL ) ) ) { return - ENOMEM ; } DJM ( no_jffs_file ++ ) ; if ( ! ( node = ( struct jffs_node * ) kmalloc ( sizeof ( struct jffs_node ) , GFP_KERNEL ) ) ) { kfree ( root ) ; DJM ( no_jffs_file -- ) ; return - ENOMEM ; } DJM ( no_jffs_node ++ ) ; memset ( node , 0 , sizeof ( struct jffs_node ) ) ; node -> ino = JFFS_MIN_INO ; memset ( root , 0 , sizeof ( struct jffs_file ) ) ; root -> ino = JFFS_MIN_INO ; root -> mode = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ; root -> atime = root -> mtime = root -> ctime = CURRENT_TIME ; root -> nlink = 1 ; root -> c = c ; root -> version_head = root -> version_tail = node ; jffs_insert_file_into_hash ( root ) ; return 0 ; }
This function adds a virtual root node to the in-RAM representation.
This function adds a virtual root node to the in - RAM representation .