error = parse_options(data, isvfat, &debug, &sbi->options); 
error = parse_options(data, isvfat, silent, &debug, &sbi->options); 
int fat_fill_super(struct super_block *sb, void *data, int silent,		   struct inode_operations *fs_dir_inode_ops, int isvfat){	struct inode *root_inode = NULL;	struct buffer_head *bh;	struct fat_boot_sector *b;	struct msdos_sb_info *sbi;	u16 logical_sector_size;	u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;	int debug;	unsigned int media;	long error;	char buf[50];	sbi = kmalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);	if (!sbi)		return -ENOMEM;	sb->s_fs_info = sbi;	memset(sbi, 0, sizeof(struct msdos_sb_info));	sb->s_flags |= MS_NODIRATIME;	sb->s_magic = MSDOS_SUPER_MAGIC;	sb->s_op = &fat_sops;	sb->s_export_op = &fat_export_ops;	sbi->dir_ops = fs_dir_inode_ops;	error = parse_options(data, isvfat, &debug, &sbi->options);	if (error)		goto out_fail;	error = -EIO;	sb_min_blocksize(sb, 512);	bh = sb_bread(sb, 0);	if (bh == NULL) {		printk(KERN_ERR "FAT: unable to read boot sector\n");		goto out_fail;	}	b = (struct fat_boot_sector *) bh->b_data;	if (!b->reserved) {		if (!silent)			printk(KERN_ERR "FAT: bogus number of reserved sectors\n");		brelse(bh);		goto out_invalid;	}	if (!b->fats) {		if (!silent)			printk(KERN_ERR "FAT: bogus number of FAT structure\n");		brelse(bh);		goto out_invalid;	}	/*	 * Earlier we checked here that b->secs_track and b->head are nonzero,	 * but it turns out valid FAT filesystems can have zero there.	 */	media = b->media;	if (!FAT_VALID_MEDIA(media)) {		if (!silent)			printk(KERN_ERR "FAT: invalid media value (0x%02x)\n",			       media);		brelse(bh);		goto out_invalid;	}	logical_sector_size =		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));	if (!logical_sector_size	    || (logical_sector_size & (logical_sector_size - 1))	    || (logical_sector_size < 512)	    || (PAGE_CACHE_SIZE < logical_sector_size)) {		if (!silent)			printk(KERN_ERR "FAT: bogus logical sector size %u\n",			       logical_sector_size);		brelse(bh);		goto out_invalid;	}	sbi->sec_per_clus = b->sec_per_clus;	if (!sbi->sec_per_clus	    || (sbi->sec_per_clus & (sbi->sec_per_clus - 1))) {		if (!silent)			printk(KERN_ERR "FAT: bogus sectors per cluster %u\n",			       sbi->sec_per_clus);		brelse(bh);		goto out_invalid;	}	if (logical_sector_size < sb->s_blocksize) {		printk(KERN_ERR "FAT: logical sector size too small for device"		       " (logical sector size = %u)\n", logical_sector_size);		brelse(bh);		goto out_fail;	}	if (logical_sector_size > sb->s_blocksize) {		brelse(bh);		if (!sb_set_blocksize(sb, logical_sector_size)) {			printk(KERN_ERR "FAT: unable to set blocksize %u\n",			       logical_sector_size);			goto out_fail;		}		bh = sb_bread(sb, 0);		if (bh == NULL) {			printk(KERN_ERR "FAT: unable to read boot sector"			       " (logical sector size = %lu)\n",			       sb->s_blocksize);			goto out_fail;		}		b = (struct fat_boot_sector *) bh->b_data;	}	sbi->cluster_size = sb->s_blocksize * sbi->sec_per_clus;	sbi->cluster_bits = ffs(sbi->cluster_size) - 1;	sbi->fats = b->fats;	sbi->fat_bits = 0;		/* Don't know yet */	sbi->fat_start = le16_to_cpu(b->reserved);	sbi->fat_length = le16_to_cpu(b->fat_length);	sbi->root_cluster = 0;	sbi->free_clusters = -1;	/* Don't know yet */	sbi->prev_free = FAT_START_ENT;	if (!sbi->fat_length && b->fat32_length) {		struct fat_boot_fsinfo *fsinfo;		struct buffer_head *fsinfo_bh;		/* Must be FAT32 */		sbi->fat_bits = 32;		sbi->fat_length = le32_to_cpu(b->fat32_length);		sbi->root_cluster = le32_to_cpu(b->root_cluster);		sb->s_maxbytes = 0xffffffff;		/* MC - if info_sector is 0, don't multiply by 0 */		sbi->fsinfo_sector = le16_to_cpu(b->info_sector);		if (sbi->fsinfo_sector == 0)			sbi->fsinfo_sector = 1;		fsinfo_bh = sb_bread(sb, sbi->fsinfo_sector);		if (fsinfo_bh == NULL) {			printk(KERN_ERR "FAT: bread failed, FSINFO block"			       " (sector = %lu)\n", sbi->fsinfo_sector);			brelse(bh);			goto out_fail;		}		fsinfo = (struct fat_boot_fsinfo *)fsinfo_bh->b_data;		if (!IS_FSINFO(fsinfo)) {			printk(KERN_WARNING			       "FAT: Did not find valid FSINFO signature.\n"			       "     Found signature1 0x%08x signature2 0x%08x"			       " (sector = %lu)\n",			       le32_to_cpu(fsinfo->signature1),			       le32_to_cpu(fsinfo->signature2),			       sbi->fsinfo_sector);		} else {			sbi->free_clusters = le32_to_cpu(fsinfo->free_clusters);			sbi->prev_free = le32_to_cpu(fsinfo->next_cluster);		}		brelse(fsinfo_bh);	}	sbi->dir_per_block = sb->s_blocksize / sizeof(struct msdos_dir_entry);	sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1;	sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length;	sbi->dir_entries =		le16_to_cpu(get_unaligned((__le16 *)&b->dir_entries));	if (sbi->dir_entries & (sbi->dir_per_block - 1)) {		if (!silent)			printk(KERN_ERR "FAT: bogus directroy-entries per block"			       " (%u)\n", sbi->dir_entries);		brelse(bh);		goto out_invalid;	}	rootdir_sectors = sbi->dir_entries		* sizeof(struct msdos_dir_entry) / sb->s_blocksize;	sbi->data_start = sbi->dir_start + rootdir_sectors;	total_sectors = le16_to_cpu(get_unaligned((__le16 *)&b->sectors));	if (total_sectors == 0)		total_sectors = le32_to_cpu(b->total_sect);	total_clusters = (total_sectors - sbi->data_start) / sbi->sec_per_clus;	if (sbi->fat_bits != 32)		sbi->fat_bits = (total_clusters > MAX_FAT12) ? 16 : 12;	/* check that FAT table does not overflow */	fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;	total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);	if (total_clusters > MAX_FAT(sb)) {		if (!silent)			printk(KERN_ERR "FAT: count of clusters too big (%u)\n",			       total_clusters);		brelse(bh);		goto out_invalid;	}	sbi->max_cluster = total_clusters + FAT_START_ENT;	/* check the free_clusters, it's not necessarily correct */	if (sbi->free_clusters != -1 && sbi->free_clusters > total_clusters)		sbi->free_clusters = -1;	/* check the prev_free, it's not necessarily correct */	sbi->prev_free %= sbi->max_cluster;	if (sbi->prev_free < FAT_START_ENT)		sbi->prev_free = FAT_START_ENT;	brelse(bh);	/* set up enough so that it can read an inode */	fat_hash_init(sb);	fat_ent_access_init(sb);	/*	 * The low byte of FAT's first entry must have same value with	 * media-field.  But in real world, too many devices is	 * writing wrong value.  So, removed that validity check.	 *	 * if (FAT_FIRST_ENT(sb, media) != first)	 */	error = -EINVAL;	sprintf(buf, "cp%d", sbi->options.codepage);	sbi->nls_disk = load_nls(buf);	if (!sbi->nls_disk) {		printk(KERN_ERR "FAT: codepage %s not found\n", buf);		goto out_fail;	}	/* FIXME: utf8 is using iocharset for upper/lower conversion */	if (sbi->options.isvfat) {		sbi->nls_io = load_nls(sbi->options.iocharset);		if (!sbi->nls_io) {			printk(KERN_ERR "FAT: IO charset %s not found\n",			       sbi->options.iocharset);			goto out_fail;		}	}	error = -ENOMEM;	root_inode = new_inode(sb);	if (!root_inode)		goto out_fail;	root_inode->i_ino = MSDOS_ROOT_INO;	root_inode->i_version = 1;	error = fat_read_root(root_inode);	if (error < 0)		goto out_fail;	error = -ENOMEM;	insert_inode_hash(root_inode);	sb->s_root = d_alloc_root(root_inode);	if (!sb->s_root) {		printk(KERN_ERR "FAT: get root inode failed\n");		goto out_fail;	}	return 0;out_invalid:	error = -EINVAL;	if (!silent)		printk(KERN_INFO "VFS: Can't find a valid FAT filesystem"		       " on dev %s.\n", sb->s_id);out_fail:	if (root_inode)		iput(root_inode);	if (sbi->nls_io)		unload_nls(sbi->nls_io);	if (sbi->nls_disk)		unload_nls(sbi->nls_disk);	if (sbi->options.iocharset != fat_default_iocharset)		kfree(sbi->options.iocharset);	sb->s_fs_info = NULL;	kfree(sbi);	return error;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/41a34a4fe1d4478b1c8b6b6ea634ab1adb156885/inode.c/clean/fs/fat/inode.c