qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare); 
xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare); 
xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,				       xfs_dirent_t *dbp, xfs_dir_put_t put){	xfs_dir_shortform_t *sf;	xfs_dir_sf_entry_t *sfe;	int retval, i, sbsize, nsbuf, lastresid=0, want_entno;	xfs_mount_t *mp;	xfs_dahash_t cookhash, hash;	xfs_dir_put_args_t p;	xfs_dir_sf_sort_t *sbuf, *sbp;	mp = dp->i_mount;	sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;	cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset);	want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset);	nsbuf = INT_GET(sf->hdr.count, ARCH_CONVERT) + 2;	sbsize = (nsbuf + 1) * sizeof(*sbuf);	sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);	xfs_dir_trace_g_du("sf: start", dp, uio);	/*	 * Collect all the entries into the buffer.	 * Entry 0 is .	 */	sbp->entno = 0;	sbp->seqno = 0;	sbp->hash = xfs_dir_hash_dot;	sbp->ino = dp->i_ino;	sbp->name = ".";	sbp->namelen = 1;	sbp++;	/*	 * Entry 1 is ..	 */	sbp->entno = 1;	sbp->seqno = 0;	sbp->hash = xfs_dir_hash_dotdot;	sbp->ino = XFS_GET_DIR_INO8(sf->hdr.parent);	sbp->name = "..";	sbp->namelen = 2;	sbp++;	/*	 * Scan the directory data for the rest of the entries.	 */	for (i = 0, sfe = &sf->list[0];			i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {		if (unlikely(		    ((char *)sfe < (char *)sf) ||		    ((char *)sfe >= ((char *)sf + dp->i_df.if_bytes)))) {			xfs_dir_trace_g_du("sf: corrupted", dp, uio);			XFS_CORRUPTION_ERROR("xfs_dir_shortform_getdents",					     XFS_ERRLEVEL_LOW, mp, sfe);			kmem_free(sbuf, sbsize);			return XFS_ERROR(EFSCORRUPTED);		}		sbp->entno = i + 2;		sbp->seqno = 0;		sbp->hash = xfs_da_hashname((char *)sfe->name, sfe->namelen);		sbp->ino = XFS_GET_DIR_INO8(sfe->inumber);		sbp->name = (char *)sfe->name;		sbp->namelen = sfe->namelen;		sfe = XFS_DIR_SF_NEXTENTRY(sfe);		sbp++;	}	/*	 * Sort the entries on hash then entno.	 */	qsort(sbuf, nsbuf, sizeof(*sbuf), xfs_dir_shortform_compare);	/*	 * Stuff in last entry.	 */	sbp->entno = nsbuf;	sbp->hash = XFS_DA_MAXHASH;	sbp->seqno = 0;	/*	 * Figure out the sequence numbers in case there's a hash duplicate.	 */	for (hash = sbuf->hash, sbp = sbuf + 1;				sbp < &sbuf[nsbuf + 1]; sbp++) {		if (sbp->hash == hash)			sbp->seqno = sbp[-1].seqno + 1;		else			hash = sbp->hash;	}	/*	 * Set up put routine.	 */	p.dbp = dbp;	p.put = put;	p.uio = uio;	/*	 * Find our place.	 */	for (sbp = sbuf; sbp < &sbuf[nsbuf + 1]; sbp++) {		if (sbp->hash > cookhash ||		    (sbp->hash == cookhash && sbp->seqno >= want_entno))			break;	}	/*	 * Did we fail to find anything?  We stop at the last entry,	 * the one we put maxhash into.	 */	if (sbp == &sbuf[nsbuf]) {		kmem_free(sbuf, sbsize);		xfs_dir_trace_g_du("sf: hash beyond end", dp, uio);		uio->uio_offset = XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH);		*eofp = 1;		return 0;	}	/*	 * Loop putting entries into the user buffer.	 */	while (sbp < &sbuf[nsbuf]) {		/*		 * Save the first resid in a run of equal-hashval entries		 * so that we can back them out if they don't all fit.		 */		if (sbp->seqno == 0 || sbp == sbuf)			lastresid = uio->uio_resid;		XFS_PUT_COOKIE(p.cook, mp, 0, sbp[1].seqno, sbp[1].hash);		p.ino = sbp->ino;#if XFS_BIG_INUMS		p.ino += mp->m_inoadd;#endif		p.name = sbp->name;		p.namelen = sbp->namelen;		retval = p.put(&p);		if (!p.done) {			uio->uio_offset =				XFS_DA_MAKE_COOKIE(mp, 0, 0, sbp->hash);			kmem_free(sbuf, sbsize);			uio->uio_resid = lastresid;			xfs_dir_trace_g_du("sf: E-O-B", dp, uio);			return retval;		}		sbp++;	}	kmem_free(sbuf, sbsize);	uio->uio_offset = p.cook.o;	*eofp = 1;	xfs_dir_trace_g_du("sf: E-O-F", dp, uio);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/380b5dc0e59340e7ed36dcc95dd1022aca75bbe2/xfs_dir_leaf.c/clean/fs/xfs/xfs_dir_leaf.c