Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[safe/jmp/linux-2.6] / fs / coda / dir.c
index 0c6c48c..4bb9d0a 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/coda_psdev.h>
 #include <linux/coda_fs_i.h>
 #include <linux/coda_cache.h>
-#include <linux/coda_proc.h>
 
 #include "coda_int.h"
 
@@ -60,7 +59,7 @@ static int coda_return_EIO(void)
 }
 #define CODA_EIO_ERROR ((void *) (coda_return_EIO))
 
-static struct dentry_operations coda_dentry_operations =
+static const struct dentry_operations coda_dentry_operations =
 {
        .d_revalidate   = coda_dentry_revalidate,
        .d_delete       = coda_dentry_delete,
@@ -87,7 +86,6 @@ const struct file_operations coda_dir_operations = {
        .read           = generic_read_dir,
        .readdir        = coda_readdir,
        .open           = coda_open,
-       .flush          = coda_flush,
        .release        = coda_release,
        .fsync          = coda_fsync,
 };
@@ -139,16 +137,19 @@ exit:
 }
 
 
-int coda_permission(struct inode *inode, int mask, struct nameidata *nd)
+int coda_permission(struct inode *inode, int mask)
 {
         int error = 0;
+
+       mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
  
        if (!mask)
                return 0; 
 
-       lock_kernel();
+       if ((mask & MAY_EXEC) && !execute_ok(inode))
+               return -EACCES;
 
-       coda_vfs_stat.permission++;
+       lock_kernel();
 
        if (coda_cache_check(inode, mask))
                goto out; 
@@ -206,7 +207,6 @@ static int coda_create(struct inode *dir, struct dentry *de, int mode, struct na
        struct coda_vattr attrs;
 
        lock_kernel();
-       coda_vfs_stat.create++;
 
        if (coda_isroot(dir) && coda_iscontrol(name, length)) {
                unlock_kernel();
@@ -246,7 +246,6 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, int mode)
        struct CodaFid newfid;
 
        lock_kernel();
-       coda_vfs_stat.mkdir++;
 
        if (coda_isroot(dir) && coda_iscontrol(name, len)) {
                unlock_kernel();
@@ -288,7 +287,6 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
        int error;
 
        lock_kernel();
-       coda_vfs_stat.link++;
 
        if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
                unlock_kernel();
@@ -320,10 +318,9 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
         const char *name = de->d_name.name;
        int len = de->d_name.len;
        int symlen;
-        int error=0;
-        
+       int error = 0;
+
        lock_kernel();
-       coda_vfs_stat.symlink++;
 
        if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
                unlock_kernel();
@@ -353,14 +350,13 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
 }
 
 /* destruction routines: unlink, rmdir */
-int coda_unlink(struct inode *dir, struct dentry *de)
+static int coda_unlink(struct inode *dir, struct dentry *de)
 {
         int error;
        const char *name = de->d_name.name;
        int len = de->d_name.len;
 
        lock_kernel();
-       coda_vfs_stat.unlink++;
 
        error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
        if ( error ) {
@@ -374,14 +370,13 @@ int coda_unlink(struct inode *dir, struct dentry *de)
        return 0;
 }
 
-int coda_rmdir(struct inode *dir, struct dentry *de)
+static int coda_rmdir(struct inode *dir, struct dentry *de)
 {
        const char *name = de->d_name.name;
        int len = de->d_name.len;
        int error;
 
        lock_kernel();
-       coda_vfs_stat.rmdir++;
 
        error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
        if (!error) {
@@ -408,7 +403,6 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
        int error;
 
        lock_kernel();
-       coda_vfs_stat.rename++;
 
        error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
                             coda_i2f(new_dir), old_length, new_length,
@@ -435,7 +429,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 
 /* file operations for directories */
-int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
+static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
 {
        struct coda_file_info *cfi;
        struct file *host_file;
@@ -445,8 +439,6 @@ int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
        BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
        host_file = cfi->cfi_container;
 
-       coda_vfs_stat.readdir++;
-
        if (!host_file->f_op)
                return -ENOTDIR;
 
@@ -522,20 +514,20 @@ static int coda_venus_readdir(struct file *coda_file, void *buf,
        vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
        if (!vdir) return -ENOMEM;
 
-       switch (coda_file->f_pos) {
-       case 0:
+       if (coda_file->f_pos == 0) {
                ret = filldir(buf, ".", 1, 0, de->d_inode->i_ino, DT_DIR);
-               if (ret < 0) break;
+               if (ret < 0)
+                       goto out;
                result++;
                coda_file->f_pos++;
-               /* fallthrough */
-       case 1:
+       }
+       if (coda_file->f_pos == 1) {
                ret = filldir(buf, "..", 2, 1, de->d_parent->d_inode->i_ino, DT_DIR);
-               if (ret < 0) break;
+               if (ret < 0)
+                       goto out;
                result++;
                coda_file->f_pos++;
-               /* fallthrough */
-       default:
+       }
        while (1) {
                /* read entries from the directory file */
                ret = kernel_read(host_file, coda_file->f_pos - 2, (char *)vdir,
@@ -590,7 +582,7 @@ static int coda_venus_readdir(struct file *coda_file, void *buf,
                 * we've already established it is non-zero. */
                coda_file->f_pos += vdir->d_reclen;
        }
-       }
+out:
        kfree(vdir);
        return result ? result : ret;
 }