dazuko-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dazuko-devel] patch for vanilla kernel 2.6.20


From: Lino Sanfilippo
Subject: [Dazuko-devel] patch for vanilla kernel 2.6.20
Date: Tue, 07 Jul 2009 17:12:17 +0200
User-agent: Icedove 1.5.0.14eol (X11/20090105)



Geschäftsführender Gesellschafter: Tjark Auerbach
Sitz der Gesellschaft: Tettnang
Handelsregister: Amtsgericht Ulm, HRB 630992
ALLGEMEINE GESCHÄFTSBEDINGUNGEN
Es gelten unsere Allgemeinen Geschäftsbedingungen
(AGB). Sie finden sie in der jeweils gültigen Fassung
im Internet unter http://www.avira.de/agb
***************************************************
diff -x CVS -rup dazukofs-3.0.0/CHANGELOG dazukofs-3.0.0-rc4_2.6.20/CHANGELOG
--- dazukofs-3.0.0/CHANGELOG    2009-02-22 17:51:22.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/CHANGELOG 2008-12-12 17:54:23.000000000 +0100
@@ -2,11 +2,6 @@
  DazukoFS CHANGELOG
 ====================
 
-3.0.0 (2009-02-22)
-- added define for version number output
-- added patches for various other kernels
-
-
 3.0.0-rc4 (2008-11-30)
 - fix incorrect dentry/vfsmnt referencing when access denied
 - fix improper cleanup in several error handling conditions
diff -x CVS -rup dazukofs-3.0.0/ctrl_dev.c dazukofs-3.0.0-rc4_2.6.20/ctrl_dev.c
--- dazukofs-3.0.0/ctrl_dev.c   2009-02-22 17:45:20.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/ctrl_dev.c        2008-12-12 17:54:23.000000000 
+0100
@@ -183,7 +183,7 @@ int dazukofs_ctrl_dev_init(int dev_major
 
        /* create control device */
        dev = device_create(dazukofs_class, NULL, MKDEV(dev_major, dev_minor),
-                           NULL, "%s.ctrl", DEVICE_NAME);
+                           "%s.ctrl", DEVICE_NAME);
        if (IS_ERR(dev)) {
                err = PTR_ERR(dev);
                goto error_out2;
diff -x CVS -rup dazukofs-3.0.0/dazukofs_fs.h 
dazukofs-3.0.0-rc4_2.6.20/dazukofs_fs.h
--- dazukofs-3.0.0/dazukofs_fs.h        2009-02-22 17:43:11.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/dazukofs_fs.h     2009-07-03 18:01:50.000000000 
+0200
@@ -3,7 +3,7 @@
    Copyright (C) 1997-2004 Erez Zadok
    Copyright (C) 2001-2004 Stony Brook University
    Copyright (C) 2004-2007 International Business Machines Corp.
-   Copyright (C) 2008-2009 John Ogness
+   Copyright (C) 2008 John Ogness
      Author: John Ogness <address@hidden>
 
    This program is free software; you can redistribute it and/or
@@ -24,8 +24,6 @@
 #ifndef __DAZUKOFS_FS_H
 #define __DAZUKOFS_FS_H
 
-#define DAZUKOFS_VERSION "3.0.0"
-
 extern struct kmem_cache *dazukofs_dentry_info_cachep;
 extern struct kmem_cache *dazukofs_file_info_cachep;
 extern struct file_operations dazukofs_main_fops;
diff -x CVS -rup dazukofs-3.0.0/dentry.c dazukofs-3.0.0-rc4_2.6.20/dentry.c
--- dazukofs-3.0.0/dentry.c     2009-02-22 17:44:22.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/dentry.c  2008-12-12 17:54:23.000000000 +0100
@@ -65,19 +65,19 @@ static int dazukofs_d_revalidate(struct 
 
        lower_mnt = GET_LOWER_MNT(dentry);
 
-       vfsmount_save = nd->path.mnt;
-       dentry_save = nd->path.dentry;
+       vfsmount_save = nd->mnt;
+       dentry_save = nd->dentry;
 
-       nd->path.mnt = mntget(lower_mnt);
-       nd->path.dentry = dget(lower_dentry);
+       nd->mnt = mntget(lower_mnt);
+       nd->dentry = dget(lower_dentry);
 
        valid = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
 
        mntput(lower_mnt);
        dput(lower_dentry);
 
-       nd->path.mnt = vfsmount_save;
-       nd->path.dentry = dentry_save;
+       nd->mnt = vfsmount_save;
+       nd->dentry = dentry_save;
 
        /* update the inode, even if d_revalidate() != 1 */
        if (dentry->d_inode) {
diff -x CVS -rup dazukofs-3.0.0/event.c dazukofs-3.0.0-rc4_2.6.20/event.c
--- dazukofs-3.0.0/event.c      2009-02-22 17:44:03.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/event.c   2009-07-03 18:56:39.000000000 +0200
@@ -23,7 +23,6 @@
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/mount.h>
-#include <linux/freezer.h>
 
 #include "dev.h"
 #include "dazukofs_fs.h"
@@ -113,21 +112,21 @@ int dazukofs_init_events(void)
        dazukofs_group_cachep =
                kmem_cache_create("dazukofs_group_cache",
                                  sizeof(struct dazukofs_group), 0,
-                                 SLAB_HWCACHE_ALIGN, NULL);
+                                 SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!dazukofs_group_cachep)
                goto error_out;
 
        dazukofs_event_container_cachep =
                kmem_cache_create("dazukofs_event_container_cache",
                                  sizeof(struct dazukofs_event_container), 0,
-                                 SLAB_HWCACHE_ALIGN, NULL);
+                                 SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!dazukofs_event_container_cachep)
                goto error_out;
 
        dazukofs_event_cachep =
                kmem_cache_create("dazukofs_event_cache",
                                  sizeof(struct dazukofs_event), 0,
-                                 SLAB_HWCACHE_ALIGN, NULL);
+                                 SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!dazukofs_event_cachep)
                goto error_out;
 
@@ -162,16 +161,23 @@ static int capture_group_count(int *cach
        return err;
 }
 
-static int get_group_count(void)
+static int get_group_count_interruptible(void)
 {
        int cache = 0;
-       int ret = wait_event_freezable(__group_count_queue,
-                                      capture_group_count(&cache) == 0);
+       int ret = wait_event_interruptible(__group_count_queue,
+                                          capture_group_count(&cache) == 0);
        if (ret == 0)
                ret = __group_count;
        return ret;
 }
 
+static int get_group_count(void)
+{
+       int cache = 0;
+       wait_event(__group_count_queue, capture_group_count(&cache) == 0);
+       return __group_count;
+}
+
 static void put_group_count(void)
 {
        mutex_lock(&group_count_mutex);
@@ -399,7 +405,7 @@ int dazukofs_add_group(const char *name,
        int already_exists;
        int available_id = 0;
        struct dazukofs_group *grp;
-       int grp_count = get_group_count();
+       int grp_count = get_group_count_interruptible();
 
        if (grp_count < 0) {
                ret = grp_count;
@@ -447,7 +453,7 @@ int dazukofs_remove_group(const char *na
        int ret = 0;
        struct dazukofs_group *grp;
        struct list_head *pos;
-       int grp_count = get_group_count();
+       int grp_count = get_group_count_interruptible();
 
        if (grp_count < 0) {
                ret = grp_count;
@@ -701,11 +707,10 @@ int dazukofs_check_access(struct dentry 
 {
        struct dazukofs_event_container *ec_array[GROUP_COUNT];
        struct dazukofs_event *evt;
-       int grp_count = get_group_count();
-       int err;
+       int grp_count;
+       int err = 0;
 
-       if (grp_count < 0)
-               return grp_count;
+       grp_count = get_group_count();
 
        if (check_access_precheck(grp_count)) {
                put_group_count();
@@ -713,32 +718,29 @@ int dazukofs_check_access(struct dentry 
        }
 
        /* at this point, the access should be handled */
-
        if (allocate_event_and_containers(&evt, ec_array, grp_count)) {
                put_group_count();
-               err = -ENOMEM;
-               goto out;
+               return -ENOMEM;
        }
-
        evt->dentry = dget(dentry);
        evt->mnt = mntget(mnt);
        evt->pid = current->pid;
-
        assign_event_to_groups(evt, ec_array);
 
        put_group_count();
 
-       /* wait until event completely processed or signal */
-       err = wait_event_freezable(evt->queue, event_assigned(evt) == 0);
+       /* wait until event completely processed */
+       wait_event(evt->queue, event_assigned(evt) == 0);
 
        if (evt->deny)
                err = -EPERM;
 
        release_event(evt, 0, 0);
-out:
+       
        return err;
 }
 
+
 int dazukofs_group_open_tracking(unsigned long group_id)
 {
        struct dazukofs_group *grp;
@@ -874,7 +876,8 @@ static struct dazukofs_event_container *
        /* move first todo-item to working list */
        mutex_lock(&work_mutex);
        if (!list_empty(&grp->todo_list.list)) {
-               ec = list_first_entry(&grp->todo_list.list,
+               struct list_head *head = &grp->todo_list.list;
+               ec = list_entry(head->next,
                                      struct dazukofs_event_container, list);
                list_del(&ec->list);
                list_add(&ec->list, &grp->working_list.list);
@@ -928,7 +931,8 @@ static int open_file(struct dazukofs_eve
        /* add myself to be ignored on file open (to avoid recursion) */
        mask_proc(&proc);
 
-       ec->file = dentry_open(dget(evt->dentry), mntget(evt->mnt), O_RDONLY);
+       ec->file = dentry_open(dget(evt->dentry), mntget(evt->mnt), 
+                              O_RDONLY | O_LARGEFILE);
        if (IS_ERR(ec->file)) {
                check_recursion();  /* remove myself from proc_list */
                ret = PTR_ERR(ec->file);
@@ -1004,9 +1008,9 @@ int dazukofs_get_event(unsigned long gro
        }
 
        while (1) {
-               ret = wait_event_freezable(grp->queue,
-                                          is_event_available(grp) ||
-                                          grp->deprecated);
+               ret = wait_event_interruptible(grp->queue,
+                                              is_event_available(grp) ||
+                                              grp->deprecated);
                if (ret != 0)
                        break;
 
diff -x CVS -rup dazukofs-3.0.0/file.c dazukofs-3.0.0-rc4_2.6.20/file.c
--- dazukofs-3.0.0/file.c       2009-02-22 17:43:11.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/file.c    2009-07-03 18:50:16.000000000 +0200
@@ -177,10 +177,11 @@ static int dazukofs_open(struct inode *i
        struct file *lower_file;
        int err;
 
-       err = dazukofs_check_access(file->f_dentry, file->f_vfsmnt);
-       if (err)
-               goto error_out1;
-
+       if (S_ISREG(inode->i_mode)) {
+               err = dazukofs_check_access(file->f_dentry, file->f_vfsmnt);
+               if (err)
+                       goto error_out1;
+       }       
        SET_FILE_INFO(file, kmem_cache_zalloc(dazukofs_file_info_cachep,
                      GFP_KERNEL));
        if (!GET_FILE_INFO(file)) {
@@ -272,6 +273,21 @@ out:
        return err;
 }
 
+static int dazukofs_mmap (struct file *file, struct vm_area_struct *vm)
+{
+
+       struct file *lower_file = GET_LOWER_FILE(file);
+
+       /* if lower fs does not support mmap(), we dont call 
generic_file_readonly_mmap(), 
+        * since this would result in calling lower readpage(), which might not 
be 
+        * defined by lower fs if mmap() is not supported*/
+       if (!lower_file->f_op || !lower_file->f_op->mmap) 
+               return -ENODEV;
+       
+
+       return generic_file_readonly_mmap(file, vm);
+}
+
 /**
  * Unused operations:
  *   - owner
@@ -295,18 +311,15 @@ out:
 struct file_operations dazukofs_main_fops = {
        .llseek         = dazukofs_llseek,
        .read           = dazukofs_read,
-       .aio_read       = generic_file_aio_read,
        .write          = dazukofs_write,
-       .aio_write      = generic_file_aio_write,
        .readdir        = dazukofs_readdir,
        .ioctl          = dazukofs_ioctl,
-       .mmap           = generic_file_mmap,
+       .mmap           = dazukofs_mmap,
        .open           = dazukofs_open,
        .flush          = dazukofs_flush,
        .release        = dazukofs_release,
        .fsync          = dazukofs_fsync,
        .fasync         = dazukofs_fasync,
-       .splice_read    = generic_file_splice_read,
 };
 
 /**
@@ -335,11 +348,10 @@ struct file_operations dazukofs_main_fop
 const struct file_operations dazukofs_dir_fops = {
        .readdir        = dazukofs_readdir,
        .ioctl          = dazukofs_ioctl,
-       .mmap           = generic_file_mmap,
+       .mmap           = dazukofs_mmap,
        .open           = dazukofs_open,
        .flush          = dazukofs_flush,
        .release        = dazukofs_release,
        .fsync          = dazukofs_fsync,
        .fasync         = dazukofs_fasync,
-       .splice_read    = generic_file_splice_read,
 };
diff -x CVS -rup dazukofs-3.0.0/group_dev.c 
dazukofs-3.0.0-rc4_2.6.20/group_dev.c
--- dazukofs-3.0.0/group_dev.c  2009-02-22 17:45:20.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/group_dev.c       2008-12-12 17:54:23.000000000 
+0100
@@ -210,7 +210,7 @@ int dazukofs_group_dev_init(int dev_majo
        /* create group devices */
        for (i = 0; i < GROUP_COUNT; i++) {
                dev = device_create(dazukofs_class, NULL,
-                                   MKDEV(dev_major, dev_minor_end), NULL,
+                                   MKDEV(dev_major, dev_minor_end),
                                    "%s.%d", DEVICE_NAME, i);
                if (IS_ERR(dev)) {
                        err = PTR_ERR(dev);
diff -x CVS -rup dazukofs-3.0.0/ign_dev.c dazukofs-3.0.0-rc4_2.6.20/ign_dev.c
--- dazukofs-3.0.0/ign_dev.c    2009-02-22 17:45:20.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/ign_dev.c 2008-12-12 17:54:23.000000000 +0100
@@ -144,7 +144,7 @@ int dazukofs_ign_dev_init(int dev_major,
        dazukofs_ign_cachep =
                kmem_cache_create("dazukofs_ign_cache",
                                  sizeof(struct dazukofs_proc), 0,
-                                 SLAB_HWCACHE_ALIGN, NULL);
+                                 SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (!dazukofs_ign_cachep) {
                err = -ENOMEM;
                goto error_out1;
@@ -159,7 +159,7 @@ int dazukofs_ign_dev_init(int dev_major,
 
        /* create ignore device */
        dev = device_create(dazukofs_class, NULL, MKDEV(dev_major, dev_minor),
-                           NULL, "%s.ign", DEVICE_NAME);
+                           "%s.ign", DEVICE_NAME);
        if (IS_ERR(dev)) {
                err = PTR_ERR(dev);
                goto error_out3;
diff -x CVS -rup dazukofs-3.0.0/inode.c dazukofs-3.0.0-rc4_2.6.20/inode.c
--- dazukofs-3.0.0/inode.c      2009-02-22 17:46:02.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/inode.c   2009-07-03 18:41:25.000000000 +0200
@@ -47,12 +47,25 @@ static int dazukofs_inode_test(struct in
 
 static void dazukofs_init_inode(struct inode *inode, struct inode *lower_inode)
 {
-       SET_LOWER_INODE(inode, lower_inode);
-       inode->i_ino = lower_inode->i_ino;
-       inode->i_version++;
-       inode->i_op = &dazukofs_main_iops;
-       inode->i_fop = &dazukofs_main_fops;
-       inode->i_mapping->a_ops = &dazukofs_aops;
+        SET_LOWER_INODE(inode, lower_inode);
+        inode->i_ino = lower_inode->i_ino;
+        inode->i_version++;
+
+        if (S_ISDIR(lower_inode->i_mode)) {
+                inode->i_op = &dazukofs_dir_iops;
+                inode->i_fop = &dazukofs_dir_fops;
+        } else {
+                inode->i_op = &dazukofs_main_iops;
+                inode->i_fop = &dazukofs_main_fops;
+
+                if (S_ISLNK(lower_inode->i_mode))
+                        inode->i_op = &dazukofs_symlink_iops;
+                else  if (special_file(lower_inode->i_mode)) {
+                        init_special_inode(inode, lower_inode->i_mode,
+                                           lower_inode->i_rdev);
+                }
+        }
+        inode->i_mapping->a_ops = &dazukofs_aops;
 }
 
 static int dazukofs_inode_set(struct inode *inode, void *lower_inode)
@@ -62,72 +75,125 @@ static int dazukofs_inode_set(struct ino
 }
 
 int dazukofs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
-                    struct super_block *sb, int flag)
+                    struct super_block *sb, int hash)
 {
        struct inode *inode;
-       struct inode *lower_inode = igrab(lower_dentry->d_inode);
-       int err = 0;
+       struct inode *lower_inode;
+       int err;
 
-       if (!lower_inode) {
-               err = -ESTALE;
-               goto out;
-       }
+       lower_inode = igrab(lower_dentry->d_inode);
 
-       if (lower_inode->i_sb != GET_LOWER_SB(sb)) {
-               iput(lower_inode);
-               err = -EXDEV;
-               goto out;
-       }
+       if (!lower_inode) 
+               return -ESTALE;
 
        inode = iget5_locked(sb, (unsigned long)lower_inode,
                             dazukofs_inode_test, dazukofs_inode_set,
                             lower_inode);
-
        if (!inode) {
-               iput(lower_inode);
                err = -EACCES;
-               goto out;
+               goto err;
        }
 
-       if (inode->i_state & I_NEW) {
+       if (inode->i_state & I_NEW) 
                unlock_new_inode(inode);
                /*
                 * This is a new node so we leave the lower_node "in use"
                 * and do not call iput().
                 */
-       } else {
+       else 
                /*
                 * This is not a new node so we decrement the usage count.
                 */
                iput(lower_inode);
-       }
 
-       if (S_ISLNK(lower_inode->i_mode))
-               inode->i_op = &dazukofs_symlink_iops;
-       else if (S_ISDIR(lower_inode->i_mode))
-               inode->i_op = &dazukofs_dir_iops;
-
-       if (S_ISDIR(lower_inode->i_mode))
-               inode->i_fop = &dazukofs_dir_fops;
-
-       if (special_file(lower_inode->i_mode)) {
-               init_special_inode(inode, lower_inode->i_mode,
-                                  lower_inode->i_rdev);
-       }
 
-       dentry->d_op = &dazukofs_dops;
-
-       if (flag)
+       if (hash)
                d_add(dentry, inode);
        else
                d_instantiate(dentry, inode);
 
        fsstack_copy_attr_all(inode, lower_inode, NULL);
        fsstack_copy_inode_size(inode, lower_inode);
-out:
+
+       return 0;
+err:
+       iput(lower_inode);
        return err;
 }
 
+
+/* creates a new lower dentry */
+static struct dentry *dazukofs_new_lower_dentry(struct qstr *name,
+                                               struct dentry *lower_base, 
+                                               struct nameidata *nd)
+{
+       struct dentry *new_dentry;
+       struct dentry *tmp;
+       struct inode *lower_inode;
+
+       lower_inode = lower_base->d_inode;
+       /* XXX: is this check still necessary? (see __lookup_hash())
+          This is (hopely) protected by locked upper inode */
+       if (IS_DEADDIR(lower_inode)) {
+               new_dentry = ERR_PTR(-ENOENT);
+               goto out;
+       }
+       tmp = d_alloc(lower_base, name);
+       if (!tmp) {
+               new_dentry = ERR_PTR(-ENOMEM);
+               goto out;
+       }
+       new_dentry = lower_inode->i_op->lookup(lower_inode, tmp, nd);
+       /* lookup() seemingly is allowed to return its own dentry (which 
+        * may indeed be a dentry or only an error). If so
+        * we use it and discard ours. Otherwise we use ours */ 
+       if (!new_dentry) 
+               new_dentry = tmp;
+       else 
+               dput(tmp);
+               
+out:           
+       return new_dentry;
+}
+
+
+/* get lower dentry for given name */
+static struct dentry *dazukofs_lookup_one_lower(struct qstr *name, 
+                                               struct dentry *lower_base,
+                                               struct vfsmount *lower_mnt)
+{
+       struct dentry *result;
+       struct nameidata nd;
+       int err;
+
+       /* see vfs_path_lookup in kernel versions >= 2.6.24 */
+       nd.last_type = LAST_ROOT;
+       nd.flags = 0;
+       nd.depth = 0;
+       nd.dentry = dget(lower_base);
+       nd.mnt = mntget(lower_mnt);
+
+       err = path_walk(name->name, &nd);
+
+       if (!err) {
+               /* inode already exists on disk */
+               result = nd.dentry;
+               /* we dont need the mount */
+               mntput(nd.mnt);
+               goto out;
+       }
+       if (err != -ENOENT) { /* this is a REAL error */        
+               result = ERR_PTR(err);
+               goto out;
+       }       
+       /* create a new (lower) dentry */
+       result = dazukofs_new_lower_dentry(name, lower_base, &nd);
+out:
+       return result;
+
+}
+
+
 /**
  * Description: Called when the VFS needs to look up an inode in a parent
  * directory. The name to look for is found in the dentry. This method
@@ -148,62 +214,48 @@ static struct dentry *dazukofs_lookup(st
        struct dentry *lower_dentry;
        struct dentry *lower_dentry_parent;
        struct vfsmount *lower_mnt;
-       int err = 0;
-
-       if ((dentry->d_name.len == 1 && !strcmp(dentry->d_name.name, "."))
-           || (dentry->d_name.len == 2 &&
-               !strcmp(dentry->d_name.name, ".."))) {
-               d_drop(dentry);
-               goto out;
-       }
-
-       dentry->d_op = &dazukofs_dops;
+       int err;
 
        lower_dentry_parent = GET_LOWER_DENTRY(dentry->d_parent);
-       lower_dentry = lookup_one_len(dentry->d_name.name, lower_dentry_parent,
-                                     dentry->d_name.len);
+       /* should be released in d_release() */
+       lower_mnt = mntget(GET_LOWER_MNT(dentry->d_parent));
 
+       lower_dentry = dazukofs_lookup_one_lower(&dentry->d_name, 
+                                                lower_dentry_parent, 
+                                                lower_mnt); 
        if (IS_ERR(lower_dentry)) {
-               err = PTR_ERR(lower_dentry);
-               d_drop(dentry);
-               goto out;
+               mntput(lower_mnt);
+               return lower_dentry;
        }
-
        BUG_ON(!atomic_read(&lower_dentry->d_count));
 
+       dentry->d_op = &dazukofs_dops;
        SET_DENTRY_INFO(dentry, kmem_cache_zalloc(dazukofs_dentry_info_cachep,
                        GFP_KERNEL));
 
        if (!GET_DENTRY_INFO(dentry)) {
-               err = -ENOMEM;
-               goto out_dput;
+               mntput(lower_mnt);
+               dput(lower_dentry);
+               return ERR_PTR(-ENOMEM);
        }
-
-       lower_mnt = mntget(GET_LOWER_MNT(dentry->d_parent));
-
-       fsstack_copy_attr_atime(dir, lower_dentry_parent->d_inode);
-
        SET_LOWER_DENTRY(dentry, lower_dentry, lower_mnt);
-
+       /* from now lower dentry and lower mount are released in 
+         d_release of upper dentry */
+       fsstack_copy_attr_atime(dir, lower_dentry_parent->d_inode);
        if (!lower_dentry->d_inode) {
                /*
                 * We want to add because we could not find in lower.
                 */
                d_add(dentry, NULL);
-               goto out;
+               goto ok;
        }
 
        err = dazukofs_interpose(lower_dentry, dentry, dir->i_sb, 1);
-       if (err)
-               goto out_dput;
-       goto out;
+       if (err) 
+               return ERR_PTR(err);
 
-out_dput:
-       dput(lower_dentry);
-       d_drop(dentry);
-
-out:
-       return ERR_PTR(err);
+ok:
+       return NULL; /* tell caller to use its own, passed dentry, not ours */
 }
 
 /**
@@ -294,19 +346,19 @@ static int dazukofs_create(struct inode 
        mutex_lock_nested(&(lower_dentry_parent_inode->i_mutex),
                          I_MUTEX_PARENT);
 
-       vfsmount_save = nd->path.mnt;
-       dentry_save = nd->path.dentry;
+       vfsmount_save = nd->mnt;
+       dentry_save = nd->dentry;
 
-       nd->path.mnt = mntget(lower_mnt);
-       nd->path.dentry = dget(lower_dentry);
+       nd->mnt = mntget(lower_mnt);
+       nd->dentry = dget(lower_dentry);
 
        err = vfs_create(lower_dentry_parent_inode, lower_dentry, mode, nd);
 
        mntput(lower_mnt);
        dput(lower_dentry);
 
-       nd->path.mnt = vfsmount_save;
-       nd->path.dentry = dentry_save;
+       nd->mnt = vfsmount_save;
+       nd->dentry = dentry_save;
 
        if (err)
                goto out;
@@ -340,7 +392,8 @@ static int dazukofs_symlink(struct inode
        mutex_lock_nested(&(lower_dentry_parent_inode->i_mutex),
                          I_MUTEX_PARENT);
 
-       err = vfs_symlink(lower_dentry_parent_inode, lower_dentry, symname);
+       err = vfs_symlink(lower_dentry_parent_inode, lower_dentry, symname,
+                         S_IALLUGO);
        if (err)
                goto out;
 
@@ -452,9 +505,37 @@ static void dazukofs_put_link(struct den
  * Description: Called by the VFS to check for access rights on a
  * POSIX-like filesystem.
  */
-static int dazukofs_permission(struct inode *inode, int mask)
+static int dazukofs_permission(struct inode *inode, int mask,
+                              struct nameidata *nd)
 {
-       return inode_permission(GET_LOWER_INODE(inode), mask);
+       struct vfsmount *lower_mnt = NULL;
+       struct dentry *lower_dentry = NULL;
+       struct vfsmount *vfsmnt_save = NULL;
+       struct dentry *dentry_save = NULL;
+       int err;
+
+       if (nd) {
+               lower_mnt = GET_LOWER_MNT(nd->dentry);
+               lower_dentry = GET_LOWER_DENTRY(nd->dentry);
+
+               vfsmnt_save = nd->mnt;
+               dentry_save = nd->dentry;
+
+               nd->mnt = mntget(lower_mnt);
+               nd->dentry = dget(lower_dentry);
+       }
+
+       err = permission(GET_LOWER_INODE(inode), mask, nd);
+
+       if (nd) {
+               mntput(lower_mnt);
+               dput(lower_dentry);
+
+               nd->mnt = vfsmnt_save;
+               nd->dentry = dentry_save;
+       }
+
+        return err;
 }
 
 /**
@@ -468,14 +549,27 @@ static int dazukofs_setattr(struct dentr
        struct inode *lower_inode = GET_LOWER_INODE(inode);
        int err;
 
-       err = notify_change(lower_dentry, ia);
 
-       fsstack_copy_attr_all(inode, lower_inode, NULL);
-       fsstack_copy_inode_size(inode, lower_inode);
+       if (!lower_inode->i_op || !lower_inode->i_op->setattr) 
+               /* XXX: at this point it is too late to handle inodes properly 
that do NOT
+               specify setattr(). VFS would normally call inode_setattr() in 
+               this case. So to force this we jump back to notify_change which 
will
+               handle this for us. But this is dangerous:
+               The attributes might be modified by notify_change() in a way
+               that results in invalid attributes. This seems to be the case
+               if the inode for which this function is called has the setuid
+               or setgid bit set */ 
+               err = notify_change(lower_dentry, ia);
+       else 
+               err = lower_inode->i_op->setattr(lower_dentry, ia);
+       
+       if (!err) {
+               fsstack_copy_attr_all(inode, lower_inode, NULL);
+               fsstack_copy_inode_size(inode, lower_inode);
+       } 
 
        return err;
 }
-
 /**
  * Description: Called by the VFS to set an extended attribute for a file.
  * Extended attribute is a name:value pair associated with an inode. This
@@ -496,7 +590,7 @@ static int dazukofs_setxattr(struct dent
 
        if (!lower_dentry_inode->i_op ||
            !lower_dentry_inode->i_op->setxattr) {
-               err = -ENOSYS;
+               err = -EOPNOTSUPP;
                goto out;
        }
 
@@ -528,7 +622,7 @@ static ssize_t dazukofs_getxattr(struct 
 
        if (!lower_dentry_inode->i_op ||
            !lower_dentry_inode->i_op->getxattr) {
-               err = -ENOSYS;
+               err = -EOPNOTSUPP;
                goto out;
        }
 
@@ -557,7 +651,7 @@ static ssize_t dazukofs_listxattr(struct
 
        if (!lower_dentry_inode->i_op ||
            !lower_dentry_inode->i_op->listxattr) {
-               err = -ENOSYS;
+               err = -EOPNOTSUPP;
                goto out;
        }
 
@@ -584,7 +678,7 @@ static int dazukofs_removexattr(struct d
 
        if (!lower_dentry_inode->i_op ||
            !lower_dentry_inode->i_op->removexattr) {
-               err = -ENOSYS;
+               err = -EOPNOTSUPP;
                goto out;
        }
 
diff -x CVS -rup dazukofs-3.0.0/Makefile dazukofs-3.0.0-rc4_2.6.20/Makefile
--- dazukofs-3.0.0/Makefile     2009-02-22 17:46:02.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/Makefile  2009-05-11 19:50:17.000000000 +0200
@@ -19,6 +19,7 @@ dazukofs_install: dazukofs_modules
 
 clean:
        rm -f Module.symvers
+       rm -f modules.order
        make -C $(DAZUKOFS_KERNEL_SRC) SUBDIRS="`pwd`" clean
 
 .PHONY: dazukofs_modules dazukofs_install clean
diff -x CVS -rup dazukofs-3.0.0/README dazukofs-3.0.0-rc4_2.6.20/README
--- dazukofs-3.0.0/README       2009-02-22 17:38:21.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/README    2008-12-12 17:54:23.000000000 +0100
@@ -21,10 +21,10 @@ NOTE: DazukoFS is completely separate fr
 =================
 
 Below are brief instructions to get DazukoFS compiled and running on a
-system with a Linux 2.6.28 kernel. You may need to manually adjust the
+system with a Linux 2.6.27 kernel. You may need to manually adjust the
 Makefile if you kernel sources are not in the default location.
-(Patches are provided for various other kernels. See the section below
-titled "PATCHING" for more information.)
+(A patch is provided to convert the DazukoFS code to support Linux
+2.6.26.)
 
 compile the kernel module
   # make
@@ -52,25 +52,6 @@ unmount DazukoFS
 
 
 
-==========
- PATCHING
-==========
-
-In the "patches" directory there are patches available to modify the
-DazukoFS code to fit various other kernels. For example, if you are
-running openSUSE 11.1 you can patch the code with the following
-command:
-
-$ patch -p1 < patches/patch-opensuse-11.1
-
-There should not be any errors. If there are errors, then the patch
-is broken and should be reported on the dazuko-devel mailing list.
-
-Once the code has been patched you can build the kernel module as
-described in the section "BUILD / INSTALL" above.
-
-
-
 =========
  TESTING
 =========
@@ -154,9 +135,6 @@ any problems.
  KNOWN ISSUES
 ==============
 
-- The kernel will crash if you attempt to mount DazukoFS to a file instead
-  of a directory. (The various kernel patches handle this error.)
-
 - DazukoFS does not support writing to memory mapped files. This should not
   cause the kernel to crash, but will instead result in the application
   failing to perform the writes (although mmap() will appear to be
diff -x CVS -rup dazukofs-3.0.0/super.c dazukofs-3.0.0-rc4_2.6.20/super.c
--- dazukofs-3.0.0/super.c      2009-02-22 17:46:02.000000000 +0100
+++ dazukofs-3.0.0-rc4_2.6.20/super.c   2009-07-03 17:58:04.000000000 +0200
@@ -35,6 +35,10 @@ static struct kmem_cache *dazukofs_sb_in
 struct kmem_cache *dazukofs_dentry_info_cachep;
 struct kmem_cache *dazukofs_file_info_cachep;
 
+
+#define DAZUKOFS_VERSION "3.0.0-rc4-avira-b2.6"
+
+
 static struct inode *dazukofs_alloc_inode(struct super_block *sb)
 {
        struct dazukofs_inode_info *inodei;
@@ -158,8 +162,8 @@ static int dazukofs_read_super(struct su
        if (err)
                return err;
 
-       lower_root = dget(nd.path.dentry);
-       lower_mnt = mntget(nd.path.mnt);
+       lower_root = dget(nd.dentry);
+       lower_mnt = mntget(nd.mnt);
 
        if (IS_ERR(lower_root)) {
                err = PTR_ERR(lower_root);
@@ -170,6 +174,10 @@ static int dazukofs_read_super(struct su
                err = -ENOENT;
                goto out_put;
        }
+       if (!S_ISDIR(lower_root->d_inode->i_mode)) {
+               err = -ENOENT;
+               goto out_put;
+       }
 
        SET_LOWER_SB(sb, lower_root->d_sb);
        sb->s_maxbytes = lower_root->d_sb->s_maxbytes;
@@ -184,7 +192,7 @@ out_put:
        dput(lower_root);
        mntput(lower_mnt);
 out:
-       path_put(&nd.path);
+       path_release(&nd);
        return err;
 }
 
@@ -213,15 +221,16 @@ static int dazukofs_get_sb(struct file_s
 
 out_abort:
        up_write(&sb->s_umount);
+       dput(sb->s_root);
        deactivate_super(sb);
 out:
        return err;
 }
 
-static void init_once(void *data)
+static void init_once(void *vptr, struct kmem_cache *cachep, unsigned long 
flags)
 {
        struct dazukofs_inode_info *inode_info =
-               (struct dazukofs_inode_info *)data;
+               (struct dazukofs_inode_info *)vptr;
 
        memset(inode_info, 0, sizeof(struct dazukofs_inode_info));
        inode_init_once(&(inode_info->vfs_inode));
@@ -256,7 +265,7 @@ static int init_caches(void)
                kmem_cache_create("dazukofs_inode_info_cache",
                                  sizeof(struct dazukofs_inode_info), 0,
                                  SLAB_HWCACHE_ALIGN,
-                                 init_once);
+                                 init_once, NULL);
        if (!dazukofs_inode_info_cachep)
                goto out_nomem;
 
@@ -264,7 +273,7 @@ static int init_caches(void)
                kmem_cache_create("dazukofs_sb_info_cache",
                                  sizeof(struct dazukofs_sb_info), 0,
                                  SLAB_HWCACHE_ALIGN,
-                                 NULL);
+                                 NULL, NULL);
        if (!dazukofs_sb_info_cachep)
                goto out_nomem;
 
@@ -272,7 +281,7 @@ static int init_caches(void)
                kmem_cache_create("dazukofs_dentry_info_cache",
                                  sizeof(struct dazukofs_dentry_info), 0,
                                  SLAB_HWCACHE_ALIGN,
-                                 NULL);
+                                 NULL, NULL);
        if (!dazukofs_dentry_info_cachep)
                goto out_nomem;
 
@@ -280,7 +289,7 @@ static int init_caches(void)
                kmem_cache_create("dazukofs_file_info_cache",
                                  sizeof(struct dazukofs_file_info), 0,
                                  SLAB_HWCACHE_ALIGN,
-                                 NULL);
+                                 NULL, NULL);
        if (!dazukofs_file_info_cachep)
                goto out_nomem;
 
@@ -305,7 +314,7 @@ static struct file_system_type dazukofs_
 
 static int __init init_dazukofs_fs(void)
 {
-       int err = 0;
+       int err;
 
        err = dazukofs_dev_init();
        if (err)
@@ -319,7 +328,7 @@ static int __init init_dazukofs_fs(void)
        if (err)
                goto error_out3;
 
-       printk(KERN_INFO "dazukofs: loaded, version=%s\n", DAZUKOFS_VERSION);
+       printk(KERN_INFO "dazukofs: loaded, version=" DAZUKOFS_VERSION "\n");
        return 0;
 
 error_out3:
@@ -335,7 +344,7 @@ static void __exit exit_dazukofs_fs(void
        unregister_filesystem(&dazukofs_fs_type);
        destroy_caches();
        dazukofs_dev_destroy();
-       printk(KERN_INFO "dazukofs: unloaded, version=%s\n", DAZUKOFS_VERSION);
+       printk(KERN_INFO "dazukofs: unloaded, version=" DAZUKOFS_VERSION "\n");
 }
 
 MODULE_AUTHOR("John Ogness");

reply via email to

[Prev in Thread] Current Thread [Next in Thread]