int hpux_getdents(unsigned int fd, struct hpux_dirent *dirent, unsigned int count)
{
struct file * file;
- struct dentry * dentry;
- struct inode * inode;
struct hpux_dirent * lastdirent;
struct getdents_callback buf;
- int error;
+ int error = -EBADF;
- lock_kernel();
- error = -EBADF;
file = fget(fd);
if (!file)
goto out;
- dentry = file->f_dentry;
- if (!dentry)
- goto out_putf;
-
- inode = dentry->d_inode;
- if (!inode)
- goto out_putf;
-
buf.current_dir = dirent;
buf.previous = NULL;
buf.count = count;
buf.error = 0;
- error = -ENOTDIR;
- if (!file->f_op || !file->f_op->readdir)
- goto out_putf;
-
- /*
- * Get the inode's semaphore to prevent changes
- * to the directory while we read it.
- */
- down(&inode->i_sem);
- error = file->f_op->readdir(file, &buf, filldir);
- up(&inode->i_sem);
+ error = vfs_readdir(file, &buf, filldir);
if (error < 0)
goto out_putf;
error = buf.error;
out_putf:
fput(file);
out:
- unlock_kernel();
return error;
}