Example #1
0
STATIC int
base0fs_mknod(inode_t *dir, struct dentry *dentry, int mode, dev_t dev)
{
        int err;
        struct dentry *lower_dentry;
        struct dentry *lower_dir_dentry;

        print_entry_location();
        lower_dentry = base0fs_lower_dentry(dentry);	/* CPW: Moved below print_entry_location */
        fist_checkinode(dir, "base0fs_mknod-dir");

        lower_dir_dentry = base0fs_lock_parent(lower_dentry);

        err = VFS_MKNOD(lower_dir_dentry->d_inode,
                        lower_dentry,
                        mode,
                        dev);
        if (err || !lower_dentry->d_inode)
                goto out;

        err = base0fs_interpose(lower_dentry, dentry, dir->i_sb, 0);
        if (err)
                goto out;
        fist_copy_attr_timesizes(dir, lower_dir_dentry->d_inode);

out:
        unlock_dir(lower_dir_dentry);
        if (!dentry->d_inode)
                d_drop(dentry);

        fist_checkinode(dir, "post base0fs_mknod-dir");
        print_exit_status(err);
        return err;
}
Example #2
0
STATIC int
base0fs_readlink(struct dentry *dentry, char *buf, int bufsiz)
{
        int err;
        struct dentry *lower_dentry;

        print_entry_location();
        lower_dentry = base0fs_lower_dentry(dentry);/* CPW: Moved below print_entry_location */
        fist_print_dentry("base0fs_readlink IN", dentry);

        if (!lower_dentry->d_inode->i_op ||
             !lower_dentry->d_inode->i_op->readlink) {
                err = -EINVAL;
                goto out;
        }

        err = lower_dentry->d_inode->i_op->readlink(lower_dentry,
                                                    buf,
                                                    bufsiz);
        if (err > 0)
                fist_copy_attr_atime(dentry->d_inode, lower_dentry->d_inode);

out:
        print_exit_status(err);
        return err;
}
Example #3
0
void unionfs_reinterpose(struct dentry *dentry)
{
	struct dentry *hidden_dentry;
	struct inode *inode;
	int bindex, bstart, bend;

	print_entry_location();
	verify_locked(dentry);
	fist_print_dentry("IN: unionfs_reinterpose: ", dentry);

	/* This is pre-allocated inode */
	inode = dentry->d_inode;

	bstart = dbstart(dentry);
	bend = dbend(dentry);
	for (bindex = bstart; bindex <= bend; bindex++) {
		hidden_dentry = dtohd_index(dentry, bindex);
		if (!hidden_dentry)
			continue;

		if (!hidden_dentry->d_inode)
			continue;
		if (itohi_index(inode, bindex))
			continue;
		set_itohi_index(inode, bindex, IGRAB(hidden_dentry->d_inode));
	}
	ibstart(inode) = dbstart(dentry);
	ibend(inode) = dbend(dentry);

	fist_print_dentry("OUT: unionfs_reinterpose: ", dentry);
	fist_print_inode("OUT: unionfs_reinterpose: ", inode);

	print_exit_location();
}
Example #4
0
/* The rest of these are utility functions for lookup. */
static int is_opaque_dir(struct dentry *dentry, int bindex)
{
	int err = 0;
	struct dentry *hidden_dentry;
	struct dentry *wh_hidden_dentry;
	struct inode *hidden_inode;
	uid_t saved_uid = current->fsuid;
	gid_t saved_gid = current->fsgid;

	print_entry_location();

	hidden_dentry = dtohd_index(dentry, bindex);
	hidden_inode = hidden_dentry->d_inode;

	BUG_ON(!S_ISDIR(hidden_inode->i_mode));

	current->fsuid = hidden_inode->i_uid;
	current->fsgid = hidden_inode->i_gid;
	wh_hidden_dentry = LOOKUP_ONE_LEN(UNIONFS_DIR_OPAQUE, hidden_dentry,
					  sizeof(UNIONFS_DIR_OPAQUE) - 1);
	current->fsuid = saved_uid;
	current->fsgid = saved_gid;
	if (IS_ERR(wh_hidden_dentry)) {
		err = PTR_ERR(wh_hidden_dentry);
		fist_dprint(1, "LOOKUP_ONE_LEN returned: %d\n", err);
		goto out;
	}
	if (wh_hidden_dentry->d_inode)
		err = 1;
	DPUT(wh_hidden_dentry);
      out:
	print_exit_status(err);
	return err;
}
Example #5
0
/* final actions when unmounting a file system */
static void unionfs_put_super(struct super_block *sb)
{
	int bindex, bstart, bend;
	struct unionfs_sb_info *spd;

	print_entry_location();

	if ((spd = stopd(sb))) {
		/* XXX: Free persistent inode stuff. */

		bstart = sbstart(sb);
		bend = sbend(sb);
		for (bindex = bstart; bindex <= bend; bindex++)
			mntput(stohiddenmnt_index(sb, bindex));

		/* Make sure we have no leaks of branchget/branchput. */
		for (bindex = bstart; bindex <= bend; bindex++)
			ASSERT(branch_count(sb, bindex) == 0);

		KFREE(stohs_ptr(sb));
		KFREE(stohiddenmnt_ptr(sb));
		KFREE(spd->usi_sbcount_p);
		KFREE(spd->usi_branchperms_p);
		KFREE(spd->usi_putmaps);
		KFREE(spd);
		stopd_lhs(sb) = NULL;
	}
	fist_dprint(6, "unionfs: released super\n");

	print_exit_location();
}
Example #6
0
/*
 * BKL held by caller.
 * dentry->d_inode->i_{sem,mutex} down
 */
STATIC int
base0fs_removexattr(struct dentry *dentry, const char *name)
{
        struct dentry *lower_dentry = NULL;
        int err = -ENOTSUPP;
        char *encoded_name;
        print_entry_location();

        lower_dentry = DENTRY_TO_LOWER(dentry);

        BUG_ON(!lower_dentry);
        BUG_ON(!lower_dentry->d_inode);
        BUG_ON(!lower_dentry->d_inode->i_op);

        fist_dprint(18, "removexattr: name=\"%s\"\n", name);

        if (lower_dentry->d_inode->i_op->removexattr) {
                encoded_name = (char *)name;

                lock_inode(lower_dentry->d_inode);
                /* lock_kernel() already done by caller. */
                err = lower_dentry->d_inode->i_op->removexattr(lower_dentry, encoded_name);
                /* unlock_kernel() will be done by caller. */
                unlock_inode(lower_dentry->d_inode);
        }

out:
        print_exit_status(err);
        return err;
}
Example #7
0
/*
 * BKL held by caller.
 * dentry->d_inode->i_{sem,mutex} down
 */
STATIC ssize_t
base0fs_listxattr(struct dentry *dentry, char *list, size_t size)
{
        struct dentry *lower_dentry = NULL;
        int err = -ENOTSUPP;
        char *encoded_list = NULL;

        print_entry_location();

        lower_dentry = DENTRY_TO_LOWER(dentry);

        BUG_ON(!lower_dentry);
        BUG_ON(!lower_dentry->d_inode);
        BUG_ON(!lower_dentry->d_inode->i_op);

        if (lower_dentry->d_inode->i_op->listxattr) {
                encoded_list = list;
                lock_inode(lower_dentry->d_inode);
                /* lock_kernel() already done by caller. */
                err = lower_dentry->d_inode->i_op->listxattr(lower_dentry, encoded_list, size);
                /* unlock_kernel() will be done by caller. */
                unlock_inode(lower_dentry->d_inode);
        }

out:
        print_exit_status(err);
        return err;
}
Example #8
0
STATIC int
base0fs_setattr(struct dentry *dentry, struct iattr *ia)
{
        int err = 0;
        struct dentry *lower_dentry;
        inode_t *inode;
        inode_t *lower_inode;

        print_entry_location();
        lower_dentry = base0fs_lower_dentry(dentry);
        inode = dentry->d_inode;
        lower_inode = INODE_TO_LOWER(inode);
        fist_checkinode(inode, "base0fs_setattr");


        err = notify_change(lower_dentry, 
#ifdef HAVE_3_ARG_NOTIFY_CHANGE
                DENTRY_TO_LVFSMNT(dentry),
#endif
                ia);

#if defined(FIST_FILTER_DATA) || defined(FIST_FILTER_SCA)
out:
#endif /* FIST_FILTER_DATA || FIST_FILTER_SCA */
        /*
         * The lower file system might has changed the attributes, even if
         * notify_change above resulted in an error(!)  so we copy the
         * lower_inode's attributes (and a few more) to our inode.
         */
        fist_copy_attr_all(inode, lower_inode);

        fist_checkinode(inode, "post base0fs_setattr");
        print_exit_status(err);
        return err;
}
Example #9
0
void
kdb3fs_d_release(dentry_t *dentry)
{
	dentry_t *hidden_dentry;

	print_entry_location();
#if 0	
	fist_print_dentry("kdb3fs_d_release IN dentry", dentry);

	/* this could be a negative dentry, so check first */
	if (!dtopd(dentry)) {
		fist_dprint(6, "dentry without private data: %*s", dentry->d_name.len, dentry->d_name.name);
		goto out;
	}
	hidden_dentry = dtohd(dentry);
	fist_print_dentry("kdb3fs_d_release IN hidden_dentry", hidden_dentry);
	if (hidden_dentry->d_inode)
		fist_dprint(6, "kdb3fs_d_release: hidden_inode->i_count %d, i_num %lu.\n",
			    atomic_read(&hidden_dentry->d_inode->i_count),
			    hidden_dentry->d_inode->i_ino);

	/* free private data (kdb3fs_dentry_info) here */
	KFREE(dtopd(dentry));
	dtopd(dentry) = NULL;	/* just to be safe */
	/* decrement hidden dentry's counter and free its inode */
	dput(hidden_dentry);
#endif
out:
	print_exit_location();
}
Example #10
0
int unionfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
{
	int err;
	struct dentry *hidden_dentry;

	print_entry_location();
	lock_dentry(dentry);
	hidden_dentry = dtohd(dentry);
	fist_print_dentry("unionfs_readlink IN", dentry);

	if (!hidden_dentry->d_inode->i_op ||
	    !hidden_dentry->d_inode->i_op->readlink) {
		err = -EINVAL;
		goto out;
	}

	err = hidden_dentry->d_inode->i_op->readlink(hidden_dentry,
						     buf, bufsiz);
	if (err > 0)
		fist_copy_attr_atime(dentry->d_inode, hidden_dentry->d_inode);

      out:
	unlock_dentry(dentry);
	print_exit_status(err);
	return err;
}
Example #11
0
/* BKL held by caller.
 * dentry->d_inode->i_sem down
 */
int
unionfs_setxattr(struct dentry *dentry, const char *name, const void *value,
		 size_t size, int flags)
{
	struct dentry *hidden_dentry = NULL;
	int err = -EOPNOTSUPP;

	print_entry_location();

	lock_dentry(dentry);
	hidden_dentry = dtohd(dentry);

	fist_dprint(8, "setxattr: name=\"%s\", value %lu bytes, flags=%x\n",
		    name, (unsigned long)size, flags);

	if (hidden_dentry->d_inode->i_op->setxattr) {
		down(&hidden_dentry->d_inode->i_sem);
		/* lock_kernel() already done by caller. */
		err = hidden_dentry->d_inode->i_op->
		    setxattr(hidden_dentry, name, value, size, flags);
		/* unlock_kernel() will be done by caller. */
		up(&hidden_dentry->d_inode->i_sem);
	}

	unlock_dentry(dentry);
	print_exit_status(err);
	return err;
}
Example #12
0
/* BKL held by caller.
 * dentry->d_inode->i_sem down
 */
int unionfs_removexattr(struct dentry *dentry, const char *name)
{
	struct dentry *hidden_dentry = NULL;
	int err = -EOPNOTSUPP;
	char *encoded_name;
	print_entry_location();

	lock_dentry(dentry);
	hidden_dentry = dtohd(dentry);

	fist_dprint(8, "removexattr: name=\"%s\"\n", name);

	if (hidden_dentry->d_inode->i_op->removexattr) {
		encoded_name = (char *)name;

		down(&hidden_dentry->d_inode->i_sem);
		/* lock_kernel() already done by caller. */
		err =
		    hidden_dentry->d_inode->i_op->removexattr(hidden_dentry,
							      encoded_name);
		/* unlock_kernel() will be done by caller. */
		up(&hidden_dentry->d_inode->i_sem);
	}

	unlock_dentry(dentry);
	print_exit_status(err);
	return err;
}
Example #13
0
STATIC void
base0fs_vm_close(vm_area_t *vma)
{
        vm_area_t *lower_vma;
        file_t *file;
        file_t *lower_file = NULL;

        print_entry_location();

        lower_vma = VMA_TO_LOWER(vma);
        file = vma->vm_file;
        if (FILE_TO_PRIVATE(file) != NULL)
                lower_file = FILE_TO_LOWER(file);
        BUG_ON(!lower_file);

        fist_dprint(6, "VM_CLOSE1: file 0x%x, lower_file 0x%x, file->f_count %d, lower_file->f_count %d\n",
                    (int) file, (int) lower_file,
                    (int) atomic_read(&file->f_count),
                    (int) atomic_read(&lower_file->f_count));

        BUG_ON(!lower_vma);

        if (lower_vma->vm_ops->close)
                lower_vma->vm_ops->close(lower_vma);
        fput(lower_file);
        KFREE(lower_vma);
        VMA_TO_LOWER(vma) = NULL;

        fist_dprint(6, "VM_CLOSE2: file 0x%x, lower_file 0x%x, file->f_count %d, lower_file->f_count %d\n",
                    (int) file, (int) lower_file,
                    (int) atomic_read(&file->f_count),
                    (int) atomic_read(&lower_file->f_count));
        print_exit_location();
}
Example #14
0
STATIC void
base0fs_vm_shared_unmap(vm_area_t *vma, unsigned long start, size_t len)
{
        vm_area_t *lower_vma;
        file_t *file;
        file_t *lower_file = NULL;

        print_entry_location();
        lower_vma = VMA_TO_LOWER(vma);
        file = vma->vm_file;
        if (FILE_TO_PRIVATE(file) != NULL)
                lower_file = FILE_TO_LOWER(file);
        BUG_ON(!lower_file);

        fist_dprint(6, "VM_S_UNMAP1: file 0x%x, lower_file 0x%x, file->f_count %d, lower_file->f_count %d\n",
                    (int) file, (int) lower_file,
                    (int) atomic_read(&file->f_count),
                    (int) atomic_read(&lower_file->f_count));

        /*
         * call sync (filemap_sync) because the default filemap_unmap
         * calls it too.
         */
        filemap_sync(vma, start, len, MS_ASYNC);

        if (lower_vma->vm_ops->unmap)
                lower_vma->vm_ops->unmap(lower_vma, start, len);

        fist_dprint(6, "VM_S_UNMAP2: file 0x%x, lower_file 0x%x, file->f_count %d, lower_file->f_count %d\n",
                    (int) file, (int) lower_file,
                    (int) atomic_read(&file->f_count),
                    (int) atomic_read(&lower_file->f_count));
        print_exit_location();
}
Example #15
0
int
kdb3fs_d_delete(dentry_t *dentry)
{
	dentry_t *hidden_dentry;
	int err = 0;

	print_entry_location();
#if 0
	/* this could be a negative dentry, so check first */
	if (!dtopd(dentry)) {
		fist_dprint(6, "dentry without private data: %*s", dentry->d_name.len, dentry->d_name.name);
		goto out;
	}

	if (!(hidden_dentry = dtohd(dentry))) {
		fist_dprint(6, "dentry without hidden_dentry: %*s", dentry->d_name.len, dentry->d_name.name);
		goto out;
	}

	//    fist_print_dentry("D_DELETE IN", dentry);
	/* added b/c of changes to dput(): it calls d_drop on us */
	if (hidden_dentry->d_op &&
	    hidden_dentry->d_op->d_delete) {
		err = hidden_dentry->d_op->d_delete(hidden_dentry);
	}
#endif
out:
	print_exit_status(err);
	return err;
}
Example #16
0
static unsigned int unionfs_poll(struct file *file, poll_table * wait)
{
	unsigned int mask = DEFAULT_POLLMASK;
	struct file *hidden_file = NULL;

	print_entry_location();

	if (unionfs_file_revalidate(file, 0)) {
		/* We should pretend an error happend. */
		mask = POLLERR | POLLIN | POLLOUT;
		goto out;
	}

	if (ftopd(file) != NULL)
		hidden_file = ftohf(file);

	if (!hidden_file->f_op || !hidden_file->f_op->poll)
		goto out;

	mask = hidden_file->f_op->poll(hidden_file, wait);

      out:
	print_exit_status(mask);
	return mask;
}
Example #17
0
STATIC int
base0fs_permission(inode_t *inode, int mask, struct nameidata* nd)
{
        inode_t *lower_inode;
        int err;
	struct dentry *lower_dentry;
	struct vfsmount *lower_mount;
	FIST_ND_DECLARATIONS;

        print_entry_location();
        lower_inode = INODE_TO_LOWER(inode);

	if(nd)
	{
	    BUG_ON(!NAMEIDATA_TO_DENTRY(nd)); /* needed to find lower_dentry */
	    lower_dentry = base0fs_lower_dentry(NAMEIDATA_TO_DENTRY(nd));
	    lower_mount = DENTRY_TO_LVFSMNT(NAMEIDATA_TO_DENTRY(nd));
	    BUG_ON(!SUPERBLOCK_TO_PRIVATE(NAMEIDATA_TO_DENTRY(nd)->d_sb)); /* needed in FIST_ND_SAVE_ARGS macro */
	    FIST_ND_SAVE_ARGS(NAMEIDATA_TO_DENTRY(nd), lower_dentry, lower_mount);
	}

	err = permission(lower_inode, mask, nd);

	if(nd)
	{
	    FIST_ND_RESTORE_ARGS;
	}

out:
        print_exit_status(err);
        return err;
}
Example #18
0
/*
 * we don't really need kdb3fs_d_iput, because dentry_iput will call iput() if
 * kdb3fs_d_iput is not defined. We left this implemented for ease of
 * tracing/debugging.
 */
void
kdb3fs_d_iput(dentry_t *dentry, inode_t *inode)
{
	print_entry_location();
	iput(inode);
	print_exit_location();
}
Example #19
0
ssize_t unionfs_read(struct file * file, char *buf, size_t count, loff_t * ppos)
{
	int err = -EINVAL;
	struct file *hidden_file = NULL;
	loff_t pos = *ppos;

	print_entry_location();

	if ((err = unionfs_file_revalidate(file, 0)))
		goto out;

	fist_print_file("entering read()", file);

	PASSERT(ftopd(file));
	hidden_file = ftohf(file);
	PASSERT(hidden_file);

	if (!hidden_file->f_op || !hidden_file->f_op->read)
		goto out;

	err = hidden_file->f_op->read(hidden_file, buf, count, &pos);
	*ppos = pos;
	if (err >= 0) {
		/* atime should also be updated for reads of size zero or more */
		fist_copy_attr_atime(file->f_dentry->d_inode,
				     hidden_file->f_dentry->d_inode);
	}
	memcpy(&(file->f_ra), &(hidden_file->f_ra),
	       sizeof(struct file_ra_state));

      out:
	fist_print_file("leaving read()", file);
	print_exit_status(err);
	return err;
}
Example #20
0
int unionfs_ioctl_branchcount(struct file *file, unsigned int cmd,
			      unsigned long arg)
{
	int err = 0;
	int bstart, bend;
	int i;
	struct super_block *sb = file->f_dentry->d_sb;

	print_entry_location();

	bstart = sbstart(sb);
	bend = sbend(sb);

	err = bend + 1;
	if (!arg)
		goto out;

	for (i = bstart; i <= bend; i++) {
		if (put_user(branch_count(sb, i), ((int *)arg) + i)) {
			err = -EFAULT;
			goto out;
		}
	}

      out:
	print_exit_status(err);
	return err;
}
Example #21
0
static int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
{
	int err;
	struct file *hidden_file = NULL;

	print_entry_location();

	if ((err = unionfs_file_revalidate(file, 1)))
		goto out;

	PASSERT(ftopd(file));
	hidden_file = ftohf(file);

	err = -EINVAL;
	if (!hidden_file->f_op || !hidden_file->f_op->fsync)
		goto out;

	down(&hidden_file->f_dentry->d_inode->i_sem);
	err = hidden_file->f_op->fsync(hidden_file, hidden_file->f_dentry,
				       datasync);
	up(&hidden_file->f_dentry->d_inode->i_sem);

      out:
	print_exit_status(err);
	return err;
}
Example #22
0
/* FIST-LITE special version of mmap */
static int unionfs_mmap(struct file *file, struct vm_area_struct *vma)
{
	int err = 0;
	struct file *hidden_file = NULL;
	int willwrite;

	print_entry_location();

	/* This might could be deferred to mmap's writepage. */
	willwrite = ((vma->vm_flags | VM_SHARED | VM_WRITE) == vma->vm_flags);
	if ((err = unionfs_file_revalidate(file, willwrite)))
		goto out;

	PASSERT(ftopd(file));
	hidden_file = ftohf(file);

	err = -ENODEV;
	if (!hidden_file->f_op || !hidden_file->f_op->mmap)
		goto out;

	PASSERT(hidden_file);
	PASSERT(hidden_file->f_op);
	PASSERT(hidden_file->f_op->mmap);

	vma->vm_file = hidden_file;
	err = hidden_file->f_op->mmap(hidden_file, vma);
	get_file(hidden_file);	/* make sure it doesn't get freed on us */
	fput(file);		/* no need to keep extra ref on ours */

      out:
	print_exit_status(err);
	return err;
}
Example #23
0
/* BKL held by caller.
 * dentry->d_inode->i_sem down
 */
ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
{
	struct dentry *hidden_dentry = NULL;
	int err = -EOPNOTSUPP;
	char *encoded_list = NULL;

	print_entry_location();
	lock_dentry(dentry);

	hidden_dentry = dtohd(dentry);

	if (hidden_dentry->d_inode->i_op->listxattr) {
		encoded_list = list;
		down(&hidden_dentry->d_inode->i_sem);
		/* lock_kernel() already done by caller. */
		err =
		    hidden_dentry->d_inode->i_op->listxattr(hidden_dentry,
							    encoded_list, size);
		/* unlock_kernel() will be done by caller. */
		up(&hidden_dentry->d_inode->i_sem);
	}

	unlock_dentry(dentry);
	print_exit_status(err);
	return err;
}
Example #24
0
static int unionfs_file_readdir(struct file *file, void *dirent,
				filldir_t filldir)
{
	int err = -ENOTDIR;
	print_entry_location();
	print_exit_status(err);
	return err;
}
Example #25
0
void unionfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
#endif
{
	char *link;
	print_entry_location();
	link = nd_get_link(nd);
	KFREE(link);
	print_exit_location();
}
Example #26
0
/*
 * Rename all occurences of source except for the leftmost destination
 */
static int __rename_all(struct inode *old_dir, struct dentry *old_dentry,
			struct inode *new_dir, struct dentry *new_dentry,
			fd_set * success_mask, struct rename_info *info)
{
	int bindex;

	int err = 0;

	print_entry_location();

	/* Loop through all the branches from right to left and rename all
	 * instances of source to destination, except the leftmost destination
	 */
	for (bindex = info->old_bend; bindex >= info->old_bstart; bindex--) {
		/* We don't rename if there is no source. */
		if (dtohd_index(old_dentry, bindex) == NULL)
			continue;

		/* we rename the bstart of destination only at the last of
		 * all operations, so that we don't lose it on error
		 */
		if (info->clobber && (bindex == info->new_bstart))
			continue;

		DPUT(info->wh_old);
		info->bwh_old = bindex;
		/* We shouldn't have a handle on this if there is no inode. */
		err =
		    do_rename(old_dir, old_dentry, new_dir, new_dentry, bindex,
			      &info->wh_old);
		if (!err) {
			/* For reverting. */
			FD_SET(bindex, success_mask);
			/* So we know not to copyup on failures the right */
			info->rename_ok = bindex;
		} else if (IS_COPYUP_ERR(err)) {
			if (info->isdir) {
				err = -EXDEV;
				break;
			}

			/* we need a whiteout... */
			info->do_whiteout = bindex - 1;

			if (bindex == info->old_bstart)
				/* ...and a copyup */
				info->do_copyup = bindex - 1;

			err = 0;	/* reset error */
		} else
			break;	/* error is set by do_rename */
	}

	print_exit_status(err);
	return err;
}
Example #27
0
	/* buf is allocated here, and freed when VFS calls our put_link method */
	err = -ENOMEM;
        buf = KMALLOC(len, GFP_KERNEL);
        if (!buf)
                goto out;

        old_fs = get_fs();
        set_fs(KERNEL_DS);
        err = dentry->d_inode->i_op->readlink(dentry, buf, len);
        set_fs(old_fs);
        if (err < 0)
                goto out_free;

        buf[err] = 0;	// terminate the buffer -- XXX still needed?
	err = 0;
	nd_set_link(nd,buf);
	goto out;

out_free:
	KFREE(buf);
out:
#if 0
        if (err < 0) {
                dput(nd->dentry);
                printk("EZK follow_link() mnt_cnt %d\n", 
                        (int) atomic_read(&nd->mnt->mnt_count));
                mntput(nd->mnt);
        }
#endif

        print_exit_status(err);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
        return err;
#else /* 2.6.13 or newer */
        return ERR_PTR(err);
#endif /* 2.6.13 or newer */
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
void
base0fs_put_link(struct dentry *dentry, struct nameidata *nd)
#else /* 2.6.13 or newer */
void
base0fs_put_link(struct dentry *dentry, struct nameidata *nd, void* unused)
#endif /* 2.6.13 or newer */
{
        print_entry_location();

        KFREE(nd_get_link(nd));

        print_exit_location();
}
Example #28
0
/*
 * we now define delete_inode, because there are two VFS paths that may
 * destroy an inode: one of them calls clear inode before doing everything
 * else that's needed, and the other is fine.  This way we truncate the inode
 * size (and its pages) and then clear our own inode, which will do an iput
 * on our and the lower inode.
 */
static void unionfs_delete_inode(struct inode *inode)
{
	print_entry_location();

	fist_checkinode(inode, "unionfs_delete_inode IN");
	inode->i_size = 0;	/* every f/s seems to do that */
	clear_inode(inode);

	print_exit_location();
}
Example #29
0
static int unionfs_unlink_whiteout(struct inode *dir, struct dentry *dentry)
{
	struct dentry *hidden_dentry;
	struct dentry *hidden_dir_dentry;
	int bindex;
	int err = 0;

	print_entry_location();

	if ((err = unionfs_partial_lookup(dentry)))
		goto out;

	bindex = dbstart(dentry);

	hidden_dentry = dtohd_index(dentry, bindex);
	if (!hidden_dentry)
		goto out;

	hidden_dir_dentry = lock_parent(hidden_dentry);

	/* avoid destroying the hidden inode if the file is in use */
	DGET(hidden_dentry);
	if (!(err = is_robranch_super(dentry->d_sb, bindex)))
		err = vfs_unlink(hidden_dir_dentry->d_inode, hidden_dentry);
	DPUT(hidden_dentry);
	fist_copy_attr_times(dir, hidden_dir_dentry->d_inode);
	unlock_dir(hidden_dir_dentry);

	if (err) {
		if (!IS_COPYUP_ERR(err))
			goto out;
	}

	if (err) {
		if (dbstart(dentry) == 0) {
			goto out;
		}
		err = create_whiteout(dentry, dbstart(dentry) - 1);
	} else if (dbopaque(dentry) != -1) {
		/* There is a hidden lower-priority file with the same name. */
		err = create_whiteout(dentry, dbopaque(dentry));
	} else {
		err = create_whiteout(dentry, dbstart(dentry));
	}
      out:
	if (!err)
		dentry->d_inode->i_nlink--;
	/* We don't want to leave negative leftover dentries for revalidate. */
	if (!err && (dbopaque(dentry) != -1))
		update_bstart(dentry);

	print_exit_status(err);
	return err;

}
/*
 * we now define delete_inode, because there are two VFS paths that may
 * destroy an inode: one of them calls clear inode before doing everything
 * else that's needed, and the other is fine.  This way we truncate the inode
 * size (and its pages) and then clear our own inode, which will do an iput
 * on our and the lower inode.
 */
STATIC void
mini_fo_delete_inode(inode_t *inode)
{
	print_entry_location();

	fist_checkinode(inode, "mini_fo_delete_inode IN");
	inode->i_size = 0;		/* every f/s seems to do that */
	clear_inode(inode);

	print_exit_location();
}