head	1.1;
access;
symbols
	LKML-branch:1.1.0.2;
locks; strict;
comment	@# @;


1.1
date	2006.10.12.07.27.08;	author jsipek;	state dead;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2006.10.12.07.27.08;	author jsipek;	state Exp;
branches;
next	;


desc
@@


1.1
log
@file 03-branchman was initially added on branch LKML-branch.
@
text
@@


1.1.2.1
log
@Try3, sent to akpm for inclusion in -mm
@
text
@a0 106
From jsipek@@cs.sunysb.edu Thu Oct 12 02:18:41 2006
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH 03 of 23][-mm] Unionfs: Branch management functionality
Message-Id: <75a3c4df97a0ae2690d5.1160633920@@thor.fsl.cs.sunysb.edu>
In-Reply-To: <patchbomb.1160633917@@thor.fsl.cs.sunysb.edu>
Date: Thu, 12 Oct 2006 02:18:40 -0400
From: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>
To: akpm@@osdl.org

From: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>

This patch contains the ioctls to increase the union generation and to query
which branch a file exists on.

Signed-off-by: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>
Signed-off-by: David Quigley <dquigley@@fsl.cs.sunysb.edu>
Signed-off-by: Erez Zadok <ezk@@cs.sunysb.edu>

---

1 file changed, 74 insertions(+)
fs/unionfs/branchman.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++

diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
new file mode 100644
--- /dev/null
+++ b/fs/unionfs/branchman.c
@@@@ -0,0 +1,74 @@@@
+/*
+ * Copyright (c) 2003-2006 Erez Zadok
+ * Copyright (c) 2003-2006 Charles P. Wright
+ * Copyright (c) 2005-2006 Josef 'Jeff' Sipek
+ * Copyright (c) 2005-2006 Junjiro Okajima
+ * Copyright (c) 2005      Arun M. Krishnakumar
+ * Copyright (c) 2004-2006 David P. Quigley
+ * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
+ * Copyright (c) 2003      Puja Gupta
+ * Copyright (c) 2003      Harikesavan Krishnan
+ * Copyright (c) 2003-2006 Stony Brook University
+ * Copyright (c) 2003-2006 The Research Foundation of State University of New York
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "union.h"
+
+int unionfs_ioctl_incgen(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct super_block *sb;
+	int gen;
+
+	sb = file->f_dentry->d_sb;
+
+	unionfs_write_lock(sb);
+
+	gen = atomic_inc_return(&stopd(sb)->usi_generation);
+
+	atomic_set(&dtopd(sb->s_root)->udi_generation, gen);
+	atomic_set(&itopd(sb->s_root->d_inode)->uii_generation, gen);
+
+	unionfs_write_unlock(sb);
+
+	return gen;
+}
+
+int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
+			    unsigned long arg)
+{
+	int err = 0;
+	fd_set branchlist;
+
+	int bstart = 0, bend = 0, bindex = 0;
+	struct dentry *dentry, *hidden_dentry;
+
+	dentry = file->f_dentry;
+	lock_dentry(dentry);
+	if ((err = unionfs_partial_lookup(dentry)))
+		goto out;
+	bstart = dbstart(dentry);
+	bend = dbend(dentry);
+
+	FD_ZERO(&branchlist);
+
+	for (bindex = bstart; bindex <= bend; bindex++) {
+		hidden_dentry = dtohd_index(dentry, bindex);
+		if (!hidden_dentry)
+			continue;
+		if (hidden_dentry->d_inode)
+			FD_SET(bindex, &branchlist);
+	}
+
+	err = copy_to_user((void __user *)arg, &branchlist, sizeof(fd_set));
+	if (err)
+		err = -EFAULT;
+
+out:
+	unlock_dentry(dentry);
+	return err < 0 ? err : bend;
+}
+


@

