reindent-20030715
[openafs.git] / src / afs / LINUX / osi_groups.c
index ef957f9..2e2cb22 100644 (file)
 #include <afsconfig.h>
 #include "afs/param.h"
 
-RCSID("$Header$");
+RCSID
+    ("$Header$");
 
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
-#include "afs/afs_stats.h"  /* statistics */
+#include "afs/afs_stats.h"     /* statistics */
 #ifdef AFS_LINUX22_ENV
 #include "h/smp_lock.h"
 #endif
 
-static int afs_getgroups(cred_t *cr, gid_t *groups);
-static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_parent);
+static int afs_getgroups(cred_t * cr, gid_t * groups);
+static int afs_setgroups(cred_t ** cr, int ngroups, gid_t * gidset,
+                        int change_parent);
 
 /* Only propogate the PAG to the parent process. Unix's propogate to 
  * all processes sharing the cred.
  */
-int set_pag_in_parent(int pag, int g0, int g1)
+int
+set_pag_in_parent(int pag, int g0, int g1)
 {
 #ifdef STRUCT_TASK_STRUCT_HAS_PARENT
     gid_t *gp = current->parent->groups;
@@ -41,7 +44,7 @@ int set_pag_in_parent(int pag, int g0, int g1)
     int ngroups;
     int i;
 
-    
+
 #ifdef STRUCT_TASK_STRUCT_HAS_PARENT
     ngroups = current->parent->ngroups;
 #else
@@ -53,9 +56,9 @@ int set_pag_in_parent(int pag, int g0, int g1)
        if (ngroups + 2 > NGROUPS) {
            return EINVAL;
        }
-       for (i = ngroups-1; i >= 0; i--) {
-           gp[i+2] = gp[i];
-       }
+       for (i = ngroups - 1; i >= 0; i--) {
+           gp[i + 2] = gp[i];
+       }
        ngroups += 2;
     }
     gp[0] = g0;
@@ -71,7 +74,9 @@ int set_pag_in_parent(int pag, int g0, int g1)
     return 0;
 }
 
-int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_parent)
+int
+setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
+       int change_parent)
 {
     gid_t *gidset;
     afs_int32 ngroups, code = 0;
@@ -79,21 +84,21 @@ int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_pare
 
     AFS_STATCNT(setpag);
 
-    gidset = (gid_t *) osi_Alloc(NGROUPS*sizeof(gidset[0]));
+    gidset = (gid_t *) osi_Alloc(NGROUPS * sizeof(gidset[0]));
     ngroups = afs_getgroups(*cr, gidset);
 
     if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
        /* We will have to shift grouplist to make room for pag */
        if (ngroups + 2 > NGROUPS) {
-           osi_Free((char *)gidset, NGROUPS*sizeof(int));
+           osi_Free((char *)gidset, NGROUPS * sizeof(int));
            return EINVAL;
        }
        for (j = ngroups - 1; j >= 0; j--) {
-           gidset[j+2] = gidset[j];
-       }
+           gidset[j + 2] = gidset[j];
+       }
        ngroups += 2;
     }
-    *newpag = (pagvalue == -1 ? genpag(): pagvalue);
+    *newpag = (pagvalue == -1 ? genpag() : pagvalue);
     afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
     code = afs_setgroups(cr, ngroups, gidset, change_parent);
 
@@ -104,14 +109,15 @@ int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_pare
        code = set_pag_in_parent(*newpag, gidset[0], gidset[1]);
     }
 
-    osi_Free((char *)gidset, NGROUPS*sizeof(int));
+    osi_Free((char *)gidset, NGROUPS * sizeof(int));
     return code;
 }
 
 
 /* Intercept the standard system call. */
-extern long (*sys_setgroupsp)(int gidsetsize, gid_t *grouplist);
-asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist)
+extern long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist);
+asmlinkage long
+afs_xsetgroups(int gidsetsize, gid_t * grouplist)
 {
     long code;
     cred_t *cr = crref();
@@ -123,7 +129,7 @@ asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist)
     crfree(cr);
     unlock_kernel();
 
-    code = (*sys_setgroupsp)(gidsetsize, grouplist);
+    code = (*sys_setgroupsp) (gidsetsize, grouplist);
     if (code) {
        return code;
     }
@@ -138,25 +144,26 @@ asmlinkage long afs_xsetgroups(int gidsetsize, gid_t *grouplist)
     unlock_kernel();
 
     /* Linux syscall ABI returns errno as negative */
-    return (- code);
+    return (-code);
 }
 
 #if defined(AFS_LINUX24_ENV)
 /* Intercept the standard uid32 system call. */
-extern long (*sys_setgroups32p)(int gidsetsize, gid_t *grouplist);
-asmlinkage long afs_xsetgroups32(int gidsetsize, gid_t *grouplist)
+extern long (*sys_setgroups32p) (int gidsetsize, gid_t * grouplist);
+asmlinkage long
+afs_xsetgroups32(int gidsetsize, gid_t * grouplist)
 {
     long code;
     cred_t *cr = crref();
     afs_uint32 junk;
     int old_pag;
-    
+
     lock_kernel();
     old_pag = PagInCred(cr);
     crfree(cr);
     unlock_kernel();
 
-    code = (*sys_setgroups32p)(gidsetsize, grouplist);
+    code = (*sys_setgroups32p) (gidsetsize, grouplist);
 
     if (code) {
        return code;
@@ -172,14 +179,15 @@ asmlinkage long afs_xsetgroups32(int gidsetsize, gid_t *grouplist)
     unlock_kernel();
 
     /* Linux syscall ABI returns errno as negative */
-    return (- code);
+    return (-code);
 }
 #endif
 
 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_AMD64_LINUX20_ENV)
 /* Intercept the uid16 system call as used by 32bit programs. */
-extern long (*sys32_setgroupsp)(int gidsetsize, old_gid_t *grouplist);
-asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist)
+extern long (*sys32_setgroupsp) (int gidsetsize, old_gid_t * grouplist);
+asmlinkage long
+afs32_xsetgroups(int gidsetsize, old_gid_t * grouplist)
 {
     long code;
     cred_t *cr = crref();
@@ -191,7 +199,7 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist)
     crfree(cr);
     unlock_kernel();
 
-    code = (*sys32_setgroupsp)(gidsetsize, grouplist);
+    code = (*sys32_setgroupsp) (gidsetsize, grouplist);
     if (code) {
        return code;
     }
@@ -206,12 +214,14 @@ asmlinkage long afs32_xsetgroups(int gidsetsize, old_gid_t *grouplist)
     unlock_kernel();
 
     /* Linux syscall ABI returns errno as negative */
-    return (- code);
+    return (-code);
 }
+
 #ifdef AFS_LINUX24_ENV
 /* Intercept the uid32 system call as used by 32bit programs. */
-extern long (*sys32_setgroups32p)(int gidsetsize, gid_t *grouplist);
-asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist)
+extern long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist);
+asmlinkage long
+afs32_xsetgroups32(int gidsetsize, gid_t * grouplist)
 {
     long code;
     cred_t *cr = crref();
@@ -223,7 +233,7 @@ asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist)
     crfree(cr);
     unlock_kernel();
 
-    code = (*sys32_setgroups32p)(gidsetsize, grouplist);
+    code = (*sys32_setgroups32p) (gidsetsize, grouplist);
     if (code) {
        return code;
     }
@@ -238,12 +248,13 @@ asmlinkage long afs32_xsetgroups32(int gidsetsize, gid_t *grouplist)
     unlock_kernel();
 
     /* Linux syscall ABI returns errno as negative */
-    return (- code);
+    return (-code);
 }
 #endif
 #endif
 
-static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_parent)
+static int
+afs_setgroups(cred_t ** cr, int ngroups, gid_t * gidset, int change_parent)
 {
     int ngrps;
     int i;
@@ -256,7 +267,7 @@ static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_par
 
     gp = (*cr)->cr_groups;
     if (ngroups < NGROUPS)
-       gp[ngroups] = (gid_t)NOGROUP;
+       gp[ngroups] = (gid_t) NOGROUP;
 
     for (i = ngroups; i > 0; i--) {
        *gp++ = *gidset++;
@@ -270,16 +281,16 @@ static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_par
 /* Returns number of groups. And we trust groups to be large enough to
  * hold all the groups.
  */
-static int afs_getgroups(cred_t *cr, gid_t *groups)
+static int
+afs_getgroups(cred_t * cr, gid_t * groups)
 {
     int i;
     gid_t *gp = cr->cr_groups;
     int n = cr->cr_ngroups;
     AFS_STATCNT(afs_getgroups);
 
-    for (i = 0; (i < n) && (*gp != (gid_t)NOGROUP); i++) {
+    for (i = 0; (i < n) && (*gp != (gid_t) NOGROUP); i++) {
        *groups++ = *gp++;
     }
     return i;
 }
-