kernels/linux-2.4.0/fs/fat/dir.c
/* This assumes that size of cluster is above the 32*slots */
This assumes that size of cluster is above the 32*slots
This assumes that size of cluster is above the 32 * slots
int fat_add_entries(struct inode *dir,int slots, struct buffer_head **bh,
		  struct msdos_dir_entry **de, int *ino)
{
	struct super_block *sb = dir->i_sb;
	loff_t offset, curr;
	int row;
	struct buffer_head *new_bh;
	offset = curr = 0;
	*bh = NULL;
	row = 0;
	while (fat_get_entry(dir,&curr,bh,de,ino) > -1) {
		if (IS_FREE((*de)->name)) {
			if (++row == slots)
				return offset;
		} else {
			row = 0;
			offset = curr;
		}
	}
	if ((dir->i_ino == MSDOS_ROOT_INO) && (MSDOS_SB(sb)->fat_bits != 32)) 
		return -ENOSPC;
	new_bh = fat_extend_dir(dir);
	if (!new_bh)
		return -ENOSPC;
	fat_brelse(sb, new_bh);
	do fat_get_entry(dir,&curr,bh,de,ino); while (++row<slots);
	return offset;
}
int fat_add_entries ( struct inode * dir , int slots , struct buffer_head * * bh , struct msdos_dir_entry * * de , int * ino ) { struct super_block * sb = dir -> i_sb ; loff_t offset , curr ; int row ; struct buffer_head * new_bh ; offset = curr = 0 ; * bh = NULL ; row = 0 ; while ( fat_get_entry ( dir , & curr , bh , de , ino ) > -1 ) { if ( IS_FREE ( ( * de ) -> name ) ) { if ( ++ row == slots ) return offset ; } else { row = 0 ; offset = curr ; } } if ( ( dir -> i_ino == MSDOS_ROOT_INO ) && ( MSDOS_SB ( sb ) -> fat_bits != 32 ) ) return - ENOSPC ; new_bh = fat_extend_dir ( dir ) ; if ( ! new_bh ) return - ENOSPC ; fat_brelse ( sb , new_bh ) ; do fat_get_entry ( dir , & curr , bh , de , ino ) ; while ( ++ row < slots ) ; return offset ; }
This assumes that size of cluster is above the 32*slots
This assumes that size of cluster is above the 32 * slots