/* fat_subdirs counts the number of sub-directories of dir. It can be run on directories being created.  */
int fat_subdirs(struct inode *dir)
/* fat_subdirs counts the number of sub-directories of dir. It can be run on directories being created.  */
int fat_subdirs(struct inode *dir)
{
	struct buffer_head *bh;
	struct msdos_dir_entry *de;
	loff_t cpos;
	int count = 0;
	bh = NULL;
	cpos = 0;
	while (fat_get_short_entry(dir, &cpos, &bh, &de) >= 0) {
		if (de->attr & ATTR_DIR)
			count++;
	}
	brelse(bh);
	return count;
}