commit 55babf632ac061e9c8217ac79f41e677b6613e57
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Sun Feb 4 18:53:27 2007 -0500

    persistent inodes

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index b43ce4f..b9c3c7b 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -91,7 +91,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, 
struct nameidata *n
        char *whname = NULL;
        const char *name;
        int namelen;
-
+       
        /* We should already have a lock on this dentry in the case of a
         * partial lookup, or a revalidation. Otherwise it is returned from
         * new_dentry_private_data already locked.
@@ -124,7 +124,6 @@ struct dentry *unionfs_lookup_backend(struct dentry 
*dentry, struct nameidata *n
 
        name = dentry->d_name.name;
        namelen = dentry->d_name.len;
-
        /* No dentries should get created for possible whiteout names. */
        if (!is_validname(name)) {
                err = -EPERM;
@@ -334,7 +333,7 @@ out_positive:
        unionfs_mntput(first_dentry, first_dentry_offset);
 
        /* check odf */
-       UNIONFS_D(dentry)->dodf = odf_lookup(parent_dentry, dentry);
+       UNIONFS_D(dentry)->dodf = odf_lookup(parent_dentry, dentry, 0);
 
        /* Partial lookups need to reinterpose, or throw away older negs. */
        if (lookupmode == INTERPOSE_PARTIAL) {
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 7ebeff0..d18de43 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -27,7 +27,7 @@ int unionfs_interpose(struct dentry *dentry, struct 
super_block *sb, int flag)
        struct dentry *hidden_dentry;
        int err = 0;
        struct inode *inode;
-       int is_negative_dentry = 1;
+       int is_negative_dentry = 1, odf_flag = ODF_LOOKUP_FILE;
        int bindex, bstart, bend;
 
        verify_locked(dentry);
@@ -40,6 +40,8 @@ int unionfs_interpose(struct dentry *dentry, struct 
super_block *sb, int flag)
                if (unionfs_lower_dentry_idx(dentry, bindex) &&
                    unionfs_lower_dentry_idx(dentry, bindex)->d_inode) {
                        is_negative_dentry = 0;
+                       if (S_ISDIR(unionfs_lower_dentry_idx(dentry, 
bindex)->d_inode->i_mode))
+                               odf_flag = ODF_LOOKUP_DIR;
                        break;
                }
        }
@@ -67,8 +69,12 @@ int unionfs_interpose(struct dentry *dentry, struct 
super_block *sb, int flag)
                        goto out;
                }
        } else {
+               ino_t ino;
+
                /* get unique inode number for unionfs */
-               
+               if ( !UNIONFS_D(dentry)->dodf )
+                       UNIONFS_D(dentry)->dodf = odf_lookup(dentry->d_parent, 
dentry, odf_flag);
+
                ino = UNIONFS_D(dentry)->dodf->d_inode->i_ino;
 
                inode = iget(sb, ino);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 745eada..c12eef2 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -72,12 +72,16 @@ out:
        else check for whiteouts
        Handle hard links
 */
-struct dentry *odf_lookup(struct dentry *parent, struct dentry *dentry)
+struct dentry *odf_lookup(struct dentry *parent, struct dentry *dentry, int 
flags)
 {
        struct dentry *res = NULL;
-       struct nameidata nd;
        int err = 0;
 
+       if ( UNIONFS_D(dentry)->dodf ) {
+               dput(UNIONFS_D(dentry)->dodf);
+               UNIONFS_D(dentry)->dodf = NULL;
+       }
+
        res = lookup_one_len(dentry->d_name.name, 
                                UNIONFS_D(parent)->dodf,
                                dentry->d_name.len);
@@ -85,20 +89,26 @@ struct dentry *odf_lookup(struct dentry *parent, struct 
dentry *dentry)
        /* create inode in odf if dont exist */
        /* XXX: should we fail if res is ERR? */
        if (  IS_ERR(res) || !res->d_inode ) {
-               if ( dentry->d_inode )
-                       err = vfs_create(UNIONFS_D(parent)->dodf->d_inode, 
-                               res, 
-                               dentry->d_inode->i_mode, &nd );
-               else
-                       err = vfs_create(UNIONFS_D(parent)->dodf->d_inode, 
-                               res, 0, &nd); 
+               
+               /* FIXME need to check hardlinks before create */
+               if ( flags & ODF_LOOKUP_FILE )
+                       err = vfs_create(UNIONFS_D(parent)->dodf->d_inode, res, 
S_IRWXUGO, 0 );
+
+               else if ( flags & ODF_LOOKUP_DIR )
+                       err = vfs_mkdir(UNIONFS_D(parent)->dodf->d_inode, res, 
S_IRWXUGO);
+
+               else {
+                       dput(res);
+                       res = NULL;
+               }
+
                /* XXX */
                if ( err ) {
                        printk(KERN_WARNING "could not create odf dentry" );
                }
        }
        else {
-               /* check for whiteout */
+               /* FIXME check for whiteouts & hardlinks */
        }
        return res;
 }
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index 066f9b4..7d24e8d 100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -1,18 +1,24 @@
 #ifndef _ODF_H_
 #define _ODF_H_
 
+
 #define ODF_MOUNT "/mnt/odf/"
 #define ODF_SB ODF_MOUNT "sb/"
 #define ODF_IC ODF_MOUNT "ic/"
 #define ODF_RC ODF_MOUNT "reclaim/"
-#define ODF_NS "/mnt/odf/ns/"
+#define ODF_NS ODF_MOUNT "ns/"
 #define ODF_NEWBIT ODF_SB "newbit"
 
+/* Lookup flags (what to create if lookup fails) */
+#define ODF_LOOKUP_FILE        1 
+#define ODF_LOOKUP_DIR 2
+
 struct vfsmount* odf_read_super(char *odffile);
 void odf_put_super(struct super_block *sb);
 int odf_is_new(int unset);
 char *odf_getoptions(void);
 int odf_putoptions(struct super_block* sb_union, struct unionfs_dentry_info 
*hidden_root);
-struct dentry *odf_lookup(struct dentry *parent, struct dentry *dentry);
+struct dentry *odf_lookup(struct dentry *parent, struct dentry *dentry, int 
flags);
 struct dentry *odf_getns(void);
+
 #endif /* _ODF_H_ */
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to