static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
{
	struct coda_file_info *cfi;
	struct file *host_file;
	int ret;

	cfi = CODA_FTOC(coda_file);
	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
	host_file = cfi->cfi_container;

	if (!host_file->f_op)
		return -ENOTDIR;

	if (host_file->f_op->readdir)
	{
		struct inode *host_inode = host_file->f_path.dentry->d_inode;

		mutex_lock(&host_inode->i_mutex);
		host_file->f_pos = coda_file->f_pos;

		ret = -ENOENT;
		if (!IS_DEADDIR(host_inode)) {
			ret = host_file->f_op->readdir(host_file, buf, filldir);
			file_accessed(host_file);
		}

		coda_file->f_pos = host_file->f_pos;
		mutex_unlock(&host_inode->i_mutex);
	}
	else 
		ret = coda_venus_readdir(coda_file, buf, filldir);

	return ret;
}
/* file operations for directories */
int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
{
	struct dentry *coda_dentry = coda_file->f_dentry;
	struct coda_file_info *cfi;
	struct file *host_file;
	int ret;

	cfi = CODA_FTOC(coda_file);
	if (!cfi || cfi->cfi_magic != CODA_MAGIC) BUG();
	host_file = cfi->cfi_container;

	coda_vfs_stat.readdir++;

	down(&host_file->f_dentry->d_inode->i_sem);
	host_file->f_pos = coda_file->f_pos;

	if ( !host_file->f_op->readdir ) {
		/* Venus: we must read Venus dirents from the file */
		ret = coda_venus_readdir(host_file, filldir, dirent, coda_dentry);
	} else {
		/* potemkin case: we were handed a directory inode */
		ret = vfs_readdir(host_file, filldir, dirent);
	}

	coda_file->f_pos = host_file->f_pos;
	up(&host_file->f_dentry->d_inode->i_sem);

	return ret;
}
Exemple #3
0
/* file operations for directories */
int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
{
	struct dentry *coda_dentry = coda_file->f_path.dentry;
	struct coda_file_info *cfi;
	struct file *host_file;
	struct inode *host_inode;
	int ret;

	cfi = CODA_FTOC(coda_file);
	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
	host_file = cfi->cfi_container;

	coda_vfs_stat.readdir++;

	host_inode = host_file->f_path.dentry->d_inode;
	mutex_lock(&host_inode->i_mutex);
	host_file->f_pos = coda_file->f_pos;

	if (!host_file->f_op->readdir) {
		/* Venus: we must read Venus dirents from the file */
		ret = coda_venus_readdir(host_file, filldir, dirent, coda_dentry);
	} else {
		/* potemkin case: we were handed a directory inode. */
		/* Yuk, we can't call vfs_readdir because we are already
		 * holding the inode semaphore. */
		ret = -ENOTDIR;
		if (!host_file->f_op || !host_file->f_op->readdir)
			goto out;

		ret = -ENOENT;
		if (!IS_DEADDIR(host_inode)) {
			ret = host_file->f_op->readdir(host_file, filldir, dirent);
			file_accessed(host_file);
		}
	}
out:
	coda_file->f_pos = host_file->f_pos;
	mutex_unlock(&host_inode->i_mutex);

	return ret;
}
Exemple #4
0
/* file operations for directories */
static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
{
	struct coda_file_info *cfi;
	struct file *host_file;
	int ret;

	cfi = CODA_FTOC(coda_file);
	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
	host_file = cfi->cfi_container;

	if (!host_file->f_op)
		return -ENOTDIR;

	if (host_file->f_op->readdir)
	{
		/* potemkin case: we were handed a directory inode.
		 * We can't use vfs_readdir because we have to keep the file
		 * position in sync between the coda_file and the host_file.
		 * and as such we need grab the inode mutex. */
		struct inode *host_inode = host_file->f_path.dentry->d_inode;

		mutex_lock(&host_inode->i_mutex);
		host_file->f_pos = coda_file->f_pos;

		ret = -ENOENT;
		if (!IS_DEADDIR(host_inode)) {
			ret = host_file->f_op->readdir(host_file, buf, filldir);
			file_accessed(host_file);
		}

		coda_file->f_pos = host_file->f_pos;
		mutex_unlock(&host_inode->i_mutex);
	}
	else /* Venus: we must read Venus dirents from a file */
		ret = coda_venus_readdir(coda_file, buf, filldir);

	return ret;
}
Exemple #5
0
/* file operations for directories */
static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
{
    struct coda_file_info *cfi;
    struct file *host_file;
    int ret;

    cfi = CODA_FTOC(coda_file);
    BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
    host_file = cfi->cfi_container;

    if (host_file->f_op->iterate) {
        struct inode *host_inode = file_inode(host_file);
        mutex_lock(&host_inode->i_mutex);
        ret = -ENOENT;
        if (!IS_DEADDIR(host_inode)) {
            ret = host_file->f_op->iterate(host_file, ctx);
            file_accessed(host_file);
        }
        mutex_unlock(&host_inode->i_mutex);
        return ret;
    }
    /* Venus: we must read Venus dirents from a file */
    return coda_venus_readdir(coda_file, ctx);
}