len = hfs_mac2triv(strbuf, &fd.key->cat.CName); 
len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName); 
static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir){	struct inode *inode = filp->f_dentry->d_inode;	struct super_block *sb = inode->i_sb;	int len, err;	char strbuf[HFS_NAMELEN + 1];	union hfs_cat_rec entry;	struct hfs_find_data fd;	struct hfs_readdir_data *rd;	u16 type;	if (filp->f_pos >= inode->i_size)		return 0;	hfs_find_init(HFS_SB(sb)->cat_tree, &fd);	hfs_cat_build_key(fd.search_key, inode->i_ino, NULL);	err = hfs_brec_find(&fd);	if (err)		goto out;	switch ((u32)filp->f_pos) {	case 0:		/* This is completely artificial... */		if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR))			goto out;		filp->f_pos++;		/* fall through */	case 1:		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);		if (entry.type != HFS_CDR_THD) {			printk("HFS: bad catalog folder thread\n");			err = -EIO;			goto out;		}		//if (fd.entrylength < HFS_MIN_THREAD_SZ) {		//	printk("HFS: truncated catalog thread\n");		//	err = -EIO;		//	goto out;		//}		if (filldir(dirent, "..", 2, 1,			    be32_to_cpu(entry.thread.ParID), DT_DIR))			goto out;		filp->f_pos++;		/* fall through */	default:		if (filp->f_pos >= inode->i_size)			goto out;		err = hfs_brec_goto(&fd, filp->f_pos - 1);		if (err)			goto out;	}	for (;;) {		if (be32_to_cpu(fd.key->cat.ParID) != inode->i_ino) {			printk("HFS: walked past end of dir\n");			err = -EIO;			goto out;		}		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);		type = entry.type;		len = hfs_mac2triv(strbuf, &fd.key->cat.CName);		if (type == HFS_CDR_DIR) {			if (fd.entrylength < sizeof(struct hfs_cat_dir)) {				printk("HFS: small dir entry\n");				err = -EIO;				goto out;			}			if (filldir(dirent, strbuf, len, filp->f_pos,				    be32_to_cpu(entry.dir.DirID), DT_DIR))				break;		} else if (type == HFS_CDR_FIL) {			if (fd.entrylength < sizeof(struct hfs_cat_file)) {				printk("HFS: small file entry\n");				err = -EIO;				goto out;			}			if (filldir(dirent, strbuf, len, filp->f_pos,				    be32_to_cpu(entry.file.FlNum), DT_REG))				break;		} else {			printk("HFS: bad catalog entry type %d\n", type);			err = -EIO;			goto out;		}		filp->f_pos++;		if (filp->f_pos >= inode->i_size)			goto out;		err = hfs_brec_goto(&fd, 1);		if (err)			goto out;	}	rd = filp->private_data;	if (!rd) {		rd = kmalloc(sizeof(struct hfs_readdir_data), GFP_KERNEL);		if (!rd) {			err = -ENOMEM;			goto out;		}		filp->private_data = rd;		rd->file = filp;		list_add(&rd->list, &HFS_I(inode)->open_dir_list);	}	memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key));out:	hfs_find_exit(&fd);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/328b9227865026268261a24a97a578907b280415/dir.c/clean/fs/hfs/dir.c