From 1f41be5168760360c4538a694e6bd79e33bda783 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Thu, 15 Jan 2009 13:27:27 +0000 Subject: [PATCH] DEVEL15-linux-2629-20090115 LICENSE IPL10 FIXES 124115 add 2.6.29 support (cherry picked from commit 24a5d12bae9a2af393f3641055893824c71a4712) --- acinclude.m4 | 2 + src/afs/LINUX/osi_cred.c | 28 ++++-- src/afs/LINUX/osi_file.c | 4 + src/afs/LINUX/osi_groups.c | 32 ++++--- src/afs/LINUX/osi_machdep.h | 30 +++++- src/afs/LINUX/osi_vnodeops.c | 4 + src/afs/afs_nfsdisp.c | 176 +++++++++++++++++------------------ src/afs/afs_osi_gcpags.c | 7 +- src/cf/linux-test4.m4 | 29 ++++++ 9 files changed, 199 insertions(+), 113 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 55355c1c9e..18b454f60c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -857,6 +857,8 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_HAVE_WRITE_BEGIN_AOP LINUX_HAVE_BDI_INIT LINUX_KMEM_CACHE_INIT + LINUX_HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN + LINUX_STRUCT_TASK_HAS_CRED LINUX_HAVE_KMEM_CACHE_T LINUX_KMEM_CACHE_CREATE_TAKES_DTOR LINUX_D_PATH_TAKES_STRUCT_PATH diff --git a/src/afs/LINUX/osi_cred.c b/src/afs/LINUX/osi_cred.c index cfc7364467..22f4bb53f4 100644 --- a/src/afs/LINUX/osi_cred.c +++ b/src/afs/LINUX/osi_cred.c @@ -79,15 +79,15 @@ crref(void) { cred_t *cr = crget(); - cr->cr_uid = current->fsuid; - cr->cr_ruid = current->uid; - cr->cr_gid = current->fsgid; - cr->cr_rgid = current->gid; + cr->cr_uid = current_fsuid(); + cr->cr_ruid = current_uid(); + cr->cr_gid = current_fsgid(); + cr->cr_rgid = current_gid(); #if defined(AFS_LINUX26_ENV) task_lock(current); - get_group_info(current->group_info); - cr->cr_group_info = current->group_info; + get_group_info(current_group_info()); + cr->cr_group_info = current_group_info(); task_unlock(current); #else memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t)); @@ -101,10 +101,20 @@ crref(void) void crset(cred_t * cr) { +#if defined(STRUCT_TASK_HAS_CRED) + struct cred *new_creds; + + new_creds = prepare_creds(); + new_creds->fsuid = cr->cr_uid; + new_creds->uid = cr->cr_ruid; + new_creds->fsgid = cr->cr_gid; + new_creds->gid = cr->cr_rgid; +#else current->fsuid = cr->cr_uid; current->uid = cr->cr_ruid; current->fsgid = cr->cr_gid; current->gid = cr->cr_rgid; +#endif #if defined(AFS_LINUX26_ENV) { struct group_info *old_info; @@ -113,8 +123,14 @@ crset(cred_t * cr) get_group_info(cr->cr_group_info); task_lock(current); +#if defined(STRUCT_TASK_HAS_CRED) + old_info = current->cred->group_info; + new_creds->group_info = cr->cr_group_info; + commit_creds(new_creds); +#else old_info = current->group_info; current->group_info = cr->cr_group_info; +#endif task_unlock(current); put_group_info(old_info); diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 6a881cd729..869ed80f66 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -87,7 +87,11 @@ osi_UFSOpen(afs_int32 ainode) #endif tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ +#if defined(STRUCT_TASK_HAS_CRED) + filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred()); +#else filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR); +#endif if (IS_ERR(filp)) #if defined(LINUX_USE_FH) osi_Panic("Can't open file\n"); diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index 93584ef970..1622ec6f7b 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -51,7 +51,7 @@ afs_setgroups(cred_t **cr, struct group_info *group_info, int change_parent) crset(*cr); -#ifdef STRUCT_TASK_STRUCT_HAS_PARENT +#if defined(STRUCT_TASK_STRUCT_HAS_PARENT) && !defined(STRUCT_TASK_HAS_CRED) if (change_parent) { old_info = current->parent->group_info; get_group_info(group_info); @@ -247,12 +247,12 @@ install_session_keyring(struct task_struct *task, struct key *keyring) #ifdef KEY_ALLOC_NEEDS_STRUCT_TASK keyring = key_alloc(__key_type_keyring, desc, - task->uid, task->gid, task, + task_uid(task), task_gid(task), task, (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, not_in_quota); #else keyring = key_alloc(__key_type_keyring, desc, - task->uid, task->gid, + task_uid(task), task_gid(task), (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, not_in_quota); #endif @@ -270,9 +270,9 @@ install_session_keyring(struct task_struct *task, struct key *keyring) /* install the keyring */ spin_lock_irq(&task->sighand->siglock); - old = task->signal->session_keyring; + old = task_session_keyring(task); smp_wmb(); - task->signal->session_keyring = keyring; + task_session_keyring(task) = keyring; spin_unlock_irq(&task->sighand->siglock); if (old) @@ -337,7 +337,7 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, if (code == 0 && (*cr)->cr_rgid != NFSXLATOR_CRED) { (void) install_session_keyring(current, NULL); - if (current->signal->session_keyring) { + if (current_session_keyring()) { struct key *key; key_perm_t perm; @@ -352,7 +352,7 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, if (!IS_ERR(key)) { key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32), - current->signal->session_keyring, NULL); + current_session_keyring(), NULL); key_put(key); } } @@ -549,26 +549,28 @@ static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen { int code; afs_uint32 *userpag, pag = NOPAG; +#ifndef AFS_LINUX26_ONEGROUP_ENV int g0, g1; +#endif if (key->uid != 0 || key->gid != 0) return -EPERM; code = -EINVAL; - get_group_info(current->group_info); + get_group_info(current_group_info()); if (datalen != sizeof(afs_uint32) || !data) goto error; - if (current->group_info->ngroups < NUMPAGGROUPS) + if (current_group_info()->ngroups < NUMPAGGROUPS) goto error; /* ensure key being set matches current pag */ #ifdef AFS_LINUX26_ONEGROUP_ENV - pag = afs_get_pag_from_groups(current->group_info); + pag = afs_get_pag_from_groups(current_group_info()); #else - g0 = GROUP_AT(current->group_info, 0); - g1 = GROUP_AT(current->group_info, 1); + g0 = GROUP_AT(current_group_info(), 0); + g1 = GROUP_AT(current_group_info(), 1); pag = afs_get_pag_from_groups(g0, g1); #endif @@ -584,7 +586,7 @@ static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen code = 0; error: - put_group_info(current->group_info); + put_group_info(current_group_info()); return code; } @@ -651,8 +653,8 @@ void osi_keyring_init(void) #else p = find_task_by_vpid(1); #endif - if (p && p->user->session_keyring) - __key_type_keyring = p->user->session_keyring->type; + if (p && task_user(p)->session_keyring) + __key_type_keyring = task_user(p)->session_keyring->type; # ifdef EXPORTED_TASKLIST_LOCK if (&tasklist_lock) read_unlock(&tasklist_lock); diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index d398c7e859..11e70308ca 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -155,7 +155,7 @@ static inline long copyinstr(char *from, char *to, int count, int *length) { #endif /* cred struct */ -typedef struct cred { /* maps to task field: */ +typedef struct afs_cred { /* maps to task field: */ int cr_ref; uid_t cr_uid; /* euid */ uid_t cr_ruid; /* uid */ @@ -167,10 +167,34 @@ typedef struct cred { /* maps to task field: */ gid_t cr_groups[NGROUPS]; /* 32 groups - empty set to NOGROUP */ int cr_ngroups; #endif - struct cred *cr_next; + struct afs_cred *cr_next; } cred_t; -#define AFS_UCRED cred +#define AFS_UCRED afs_cred #define AFS_PROC struct task_struct +#if !defined(current_cred) +#define current_gid() (current->gid) +#define current_uid() (current->uid) +#define current_fsgid() (current->fsgid) +#define current_fsuid() (current->fsuid) +#endif +#if defined(STRUCT_TASK_HAS_CRED) +#define current_group_info() (current->cred->group_info) +#define task_gid(task) (task->cred->gid) +#define task_user(task) (task->cred->user) +#define task_session_keyring(task) (task->cred->tgcred->session_keyring) +#define current_session_keyring() (current->cred->tgcred->session_keyring) +#else +#define current_group_info() (current->group_info) +#if !defined(task_gid) +#define task_gid(task) (task->gid) +#endif +#if !defined(task_uid) +#define task_uid(task) (task->uid) +#endif +#define task_user(task) (task->user) +#define task_session_keyring(task) (task->signal->session_keyring) +#define current_session_keyring() (current->signal->session_keyring) +#endif #define crhold(c) (c)->cr_ref++ /* UIO manipulation */ diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index c1a95480ad..747318da43 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -2128,7 +2128,11 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping, { struct page *page; pgoff_t index = pos >> PAGE_CACHE_SHIFT; +#if defined(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN) + page = grab_cache_page_write_begin(mapping, index, flags); +#else page = __grab_cache_page(mapping, index); +#endif *pagep = page; return 0; diff --git a/src/afs/afs_nfsdisp.c b/src/afs/afs_nfsdisp.c index 2c72374e6d..2b45437311 100644 --- a/src/afs/afs_nfsdisp.c +++ b/src/afs/afs_nfsdisp.c @@ -378,8 +378,8 @@ void afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -393,8 +393,8 @@ void afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -408,8 +408,8 @@ void afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -426,8 +426,8 @@ void afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -441,8 +441,8 @@ void afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_READ, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -456,8 +456,8 @@ void afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -471,8 +471,8 @@ void afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -489,8 +489,8 @@ void afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -504,8 +504,8 @@ void afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -519,8 +519,8 @@ void afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -534,8 +534,8 @@ void afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -549,8 +549,8 @@ void afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -567,8 +567,8 @@ void afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -582,8 +582,8 @@ void afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -597,8 +597,8 @@ void afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs2_noaccess((struct afs_nfs2_resp *)xp); @@ -633,8 +633,8 @@ void afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, &exp, rp, crp); if (call > 1) @@ -650,8 +650,8 @@ void afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, &exp, rp, crp); if (call > 1) @@ -667,8 +667,8 @@ void afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, &exp, rp, crp); if (call > 1) @@ -684,8 +684,8 @@ void afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, &exp, rp, crp); if (call > 1) @@ -702,8 +702,8 @@ void afs_acl2_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1140,8 +1140,8 @@ afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1158,8 +1158,8 @@ afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1176,8 +1176,8 @@ afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, &exp, rp, crp); if (call > 1) @@ -1199,8 +1199,8 @@ afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, &exp, rp, crp); if (call > 1) @@ -1217,8 +1217,8 @@ afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, &exp, rp, crp); @@ -1236,8 +1236,8 @@ afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); @@ -1253,8 +1253,8 @@ afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, &exp, rp, crp); if (call > 1) @@ -1271,8 +1271,8 @@ afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, &exp, rp, crp); if (call > 1) @@ -1294,8 +1294,8 @@ afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1317,8 +1317,8 @@ afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, &exp, rp, crp); if (call > 1) @@ -1340,8 +1340,8 @@ afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, &exp, rp, crp); if (call > 1) @@ -1363,8 +1363,8 @@ afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, &exp, rp, crp); if (call > 1) @@ -1381,8 +1381,8 @@ afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1399,8 +1399,8 @@ afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, &exp, rp, crp); if (call > 1) @@ -1417,8 +1417,8 @@ afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, &exp, rp, crp); if (call > 1) afs_nfs3_noaccess((struct afs_nfs3_resp *)xp); @@ -1434,8 +1434,8 @@ afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, &exp, rp, crp); if (call > 1) @@ -1452,8 +1452,8 @@ afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, &exp, rp, crp); @@ -1473,8 +1473,8 @@ afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, &exp, rp, crp); if (call > 1) @@ -1491,8 +1491,8 @@ afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, &exp, rp, crp); if (call > 1) @@ -1509,8 +1509,8 @@ afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, &exp, rp, crp); @@ -1528,8 +1528,8 @@ afs_nfs3_commit(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; afs_nfs3_resp dummy; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, &exp, rp, crp); if (call > 1) @@ -1570,8 +1570,8 @@ void afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, &exp, rp, crp); if (call > 1) @@ -1587,8 +1587,8 @@ void afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, &exp, rp, crp); if (call > 1) @@ -1605,8 +1605,8 @@ void afs_acl3_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp) { u_int call; - struct cred *svcred = curthread->t_cred; - curthread->t_cred = (struct cred *)crp; + struct AFS_UCRED *svcred = curthread->t_cred; + curthread->t_cred = (struct AFS_UCRED *)crp; call = afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, (char *)args, &exp, rp, crp); if (call > 1) diff --git a/src/afs/afs_osi_gcpags.c b/src/afs/afs_osi_gcpags.c index 4c552ca1d6..b0e42cf435 100644 --- a/src/afs/afs_osi_gcpags.c +++ b/src/afs/afs_osi_gcpags.c @@ -513,10 +513,15 @@ afs_osi_proc2cred(AFS_PROC * pr) || (pr->state == TASK_UNINTERRUPTIBLE) || (pr->state == TASK_STOPPED)) { cr.cr_ref = 1; - cr.cr_uid = pr->uid; + cr.cr_uid = task_uid(pr); #if defined(AFS_LINUX26_ENV) +#if defined(STRUCT_TASK_HAS_CRED) + get_group_info(pr->cred->group_info); + cr.cr_group_info = pr->cred->group_info; +#else get_group_info(pr->group_info); cr.cr_group_info = pr->group_info; +#endif #else cr.cr_ngroups = pr->ngroups; memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t)); diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 180083a981..5530fcecdf 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -1133,3 +1133,32 @@ AC_DEFUN([LINUX_HAVE_WRITE_BEGIN_AOP], [ if test "x$ac_cv_linux_write_begin" = "xyes"; then AC_DEFINE([HAVE_WRITE_BEGIN], 1, [define if your kernel has a write_begin() address space op]) fi]) + +AC_DEFUN([LINUX_HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], [ + AC_MSG_CHECKING([for linux grab_cache_page_write_begin()]) + AC_CACHE_VAL([ac_cv_linux_grab_cache_page_write_begin], [ + AC_TRY_KBUILD( +[#include ], +[grab_cache_page_write_begin(NULL, 0, 0);], + ac_cv_linux_grab_cache_page_write_begin=yes, + ac_cv_linux_grab_cache_page_write_begin=no)]) + AC_MSG_RESULT($ac_cv_linux_grab_cache_page_write_begin) + if test "x$ac_cv_linux_grab_cache_page_write_begin" = "xyes"; then + AC_DEFINE([HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], 1, [define if your kernel has grab_cache_page_write_begin()]) + fi]) + +AC_DEFUN([LINUX_STRUCT_TASK_HAS_CRED], [ + AC_MSG_CHECKING([if struct task has cred]) + AC_CACHE_VAL([ac_cv_linux_struct_task_has_cred], [ + AC_TRY_KBUILD( +[#include +#include ], +[struct task_struct _t; +uid_t _u; +_u =_t.cred->uid ;], + ac_cv_linux_struct_task_has_cred=yes, + ac_cv_linux_struct_task_has_cred=no)]) + AC_MSG_RESULT($ac_cv_linux_struct_task_has_cred) + if test "x$ac_cv_linux_struct_task_has_cred" = "xyes"; then + AC_DEFINE([STRUCT_TASK_HAS_CRED], 1, [define if struct task has a cred pointer]) + fi])