/* get a directory entry. Note that the caller is responsible for holding the relevant locks.  */
static int __adfs_dir_get(struct adfs_dir *dir, int pos, struct object_info *obj)
/* get a directory entry. Note that the caller is responsible for holding the relevant locks.  */
static int __adfs_dir_get(struct adfs_dir *dir, int pos, struct object_info *obj)
{
	struct super_block *sb = dir->sb;
	struct adfs_direntry de;
	int thissize, buffer, offset;
	buffer = pos >> sb->s_blocksize_bits;
	if (buffer > dir->nr_buffers)
		return -EINVAL;
	offset = pos & (sb->s_blocksize - 1);
	thissize = sb->s_blocksize - offset;
	if (thissize > 26)
		thissize = 26;
	memcpy(&de, dir->bh[buffer]->b_data + offset, thissize);
	if (thissize != 26)
		memcpy(((char *)&de) + thissize, dir->bh[buffer + 1]->b_data,
		       26 - thissize);
	if (!de.dirobname[0])
		return -ENOENT;
	adfs_dir2obj(obj, &de);
	return 0;
}