Shaya Potter wrote:
Shaya Potter wrote:
Josef Sipek wrote:
On Wed, Jan 17, 2007 at 01:04:22PM -0500, Shaya Potter wrote:
Josef Sipek wrote:
On a more general level, what has higher priority a whiteout or a
file?
whiteout, if it's 'valid' (i.e. serves a purpose) to exist, as all
my code does is skip whiteout searching if it doesn't matter if it
exists.
If whiteout is the higher priority object, then readdir should not
display
the file created under these circumstances. => pushing the "problem" to
readdir :)
true, though readdir could ignore it in the right situations as well :)
I looked at unionfs_readdir() and am unsure how to get it to ignore
whiteouts that can be ignored, it should be in unionfs_filldir(), but
unsure how to do it (never really bothered much w/ the readdir code
before as it mostly worked just fine).
quick and dirty patch to handle readdir() and helper for rmdir(), unsure
if its correct, haven't tested throughly
Index: dirfops.c
===================================================================
RCS file: /home/spotter/unionfs/2/unionfs/unionfs/dirfops.c,v
retrieving revision 1.27
diff -u -r1.27 dirfops.c
--- dirfops.c 5 Jan 2007 04:05:56 -0000 1.27
+++ dirfops.c 17 Jan 2007 20:26:21 -0000
@@ -59,6 +59,16 @@
is_wh_entry = 1;
}
+ /* If we found a whiteout in a directory where it doesn't matter
+ * i.e. the last branch the dir exists in, ignore it, as otherwise
+ * it will whiteout a file that could exist in this dir
+ */
+
+ if (is_wh_entry
+ && (buf->rdstate->uds_bindex == buf->rdstate->uds_bend)) {
+ goto out;
+ }
+
found = find_filldir_node(buf->rdstate, name, namelen);
if (found)
@@ -131,6 +141,7 @@
}
}
bend = fbend(file);
+ uds->uds_bend = bend;
while (uds->uds_bindex <= bend) {
hidden_file = ftohf_index(file, uds->uds_bindex);
Index: dirhelper.c
===================================================================
RCS file: /home/spotter/unionfs/2/unionfs/unionfs/dirhelper.c,v
retrieving revision 1.33
diff -u -r1.33 dirhelper.c
--- dirhelper.c 28 Dec 2006 02:48:47 -0000 1.33
+++ dirhelper.c 17 Jan 2007 20:30:51 -0000
@@ -177,6 +177,14 @@
whiteout = 1;
}
+ /* If we found a whiteout in a directory where it doesn't matter
+ * i.e. the last branch the dir exists in, ignore it, as otherwise
+ * it will whiteout a file that could exist in this dir
+ */
+
+ if (whiteout && (buf->rdstate->uds_bindex == buf->rdstate->uds_bend))
+ goto out;
+
found = find_filldir_node(buf->rdstate, name, namelen);
/* If it was found in the table there was a previous whiteout. */
if (found)
@@ -235,6 +243,7 @@
err = -ENOMEM;
goto out;
}
+ buf->rdstate->uds_bend = bend;
/* Process the hidden directories with rdutil_callback as a filldir. */
for (bindex = bstart; bindex <= bend; bindex++) {
Index: unionfs.h
===================================================================
RCS file: /home/spotter/unionfs/2/unionfs/unionfs/unionfs.h,v
retrieving revision 1.209
diff -u -r1.209 unionfs.h
--- unionfs.h 26 Dec 2006 22:00:32 -0000 1.209
+++ unionfs.h 17 Jan 2007 20:26:30 -0000
@@ -195,6 +195,7 @@
unsigned int uds_cookie; /* The cookie, which is based off of
uii_rdversion */
unsigned int uds_offset; /* The entry we have returned. */
int uds_bindex;
+ int uds_bend;
loff_t uds_dirpos; /* The offset within the lower level directory.
*/
int uds_size; /* How big is the hash table? */
int uds_hashentries; /* How many entries have been inserted? */
_______________________________________________
unionfs mailing list
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs