Exemplo n.º 1
0
static int wrapfs_readdir(struct file *file, void *dirent, filldir_t filldir)
{
	int err = 0;
	struct file *lower_file = NULL;
	struct dentry *dentry = file->f_path.dentry;
	struct dentry *parent;
	struct inode *inode = NULL;
	int bindex = 0;

	inode = dentry->d_inode;
	parent = dget_parent(dentry);

	for (bindex = 0; bindex <= 1; bindex++) {
		lower_file = wrapfs_lower_file_idx(file, bindex);
		if (!lower_file)
			continue;
		err = vfs_readdir(lower_file, filldir, dirent);
		file->f_pos = lower_file->f_pos;
		if (err >= 0) {
			/* copy the atime */
			fsstack_copy_attr_atime(dentry->d_inode,
				lower_file->f_path.dentry->d_inode);
			}
		}
	dput(parent);
	return err;
}
Exemplo n.º 2
0
static int wrapfs_readdir(struct file *file, void *dirent, filldir_t filldir)
{
	int err = 0;
	struct file *lower_file = NULL;
	struct dentry *dentry = file->f_path.dentry;
	struct wrapfs_getdents_callback buf;
	int i = 0;
	UDBG;
	for (i = 0; i <= 1; i++) {
		UDBG;
		lower_file = wrapfs_lower_file_idx(file, i);
		if (!lower_file) {
			buf.files = NULL;
			buf.leftcount = 0;
			continue;
		}
		UDBG;
		buf.dirent = dirent;
		buf.filldir = filldir;
		buf.index = i;
		buf.count = 0;
		if (i == 0)
			buf.files = kmalloc(100*sizeof(char *), GFP_KERNEL);
		err = vfs_readdir(lower_file, wrapfs_filldir, &buf);
		if (i == 0)
			buf.leftcount = buf.count;
		else
			buf.leftcount = 0;
		file->f_pos = lower_file->f_pos;
		if (err >= 0 && !lower_file->f_path.dentry->d_inode)
			fsstack_copy_attr_atime(dentry->d_inode,
				lower_file->f_path.dentry->d_inode);
		if (err)
			goto out;
	}
out:
	return err;
}