]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Coda updates [3/5]
authorJan Harkes <jaharkes@cs.cmu.edu>
Tue, 16 Sep 2003 10:33:32 +0000 (03:33 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Tue, 16 Sep 2003 10:33:32 +0000 (03:33 -0700)
Both userspace and the kernel are testing only the fsuid part of the
coda_creds credentials structure. Nothing else is really used, so we now
match the code with the actual usage by only passing fsuid around. The
kernel-userspace API is kept compatible (for now).

fs/coda/cache.c
fs/coda/coda_linux.c
fs/coda/file.c
fs/coda/inode.c
fs/coda/upcall.c
include/linux/coda_fs_i.h
include/linux/coda_linux.h
include/linux/coda_psdev.h

index e407c1b9212be430cb9023267316889fe50dafff..80072fd9b7faf6a6c21747d65ffc6bb2c65e8cbd 100644 (file)
@@ -31,8 +31,8 @@ void coda_cache_enter(struct inode *inode, int mask)
        struct coda_inode_info *cii = ITOC(inode);
 
        cii->c_cached_epoch = atomic_read(&permission_epoch);
-        if ( !coda_cred_ok(&cii->c_cached_cred) ) {
-                coda_load_creds(&cii->c_cached_cred);
+       if (cii->c_uid != current->fsuid) {
+                cii->c_uid = current->fsuid;
                 cii->c_cached_perm = mask;
         } else
                 cii->c_cached_perm |= mask;
@@ -64,8 +64,8 @@ int coda_cache_check(struct inode *inode, int mask)
         int hit;
        
         hit = (mask & cii->c_cached_perm) == mask &&
-           coda_cred_ok(&cii->c_cached_cred) &&
-           cii->c_cached_epoch == atomic_read(&permission_epoch);
+               cii->c_uid == current->fsuid &&
+               cii->c_cached_epoch == atomic_read(&permission_epoch);
 
         return hit;
 }
index 4ab24ea7b49d037bb6651c2c8a17299dd0f1ae6b..b07d3b8c1a262221e07e9f8488be649ee853b48f 100644 (file)
@@ -45,30 +45,6 @@ int coda_isroot(struct inode *i)
     return ( i->i_sb->s_root->d_inode == i );
 }
 
-/* put the current process credentials in the cred */
-void coda_load_creds(struct coda_cred *cred)
-{
-        cred->cr_uid = (vuid_t) current->uid;
-        cred->cr_euid = (vuid_t) current->euid;
-        cred->cr_suid = (vuid_t) current->suid;
-        cred->cr_fsuid = (vuid_t) current->fsuid;
-
-        cred->cr_groupid = (vgid_t) current->gid;
-        cred->cr_egid = (vgid_t) current->egid;
-        cred->cr_sgid = (vgid_t) current->sgid;
-        cred->cr_fsgid = (vgid_t) current->fsgid;
-}
-
-int coda_cred_ok(struct coda_cred *cred)
-{
-       return(current->fsuid == cred->cr_fsuid);
-}
-
-int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2)
-{
-       return (cred1->cr_fsuid == cred2->cr_fsuid);
-}
-
 unsigned short coda_flags_to_cflags(unsigned short flags)
 {
        unsigned short coda_flags = 0;
index 8d4865cbc91aa6ac98dd4892bf856ddcc15ee289..f9b00cc2959fdb5f5d0e2442150afaafb06c173e 100644 (file)
@@ -136,7 +136,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
        cfi->cfi_magic = CODA_MAGIC;
        cfi->cfi_mapcount = 0;
        cfi->cfi_container = host_file;
-       coda_load_creds(&cfi->cfi_cred);
 
        BUG_ON(coda_file->private_data != NULL);
        coda_file->private_data = cfi;
@@ -176,7 +175,7 @@ int coda_flush(struct file *coda_file)
        coda_inode = coda_file->f_dentry->d_inode;
 
        err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
-                         &cfi->cfi_cred);
+                         coda_file->f_uid);
 
        if (err == -EOPNOTSUPP) {
                use_coda_close = 1;
@@ -214,7 +213,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
 
        if (use_coda_close)
                err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
-                                 coda_flags, &cfi->cfi_cred);
+                                 coda_flags, coda_file->f_uid);
 
        host_inode = cfi->cfi_container->f_dentry->d_inode;
        cii = ITOC(coda_inode);
index 1fb16b79dd0f40a34de64cdd9c88310e93d3904c..0d057e81385ac767546bd9bc5deff15c85fe82b4 100644 (file)
@@ -46,7 +46,7 @@ static struct inode *coda_alloc_inode(struct super_block *sb)
                return NULL;
        memset(&ei->c_fid, 0, sizeof(struct ViceFid));
        ei->c_flags = 0;
-       memset(&ei->c_cached_cred, 0, sizeof(struct coda_cred));
+       ei->c_uid = 0;
        ei->c_cached_perm = 0;
        return &ei->vfs_inode;
 }
index 308014e0f15bdf4d348dce0c062948b2d9bf4892..e9f15ae6e1b5ecdfdb43d591ca36735ba7c0844c 100644 (file)
@@ -55,7 +55,8 @@ static void *alloc_upcall(int opcode, int size)
         inp->ih.opcode = opcode;
        inp->ih.pid = current->pid;
        inp->ih.pgid = current->pgrp;
-       coda_load_creds(&(inp->ih.cred));
+       memset(&inp->ih.cred, 0, sizeof(struct coda_cred));
+       inp->ih.cred.cr_fsuid = current->fsuid;
 
        return (void*)inp;
 }
@@ -163,16 +164,18 @@ int venus_lookup(struct super_block *sb, struct ViceFid *fid,
 }
 
 int venus_store(struct super_block *sb, struct ViceFid *fid, int flags,
-                struct coda_cred *cred)
+                vuid_t uid)
 {
         union inputArgs *inp;
         union outputArgs *outp;
         int insize, outsize, error;
+       struct coda_cred cred = { 0, };
+       cred.cr_fsuid = uid;
        
        insize = SIZE(store);
        UPARG(CODA_STORE);
        
-       memcpy(&(inp->ih.cred), cred, sizeof(*cred));
+       memcpy(&(inp->ih.cred), &cred, sizeof(cred));
        
         inp->coda_store.VFid = *fid;
         inp->coda_store.flags = flags;
@@ -202,16 +205,18 @@ int venus_release(struct super_block *sb, struct ViceFid *fid, int flags)
 }
 
 int venus_close(struct super_block *sb, struct ViceFid *fid, int flags,
-                struct coda_cred *cred)
+                vuid_t uid)
 {
        union inputArgs *inp;
        union outputArgs *outp;
        int insize, outsize, error;
+       struct coda_cred cred = { 0, };
+       cred.cr_fsuid = uid;
        
        insize = SIZE(release);
        UPARG(CODA_CLOSE);
        
-       memcpy(&(inp->ih.cred), cred, sizeof(*cred));
+       memcpy(&(inp->ih.cred), &cred, sizeof(cred));
        
         inp->coda_close.VFid = *fid;
         inp->coda_close.flags = flags;
index 28511c79af45505f6e2e19438ffe303631882817..11af36d85867096ed5a2cdad378a6c3d445834ed 100644 (file)
@@ -21,8 +21,8 @@ struct coda_inode_info {
         u_short                   c_flags;     /* flags (see below) */
        struct list_head   c_cilist;    /* list of all coda inodes */
        unsigned int       c_mapcount;  /* nr of times this inode is mapped */
-       unsigned int       c_cached_epoch;
-        struct coda_cred   c_cached_cred; /* credentials of cached perms */
+       unsigned int       c_cached_epoch; /* epoch for cached permissions */
+       vuid_t             c_uid;       /* fsuid for cached permissions */
         unsigned int       c_cached_perm; /* cached access permissions */
        struct inode       vfs_inode;
 };
@@ -35,7 +35,6 @@ struct coda_file_info {
        int                cfi_magic;     /* magic number */
        struct file       *cfi_container; /* container file for this cnode */
        unsigned int       cfi_mapcount;  /* nr of times this file is mapped */
-       struct coda_cred   cfi_cred;      /* credentials of opener */
 };
 
 #define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data))
index 80835f7dd00d8e587863a2c2c8fd85fcd63dfbf4..42a8ec1f81f1d606fae056c8769d8d9c324cae01 100644 (file)
@@ -54,12 +54,9 @@ char *coda_f2s(ViceFid *f);
 int coda_isroot(struct inode *i);
 int coda_iscontrol(const char *name, size_t length);
 
-void coda_load_creds(struct coda_cred *cred);
 void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
 void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
 unsigned short coda_flags_to_cflags(unsigned short);
-int coda_cred_ok(struct coda_cred *cred);
-int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2);
 
 /* sysctl.h */
 void coda_sysctl_init(void);
index 74125fc4e0a8adf1833775ee9fba0aa0db9f61c1..0d3cd872102163902d2ada3d38ce00bea9d19400 100644 (file)
@@ -39,11 +39,9 @@ int venus_setattr(struct super_block *, struct ViceFid *,
 int venus_lookup(struct super_block *sb, struct ViceFid *fid, 
                    const char *name, int length, int *type, 
                    struct ViceFid *resfid);
-int venus_store(struct super_block *sb, struct ViceFid *fid, int flags,
-               struct coda_cred *);
+int venus_store(struct super_block *sb, struct ViceFid *fid, int flags, vuid_t uid);
 int venus_release(struct super_block *sb, struct ViceFid *fid, int flags);
-int venus_close(struct super_block *sb, struct ViceFid *fid, int flags,
-               struct coda_cred *);
+int venus_close(struct super_block *sb, struct ViceFid *fid, int flags, vuid_t uid);
 int venus_open(struct super_block *sb, struct ViceFid *fid,
                int flags, struct file **f);
 int venus_mkdir(struct super_block *sb, struct ViceFid *dirfid,