commit 8a514bc403aa741ede5ef8cba36ccdb7fea77836
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Fri Apr 13 17:57:32 2007 -0400

    /odf/sb a file instead of a dir

diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index ec6be92..b31f377 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -30,7 +30,7 @@ out:
  */
 int __odf_create_hierarchy(struct dentry *odf_root)
 {
-       struct dentry *dentry = NULL, *dentry_wh = NULL;
+       struct dentry *dentry = NULL;
        int err = 0;
 
        dentry = __odf_create_dir(odf_root, ODF_NS);
@@ -54,28 +54,21 @@ int __odf_create_hierarchy(struct dentry *odf_root)
                goto out;
        }
        dput(dentry);
-       dentry = __odf_create_dir(odf_root, ODF_SB);
-       if (IS_ERR(dentry)){
+       dentry = lookup_one_len(ODF_WH_NAME, odf_root, ODF_WH_LEN);
+       if (IS_ERR(dentry)) {
                err = PTR_ERR(dentry);
                dentry = NULL;
                goto out;
        }
-       dentry_wh = lookup_one_len(ODF_WH_NAME, dentry, ODF_WH_LEN);
-       if (IS_ERR(dentry_wh)) {
-               err = PTR_ERR(dentry_wh);
-               dentry_wh = NULL;
-               goto out;
-       }
-       if (unlikely(dentry_wh->d_inode)){
+       if (unlikely(dentry->d_inode)){
                err = -EINVAL;
                goto out;
        }
-       err = vfs_create(dentry->d_inode, dentry_wh, S_IRWXUGO, NULL );
+       err = vfs_create(odf_root->d_inode, dentry, S_IRWXUGO, NULL );
        if (err)
                goto out;
 out:
        dput(dentry);
-       dput(dentry_wh);
        return err;
 }
 
@@ -90,7 +83,7 @@ struct odf_sb_info* odf_read_super(char *options)
        struct odf_sb_info *osi = NULL;
        char *odffile = NULL;
        struct sioa_args *sioa;
-       int err, odfforce, new = 0;
+       int err, odfforce;
        
        odfforce = odf_parse_options(options, &odffile);
        if (odfforce < 0) {
@@ -118,22 +111,22 @@ struct odf_sb_info* odf_read_super(char *options)
                goto out_release;
        }
 
-       osi->odi_sb = odf_getpath(nd.dentry, osi, ODF_SB);
-       if (IS_ERR(osi->odi_sb)){
-               osi->odi_sb = NULL;
-       
+       osi->sb = lookup_one_len(ODF_SB, nd.dentry, strlen(ODF_SB));
+       if (IS_ERR(osi->sb)) {
+               err = PTR_ERR(osi->sb);
+               osi->sb = NULL;
+               goto out_free;
+       }
+       if (osi->sb->d_inode && !S_ISREG(osi->sb->d_inode->i_mode)) {
+               err = -EINVAL;
+               goto out_free;
+       }
+
+       if (odf_is_new(osi)) {  
                /* if this odf is fresh, create the hierarchy */
                err = __odf_create_hierarchy(nd.dentry);
                if (err)
                        goto out_free;
-               new = 1;
-
-               osi->odi_sb = odf_getpath(nd.dentry, osi, ODF_SB);
-               if (IS_ERR(osi->odi_sb)){
-                       err = PTR_ERR(osi->odi_sb);
-                       osi->odi_sb = NULL;
-                       goto out_free;
-               }
        }
 
        osi->odi_ns = odf_getpath(nd.dentry, osi, ODF_NS);
@@ -157,7 +150,7 @@ struct odf_sb_info* odf_read_super(char *options)
                goto out_free;
        }
 
-       osi->whiteout = lookup_one_len(ODF_WH_NAME, osi->odi_sb->dentry, 
ODF_WH_LEN);
+       osi->whiteout = lookup_one_len(ODF_WH_NAME, nd.dentry, ODF_WH_LEN);
        if (IS_ERR(osi->whiteout)) {
                err = PTR_ERR(osi->whiteout);
                osi->whiteout = NULL;
@@ -168,12 +161,6 @@ struct odf_sb_info* odf_read_super(char *options)
                goto out_free;
        }
 
-       /* if this odf was not fresh, but doesn't have sb/content, then fail */
-       if (!new && odf_is_new(osi)) {
-               err = -EINVAL;
-               goto out_free;
-       }
-
        /* start the reclaim sioa */
        sioa = kmalloc(sizeof(struct sioa_args), GFP_KERNEL);
        if (!sioa) {
@@ -193,8 +180,8 @@ struct odf_sb_info* odf_read_super(char *options)
 out_free:
        odf_put_info(osi->odi_ns);
        odf_put_info(osi->odi_rc);
-       odf_put_info(osi->odi_sb);
        odf_put_info(osi->odi_ic);
+       dput(osi->sb);
        dput(osi->whiteout);
        kfree(osi->branch_uuids);
        kfree(osi);
@@ -215,9 +202,9 @@ void odf_put_super(struct odf_sb_info *osi)
 {
        /* do not put ns here, as it will be put by root of UnionFs*/
        odf_put_info(osi->odi_rc);
-       odf_put_info(osi->odi_sb);
        odf_put_info(osi->odi_ic);
        dput(osi->mnt->mnt_sb->s_root);
+       dput(osi->sb);
        dput(osi->whiteout);
        mntput(osi->mnt);
        if (osi->cleanup)
@@ -1779,22 +1766,14 @@ int __odf_set_opaque(struct dentry *d, int branch)
 }
 
 /* 
- * checks the sb/content file exists 
+ * checks if the /odf/sb file exists 
  */
 int odf_is_new(struct odf_sb_info *osi)
 {
-       struct dentry *dentry;
-
-       /* check if sb/content exists */
-       dentry = lookup_one_len(ODF_CONTENT, osi->odi_sb->dentry, 
ODF_CONTENT_LEN);
-       if (IS_ERR(dentry) || !dentry)
+       if (!osi->sb)
                return 1;
-       else if (unlikely(!dentry->d_inode)) {
-               dput(dentry);
+       else if (unlikely(!osi->sb->d_inode))
                return 1;
-       }
-
-       dput(dentry);
        return 0;
 }
 
@@ -1933,7 +1912,7 @@ out:
  */
 int odf_write_sb_data(struct odf_sb_info* osi, struct unionfs_data *data, 
struct path *lower_paths, int branches)
 {
-       struct dentry *d, *d_odf_sb, *d_content;
+       struct dentry *d, *d_content;
        struct vfsmount *m, *odf_mnt;
        struct file *file;
        char *name, *uuid;
@@ -1950,10 +1929,9 @@ int odf_write_sb_data(struct odf_sb_info* osi, struct 
unionfs_data *data, struct
                goto out;
        }
 
-       d_odf_sb = osi->odi_sb->dentry;
        odf_mnt = osi->mnt;
 
-       d_content = lookup_one_len(ODF_CONTENT, d_odf_sb, ODF_CONTENT_LEN);
+       d_content = osi->sb;
        if (IS_ERR(d_content) || !d_content) {
                err = -EINVAL;
                goto out;
@@ -1969,7 +1947,7 @@ int odf_write_sb_data(struct odf_sb_info* osi, struct 
unionfs_data *data, struct
                }
        }
        else {
-               err = vfs_create(d_odf_sb->d_inode, d_content, S_IRWXUGO, NULL 
);
+               err = vfs_create(d_content->d_parent->d_inode, d_content, 
S_IRWXUGO, NULL );
                if (err)
                        goto out;
        }
@@ -2093,7 +2071,7 @@ char *odf_read_sb_data(struct odf_sb_info *odf_sb, int 
**bid)
        sprintf(ptr,"dirs=");
        ptr+=strlen(ptr);
 
-       d_content = lookup_one_len(ODF_CONTENT, odf_sb->odi_sb->dentry, 
ODF_CONTENT_LEN);
+       d_content = odf_sb->sb;
        if (IS_ERR(d_content) || !d_content) {
                err = -EINVAL;
                goto out_err;
@@ -2288,7 +2266,7 @@ void __odf_cleanup(void *args)
        odf_lock(cl->odf->odi_ic);
        odf_lock(cl->odf->odi_rc);
 
-       vfs_statfs(cl->odf->odi_sb->dentry, &stat);
+       vfs_statfs(cl->odf->sb, &stat);
        if (cl->force) {
                cl->force = 0;
                cleanup = ODF_CLEAN_CACHE;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 5e1148a..214b37e 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -106,12 +106,12 @@ struct odf_dentry_info {
 struct odf_sb_info {
        struct vfsmount *mnt;           /* odf vmsmount */
        struct odf_dentry_info *odi_ns; /* namespace (/ns) */
-       struct odf_dentry_info *odi_sb; /* superblock (/sb) */
        struct odf_dentry_info *odi_rc; /* reclaim (/reclaim) */
        struct odf_dentry_info *odi_ic; /* inode cache (/ic) */
        struct sioa_args *cleanup;      /* our cleanup thread */
        char *branch_uuids;   /* not null terminated string of all branch 
uuids*/
        int opaque_branch_id; /* should always be the branch id of branch 0*/
+       struct dentry *sb;              /* superblock (/sb) */
        struct dentry *whiteout;
 };
 
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to