struct afs_lhash_stat afs_linux_lsb; /* hash table statistics */
unsigned int afs_linux_hash_bucket_dist[MAX_BUCKET_LEN]; /* bucket population distribution in our hash table */
-#if defined(AFS_LINUX24_ENV)
#include "h/vmalloc.h"
-#else
-/* externs : can we do this in a better way. Including vmalloc.h causes other
- * problems.*/
-extern void vfree(void *addr);
-extern void *vmalloc(unsigned long size);
-#endif
/* Allocator support functions (static) */
/************** Linux memory allocator interface functions **********/
-#if defined(AFS_LINUX24_ENV)
DECLARE_MUTEX(afs_linux_alloc_sem);
-#else
-struct semaphore afs_linux_alloc_sem = MUTEX;
-#endif
void *
osi_linux_alloc(unsigned int asize, int drop_glock)
return;
}
-#if defined(AFS_LINUX26_ENV)
put_group_info(cr->cr_group_info);
-#endif
kfree(cr);
}
tmp->cr_gid = cr->cr_gid;
tmp->cr_rgid = cr->cr_rgid;
-#if defined(AFS_LINUX26_ENV)
get_group_info(cr->cr_group_info);
tmp->cr_group_info = cr->cr_group_info;
-#else
- memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
- tmp->cr_ngroups = cr->cr_ngroups;
-#endif
return tmp;
}
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();
task_unlock(current);
-#else
- memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t));
- cr->cr_ngroups = current->ngroups;
-#endif
+
return cr;
}
-
/* Set the cred info into the current task */
void
crset(cred_t * cr)
{
+ struct group_info *old_info;
#if defined(STRUCT_TASK_HAS_CRED)
struct cred *new_creds;
current->fsgid = cr->cr_gid;
current->gid = cr->cr_rgid;
#endif
-#if defined(AFS_LINUX26_ENV)
-{
- struct group_info *old_info;
/* using set_current_groups() will sort the groups */
get_group_info(cr->cr_group_info);
put_group_info(old_info);
}
-#else
- memcpy(current->groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
- current->ngroups = cr->cr_ngroups;
-#endif
-}
#include "afs/param.h"
-#ifdef AFS_LINUX24_ENV
#include "h/module.h" /* early to avoid printf->printk mapping */
-#endif
#include "afs/sysincludes.h" /* Standard vendor system headers */
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#include "h/smp_lock.h"
-#if defined(AFS_LINUX26_ENV)
#include "h/namei.h"
-#endif
#if defined(LINUX_USE_FH)
#include "h/exportfs.h"
int cache_fh_type = -1;
afs_lock_t afs_xosi; /* lock is for tvattr */
extern struct osi_dev cacheDev;
-#if defined(AFS_LINUX24_ENV)
extern struct vfsmount *afs_cacheMnt;
-#endif
extern struct super_block *afs_cacheSBp;
-#if defined(AFS_LINUX26_ENV)
struct file *
afs_linux_raw_open(afs_dcache_id_t *ainode, ino_t *hint)
{
afile->proc = (int (*)())0;
return (void *)afile;
}
-#else
-void *
-osi_UFSOpen(afs_dcache_id_t *ainode)
-{
- register struct osi_file *afile = NULL;
- extern int cacheDiskType;
- afs_int32 code = 0;
- struct inode *tip = NULL;
- struct file *filp = NULL;
- AFS_STATCNT(osi_UFSOpen);
- if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
- osi_Panic("UFSOpen called for non-UFS cache\n");
- }
- if (!afs_osicred_initialized) {
- /* valid for alpha_osf, SunOS, Ultrix */
- memset((char *)&afs_osi_cred, 0, sizeof(AFS_UCRED));
- crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */
- afs_osicred_initialized = 1;
- }
- afile = (struct osi_file *)osi_AllocLargeSpace(sizeof(struct osi_file));
- AFS_GUNLOCK();
- if (!afile) {
- osi_Panic("osi_UFSOpen: Failed to allocate %d bytes for osi_file.\n",
- sizeof(struct osi_file));
- }
- memset(afile, 0, sizeof(struct osi_file));
- filp = &afile->file;
- filp->f_dentry = &afile->dentry;
- tip = iget(afs_cacheSBp, ainode->ufs);
- if (!tip)
- osi_Panic("Can't get inode %d\n", ainode->ufs);
- FILE_INODE(filp) = tip;
- tip->i_flags |= MS_NOATIME; /* Disable updating access times. */
- filp->f_flags = O_RDWR;
-#if defined(AFS_LINUX24_ENV)
- filp->f_mode = FMODE_READ|FMODE_WRITE;
- filp->f_op = fops_get(tip->i_fop);
-#else
- filp->f_op = tip->i_op->default_file_ops;
-#endif
- if (filp->f_op && filp->f_op->open)
- code = filp->f_op->open(tip, filp);
- if (code)
- osi_Panic("Can't open inode %d\n", ainode->ufs);
- afile->size = i_size_read(tip);
- AFS_GLOCK();
- afile->offset = 0;
- afile->proc = (int (*)())0;
- afile->inum = ainode->ufs; /* for hint validity checking */
- return (void *)afile;
-}
-#endif
#if defined(LINUX_USE_FH)
/*
int
afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
{
- register afs_int32 code;
AFS_STATCNT(osi_Stat);
MObtainWriteLock(&afs_xosi, 320);
astat->size = i_size_read(OSIFILE_INODE(afile));
-#if defined(AFS_LINUX26_ENV)
astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
-#else
- astat->mtime = OSIFILE_INODE(afile)->i_mtime;
- astat->atime = OSIFILE_INODE(afile)->i_atime;
-#endif
- code = 0;
+
MReleaseWriteLock(&afs_xosi);
- return code;
+ return 0;
}
-#ifdef AFS_LINUX26_ENV
int
osi_UFSClose(register struct osi_file *afile)
{
osi_FreeLargeSpace(afile);
return 0;
}
-#else
-int
-osi_UFSClose(register struct osi_file *afile)
-{
- AFS_STATCNT(osi_Close);
- if (afile) {
- if (FILE_INODE(&afile->file)) {
- struct file *filp = &afile->file;
- if (filp->f_op && filp->f_op->release)
- filp->f_op->release(FILE_INODE(filp), filp);
- iput(FILE_INODE(filp));
- }
- }
-
- osi_FreeLargeSpace(afile);
- return 0;
-}
-#endif
int
osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
#endif
newattrs.ia_size = asize;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-#if defined(AFS_LINUX24_ENV)
newattrs.ia_ctime = CURRENT_TIME;
/* avoid notify_change() since it wants to update dentry->d_parent */
code = inode_change_ok(inode, &newattrs);
if (!code) {
#ifdef INODE_SETATTR_NOT_VOID
-#if defined(AFS_LINUX26_ENV)
if (inode->i_op && inode->i_op->setattr)
code = inode->i_op->setattr(afile->filp->f_dentry, &newattrs);
else
-#endif
code = inode_setattr(inode, &newattrs);
#else
inode_setattr(inode, &newattrs);
unlock_kernel();
if (!code)
truncate_inode_pages(&inode->i_data, asize);
-#else
- i_size_write(inode, asize);
- if (inode->i_sb->s_op && inode->i_sb->s_op->notify_change) {
- code = inode->i_sb->s_op->notify_change(&afile->dentry, &newattrs);
- }
- if (!code) {
- truncate_inode_pages(inode, asize);
- if (inode->i_op && inode->i_op->truncate)
- inode->i_op->truncate(inode);
- }
-#endif
code = -code;
#ifdef STRUCT_INODE_HAS_I_MUTEX
mutex_unlock(&inode->i_mutex);
int
osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
{
-#ifdef AFS_LINUX26_ENV
struct file *filp = osifile->filp;
-#else
- struct file *filp = &osifile->file;
-#endif
KERNEL_SPACE_DECL;
int code = 0;
struct iovec *iov;
#include "afsincludes.h"
#include "afs/afs_stats.h" /* statistics */
#include "afs/nfsclient.h"
-#ifdef AFS_LINUX22_ENV
#include "h/smp_lock.h"
-#endif
#ifdef AFS_LINUX26_ONEGROUP_ENV
#define NUMPAGGROUPS 1
#define NUMPAGGROUPS 2
#endif
-#if defined(AFS_LINUX26_ENV)
static int
afs_setgroups(cred_t **cr, struct group_info *group_info, int change_parent)
{
return (0);
}
-#else
-static int
-afs_setgroups(cred_t **cr, int ngroups, gid_t * gidset, int change_parent)
-{
- int ngrps;
- int i;
- gid_t *gp;
-
- AFS_STATCNT(afs_setgroups);
-
- if (ngroups > NGROUPS)
- return EINVAL;
-
- gp = (*cr)->cr_groups;
- if (ngroups < NGROUPS)
- gp[ngroups] = (gid_t) NOGROUP;
-
- for (i = ngroups; i > 0; i--) {
- *gp++ = *gidset++;
- }
-
- (*cr)->cr_ngroups = ngroups;
- crset(*cr);
- return (0);
-}
-#endif
-
-#if defined(AFS_LINUX26_ENV)
+/* Returns number of groups. And we trust groups to be large enough to
+ * hold all the groups.
+ */
static struct group_info *
afs_getgroups(cred_t * cr)
{
get_group_info(cr->cr_group_info);
return cr->cr_group_info;
}
-#else
-/* 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)
-{
- int i;
- int n;
- gid_t *gp;
-
- AFS_STATCNT(afs_getgroups);
-
- gp = cr->cr_groups;
- n = cr->cr_ngroups;
-
- for (i = 0; (i < n) && (*gp != (gid_t) NOGROUP); i++)
- *groups++ = *gp++;
- return i;
-}
-#endif
-#if !defined(AFS_LINUX26_ENV)
-/* 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 i;
-#ifdef STRUCT_TASK_STRUCT_HAS_PARENT
- gid_t *gp = current->parent->groups;
- int ngroups = current->parent->ngroups;
-#else
- gid_t *gp = current->p_pptr->groups;
- int ngroups = current->p_pptr->ngroups;
-#endif
-
- if ((ngroups < 2) || (afs_get_pag_from_groups(gp[0], gp[1]) == NOPAG)) {
- /* We will have to shift grouplist to make room for pag */
- if (ngroups + 2 > NGROUPS) {
- return EINVAL;
- }
- for (i = ngroups - 1; i >= 0; i--) {
- gp[i + 2] = gp[i];
- }
- ngroups += 2;
- }
- gp[0] = g0;
- gp[1] = g1;
- if (ngroups < NGROUPS)
- gp[ngroups] = NOGROUP;
-
-#ifdef STRUCT_TASK_STRUCT_HAS_PARENT
- current->parent->ngroups = ngroups;
-#else
- current->p_pptr->ngroups = ngroups;
-#endif
- return 0;
-}
-#endif
-
-#if defined(AFS_LINUX26_ENV)
int
__setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
int change_parent)
}
#endif /* LINUX_KEYRING_SUPPORT */
-#else
-int
-__setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
- int change_parent)
-{
- gid_t *gidset;
- afs_int32 ngroups, code = 0;
- int j;
-
- 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));
- return EINVAL;
- }
- for (j = ngroups - 1; j >= 0; j--) {
- gidset[j + 2] = gidset[j];
- }
- ngroups += 2;
- }
- *newpag = (pagvalue == -1 ? genpag() : pagvalue);
- afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
- code = afs_setgroups(cr, ngroups, gidset, change_parent);
-
- /* If change_parent is set, then we should set the pag in the parent as
- * well.
- */
- if (change_parent && !code) {
- code = set_pag_in_parent(*newpag, gidset[0], gidset[1]);
- }
-
- osi_Free((char *)gidset, NGROUPS * sizeof(int));
- return code;
-}
-#endif
-
-
int
setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
int change_parent)
return (-code);
}
-#if defined(AFS_LINUX24_ENV)
/* Intercept the standard uid32 system call. */
extern asmlinkage long (*sys_setgroups32p) (int gidsetsize, gid_t * grouplist);
asmlinkage long
/* Linux syscall ABI returns errno as negative */
return (-code);
}
-#endif
#if defined(AFS_PPC64_LINUX20_ENV)
/* Intercept the uid16 system call as used by 32bit programs. */
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
return (-code);
}
#endif
-#endif
#ifdef LINUX_KEYRING_SUPPORT
if (cmd != VIOC_SYSCALL && cmd != VIOC_SYSCALL32) return -EINVAL;
#ifdef NEED_IOCTL32
-#ifdef AFS_LINUX26_ENV
-#ifdef AFS_S390X_LINUX26_ENV
+# ifdef AFS_S390X_LINUX26_ENV
if (test_thread_flag(TIF_31BIT))
-#elif AFS_AMD64_LINUX20_ENV
+# elif AFS_AMD64_LINUX20_ENV
if (test_thread_flag(TIF_IA32))
-#else
+# else
if (test_thread_flag(TIF_32BIT))
-#endif /* AFS_S390X_LINUX26_ENV */
-#else
-#ifdef AFS_SPARC64_LINUX24_ENV
- if (current->thread.flags & SPARC_FLAG_32BIT)
-#elif defined(AFS_SPARC64_LINUX20_ENV)
- if (current->tss.flags & SPARC_FLAG_32BIT)
-#elif defined(AFS_AMD64_LINUX20_ENV)
- if (current->thread.flags & THREAD_IA32)
-#elif defined(AFS_PPC64_LINUX20_ENV)
- if (current->thread.flags & PPC_FLAG_32BIT)
-#elif defined(AFS_S390X_LINUX20_ENV)
- if (current->thread.flags & S390_FLAG_31BIT)
-#else
-#error Not done for this linux type
-#endif /* AFS_LINUX26_ENV */
-#endif /* NEED_IOCTL32 */
+# endif /* AFS_S390X_LINUX26_ENV */
{
if (copy_from_user(&sysargs32, (void *)arg,
sizeof(struct afsprocdata32)))
(unsigned long)sysargs32.param3,
(unsigned long)sysargs32.param4);
} else
-#endif
+#endif /* NEED_IOCTL32 */
{
if (copy_from_user(&sysargs, (void *)arg, sizeof(struct afsprocdata)))
return -EFAULT;
uid_t cr_ruid; /* uid */
gid_t cr_gid; /* egid */
gid_t cr_rgid; /* gid */
-#if defined(AFS_LINUX26_ENV)
struct group_info *cr_group_info;
-#else
- gid_t cr_groups[NGROUPS]; /* 32 groups - empty set to NOGROUP */
- int cr_ngroups;
-#endif
struct afs_cred *cr_next;
} cred_t;
#define AFS_UCRED struct afs_cred
/* Get/set the inode in the osifile struct. */
#define FILE_INODE(F) (F)->f_dentry->d_inode
-#ifdef AFS_LINUX26_ENV
#define OSIFILE_INODE(a) FILE_INODE((a)->filp)
-#else
-#define OSIFILE_INODE(a) FILE_INODE(&(a)->file)
-#endif
#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
#define NEED_IOCTL32
#endif
-/* page offset is obtained and stored here during module initialization
- * We need a variable to do this because, the PAGE_OFFSET macro defined in
- * include/asm/page.h can change from kernel to kernel and we cannot use
- * the hardcoded version.
- */
-extern unsigned long afs_linux_page_offset;
-
-/* function to help with the page offset stuff */
-#define afs_linux_page_address(page) (afs_linux_page_offset + PAGE_SIZE * (page - mem_map))
-
#if defined(__KERNEL__)
#include <linux/version.h>
#include <linux/sched.h>
#include <linux/module.h> /* early to avoid printf->printk mapping */
-#if defined(AFS_LINUX26_ENV)
#include "h/dcache.h"
#include "h/namei.h"
#include "h/kthread.h"
-#endif
#include "afs/sysincludes.h"
#include "afsincludes.h"
#include "afs/afs_stats.h"
-#if defined(AFS_LINUX24_ENV)
#include "h/smp_lock.h"
-#endif
int afs_osicred_initialized = 0;
AFS_UCRED afs_osi_cred;
void
afs_osi_SetTime(osi_timeval_t * tvp)
{
-#if defined(AFS_LINUX24_ENV)
-
-#if defined(AFS_LINUX26_ENV)
struct timespec tv;
tv.tv_sec = tvp->tv_sec;
tv.tv_nsec = tvp->tv_usec * NSEC_PER_USEC;
-#else
- struct timeval tv;
- tv.tv_sec = tvp->tv_sec;
- tv.tv_usec = tvp->tv_usec;
-#endif
AFS_STATCNT(osi_SetTime);
do_settimeofday(&tv);
-#else
- extern int (*sys_settimeofdayp) (struct timeval * tv,
- struct timezone * tz);
-
- KERNEL_SPACE_DECL;
-
- AFS_STATCNT(osi_SetTime);
-
- TO_USER_SPACE();
- if (sys_settimeofdayp)
- (void)(*sys_settimeofdayp) (tvp, NULL);
- TO_KERNEL_SPACE();
-#endif
}
void
SIG_UNLOCK(current);
}
-#if defined(AFS_LINUX24_ENV)
/* LOOKUP_POSITIVE is becoming the default */
#ifndef LOOKUP_POSITIVE
#define LOOKUP_POSITIVE 0
if (followlink)
flags |= LOOKUP_FOLLOW;
-#if defined(AFS_LINUX26_ENV)
code = path_lookup(aname, flags, &nd);
-#else
- if (path_init(aname, flags, &nd))
- code = path_walk(aname, &nd);
-#endif
if (!code) {
#if defined(STRUCT_NAMEIDATA_HAS_PATH)
}
return code;
}
-#else
-int
-osi_lookupname(char *aname, uio_seg_t seg, int followlink, struct dentry **dpp)
-{
- struct dentry *dp = NULL;
- int code;
-
- code = ENOENT;
- if (seg == AFS_UIOUSER) {
- dp = followlink ? namei(aname) : lnamei(aname);
- } else {
- dp = lookup_dentry(aname, NULL, followlink ? 1 : 0);
- }
-
- if (dp && !IS_ERR(dp)) {
- if (dp->d_inode) {
- *dpp = dp;
- code = 0;
- } else
- dput(dp);
- }
-
- return code;
-}
-#endif
-
-#ifdef AFS_LINUX26_ENV
-/* This is right even for Linux 2.4, but on that version d_path is inline
- * and implemented in terms of __d_path, which is not exported.
- */
int osi_abspath(char *aname, char *buf, int buflen,
int followlink, char **pathp)
{
{
kthread_run(afs_thread_wrapper, proc, "%s", name);
}
-#endif
#include <linux/proc_fs.h>
#include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/kernel.h>
-#endif
#include "osi_pagecopy.h"
extern struct file_system_type afs_fs_type;
-#if !defined(AFS_LINUX24_ENV)
-static long get_page_offset(void);
-#endif
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
DEFINE_MUTEX(afs_global_lock);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-DECLARE_MUTEX(afs_global_lock);
#else
-struct semaphore afs_global_lock = MUTEX;
+DECLARE_MUTEX(afs_global_lock);
#endif
int afs_global_owner = 0;
-#if !defined(AFS_LINUX24_ENV)
-unsigned long afs_linux_page_offset = 0; /* contains the PAGE_OFFSET value */
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
int __init
afs_init(void)
-#else
-int
-init_module(void)
-#endif
{
int err;
AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
-#if !defined(AFS_LINUX24_ENV)
- /* obtain PAGE_OFFSET value */
- afs_linux_page_offset = get_page_offset();
-
-#ifndef AFS_S390_LINUX22_ENV
- if (afs_linux_page_offset == 0) {
- /* couldn't obtain page offset so can't continue */
- printf("afs: Unable to obtain PAGE_OFFSET. Exiting..");
- return -EIO;
- }
-#endif /* AFS_S390_LINUX22_ENV */
-#endif /* !defined(AFS_LINUX24_ENV) */
-
osi_Init();
-#ifdef AFS_LINUX26_ENV
#if !defined(AFS_NONFSTRANS)
osi_linux_nfssrv_init();
#endif
-#endif
#ifndef LINUX_KEYRING_SUPPORT
err = osi_syscall_init();
#ifdef LINUX_KEYRING_SUPPORT
osi_keyring_init();
#endif
-#ifdef AFS_LINUX24_ENV
osi_proc_init();
osi_ioctl_init();
-#endif
#if defined(AFS_CACHE_BYPASS)
afs_warn("Cache bypass patched libafs module init.\n");
#endif
return 0;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
void __exit
afs_cleanup(void)
-#else
-void
-cleanup_module(void)
-#endif
{
#if defined(AFS_CACHE_BYPASS)
afs_warn("Cache bypass patched libafs module cleaning up.\n");
unregister_filesystem(&afs_fs_type);
afs_destroy_inodecache();
-#ifdef AFS_LINUX26_ENV
#if !defined(AFS_NONFSTRANS)
osi_linux_nfssrv_shutdown();
#endif
-#endif
osi_linux_free_afs_memory();
-#ifdef AFS_LINUX24_ENV
osi_ioctl_clean();
osi_proc_clean();
-#endif
return;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
module_init(afs_init);
module_exit(afs_cleanup);
-#endif
-
-
-#if !defined(AFS_LINUX24_ENV)
-static long
-get_page_offset(void)
-{
-#if defined(AFS_PPC_LINUX22_ENV) || defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV) || defined(AFS_ALPHA_LINUX20_ENV) || defined(AFS_S390_LINUX22_ENV) || defined(AFS_IA64_LINUX20_ENV) || defined(AFS_PARISC_LINUX24_ENV) || defined(AFS_AMD64_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
- return PAGE_OFFSET;
-#else
- struct task_struct *p, *q;
-
- /* search backward thru the circular list */
-#if defined(EXPORTED_TASKLIST_LOCK)
- read_lock(&tasklist_lock);
-#endif
- /* search backward thru the circular list */
-#ifdef DEFINED_PREV_TASK
- for (q = current; p = q; q = prev_task(p)) {
-#else
- for (p = current; p; p = p->prev_task) {
-#endif
- if (p->pid == 1) {
-#if defined(EXPORTED_TASKLIST_LOCK)
- read_unlock(&tasklist_lock);
-#endif
- return p->addr_limit.seg;
- }
- }
-#if defined(EXPORTED_TASKLIST_LOCK)
- read_unlock(&tasklist_lock);
-#endif
- return 0;
-#endif
-}
-#endif /* !AFS_LINUX24_ENV */
#include <linux/proc_fs.h>
#include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/kernel.h>
-#endif
static unsigned long nfs_server_addr = 0;
#if defined(module_param) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
#endif
MODULE_PARM_DESC(this_cell, "Local cell name");
-#if defined(AFS_LINUX24_ENV)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
DEFINE_MUTEX(afs_global_lock);
#else
DECLARE_MUTEX(afs_global_lock);
#endif
struct proc_dir_entry *openafs_procfs;
-#else
-struct semaphore afs_global_lock = MUTEX;
-#endif
int afs_global_owner = 0;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
int __init
afspag_init(void)
-#else
-int
-init_module(void)
-#endif
{
-#if !defined(EXPORTED_PROC_ROOT_FS) && defined(AFS_LINUX24_ENV)
+#if !defined(EXPORTED_PROC_ROOT_FS)
char path[64];
#endif
int err;
err = osi_syscall_init();
if (err)
return err;
-#ifdef AFS_LINUX24_ENV
#if defined(EXPORTED_PROC_ROOT_FS)
openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs);
#else
openafs_procfs = proc_mkdir(path, NULL);
#endif
osi_ioctl_init();
-#endif
afspag_Init(htonl(nfs_server_addr));
if (this_cell)
return 0;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
void __exit
afspag_cleanup(void)
-#else
-void
-cleanup_module(void)
-#endif
{
-#if !defined(EXPORTED_PROC_ROOT_FS) && defined(AFS_LINUX24_ENV)
+#if !defined(EXPORTED_PROC_ROOT_FS)
char path[64];
#endif
osi_syscall_clean();
osi_linux_free_afs_memory();
-#ifdef AFS_LINUX24_ENV
osi_ioctl_clean();
#if defined(EXPORTED_PROC_ROOT_FS)
remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
sprintf(path, "fs/%s", PROC_FSDIRNAME);
remove_proc_entry(path, NULL);
#endif
-#endif
return;
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
module_init(afspag_init);
module_exit(afspag_cleanup);
-#endif
-#ifdef AFS_LINUX26_ENV
/* Hack alert!
* These will never be called in the standalone PAG manager, because
* they are only referenced in afs_InitReq, and nothing calls that.
{
return EINVAL;
}
-#endif
/* Code to find the Linux syscall table */
#ifdef OSI_PROBE_STANDALONE
-#define OSI_PROBE_DEBUG
+# define OSI_PROBE_DEBUG
#endif
#ifndef OSI_PROBE_STANDALONE
-#include <afsconfig.h>
-#include "afs/param.h"
+# include <afsconfig.h>
+# include "afs/param.h"
#endif
+
#if defined(ENABLE_LINUX_SYSCALL_PROBING) && defined(EXPORTED_INIT_MM)
-#ifdef AFS_LINUX24_ENV
#include <linux/module.h> /* early to avoid printf->printk mapping */
-#ifdef AFS_LINUX26_ENV
#include <scsi/scsi.h> /* for scsi_command_size */
-#endif
#ifndef OSI_PROBE_STANDALONE
-#include "afs/sysincludes.h"
-#include "afsincludes.h"
+# include "afs/sysincludes.h"
+# include "afsincludes.h"
#endif
#include <linux/version.h>
#include <linux/sched.h>
#ifdef CONFIG_H_EXISTS
-#include <linux/config.h>
+# include <linux/config.h>
#endif
#include <linux/linkage.h>
#include <linux/init.h>
#include <linux/mm.h>
#if defined(AFS_PPC64_LINUX26_ENV)
-#include <asm/abs_addr.h>
+# include <asm/abs_addr.h>
#endif
#ifdef AFS_AMD64_LINUX20_ENV
-#include <asm/ia32_unistd.h>
+# include <asm/ia32_unistd.h>
#endif
/* number of syscalls */
extern asmlinkage long sys_chdir(const char *) __attribute__((weak));
#endif
extern asmlinkage ssize_t sys_write(unsigned int, const char *, size_t) __attribute__((weak));
-#ifdef AFS_LINUX26_ENV
extern asmlinkage long sys_wait4(pid_t, int *, int, struct rusage *) __attribute__((weak));
-#else
-extern asmlinkage long sys_wait4(pid_t, unsigned int *, int, struct rusage *) __attribute__((weak));
-#endif
extern asmlinkage long sys_exit (int) __attribute__((weak));
#if defined(EXPORTED_SYS_OPEN)
extern asmlinkage long sys_open (const char *, int, int) __attribute__((weak));
* The module-loading mechanism changed in Linux 2.6, and insmod's
* loss is our gain: three new unimplemented system calls!
*/
-#if defined(AFS_LINUX26_ENV)
#ifdef __NR_
__NR_create_module,
#endif
#ifdef __NR_get_kernel_syms
__NR_get_kernel_syms,
#endif
-#endif /* AFS_LINUX26_ENV */
/*
* On IA64, the old module-loading calls are indeed present and
#elif defined(AFS_AMD64_LINUX26_ENV)
/* On this platform, it's in a different section! */
(unsigned long)&generic_ro_fops,
-#elif defined(AFS_AMD64_LINUX20_ENV)
- /* On this platform, it's in a different section! */
- (unsigned long)&tasklist_lock,
#else
(unsigned long)&init_mm,
#endif
(unsigned long)(&generic_ro_fops) - 0x30000,
0,
0x6000,
-#elif defined(AFS_AMD64_LINUX20_ENV)
- (unsigned long)(&tasklist_lock) - 0x30000,
- 0,
- 0x6000,
#elif defined(AFS_PPC64_LINUX26_ENV)
(unsigned long)(&do_signal),
0xfff,
0x400,
-#elif defined(AFS_PPC_LINUX20_ENV) || defined(AFS_PPC_LINUX20_ENV)
- (unsigned long)&init_mm,
- 0xffff,
- 16384,
#else
(unsigned long)&init_mm,
0,
16384,
#endif
-#ifdef AFS_LINUX26_ENV
(unsigned long)scsi_command_size,
(unsigned long)scsi_command_size - 0x10000,
0x3ffff,
0x40000,
-#else
- 0, 0, 0, 0,
-#endif
/* number and list of unimplemented system calls */
((sizeof(main_zapped_syscalls)/sizeof(main_zapped_syscalls[0])) - 1),
0,
(0x180000 / sizeof(unsigned long *)),
-#ifdef AFS_LINUX26_ENV
(unsigned long)scsi_command_size,
(unsigned long)scsi_command_size - 0x10000,
0x3ffff,
0x40000,
-#else
- 0, 0, 0, 0,
-#endif
/* number and list of unimplemented system calls */
16384,
#endif
-#ifdef AFS_LINUX26_ENV
(unsigned long)scsi_command_size,
(unsigned long)scsi_command_size - 0x10000,
0x3ffff,
0x40000,
-#else
- 0, 0, 0, 0,
-#endif
/* number and list of unimplemented system calls */
((sizeof(sct32_zapped_syscalls)/sizeof(sct32_zapped_syscalls[0])) - 1),
0xfffff,
0x20000,
-#ifdef AFS_LINUX26_ENV
(unsigned long)scsi_command_size,
(unsigned long)scsi_command_size - 0x10000,
0x3ffff,
0x40000,
-#else
- 0, 0, 0, 0,
-#endif
/* number and list of unimplemented system calls */
((sizeof(emu_zapped_syscalls)/sizeof(emu_zapped_syscalls[0])) - 1),
module_init(osi_probe_init);
module_exit(osi_probe_exit);
#endif
-#endif
+
#else
void *osi_find_syscall_table(int which)
{
int seq; /* Sequence number: this is incremented
* by wakeup calls; wait will not return until
* it changes */
-#if defined(AFS_LINUX24_ENV)
wait_queue_head_t cond;
-#else
- struct wait_queue *cond;
-#endif
} afs_event_t;
#define HASHSIZE 128
afs_evhashcnt++;
newp->next = afs_evhasht[hashcode];
afs_evhasht[hashcode] = newp;
-#if defined(AFS_LINUX24_ENV)
init_waitqueue_head(&newp->cond);
-#else
- init_waitqueue(&newp->cond);
-#endif
newp->seq = 0;
newp->event = &dummyV; /* Dummy address for new events */
newp->refcount = 0;
AFS_ASSERT_GLOCK();
AFS_GUNLOCK();
schedule();
-#ifdef AFS_LINUX26_ENV
#ifdef CONFIG_PM
if (
#ifdef PF_FREEZE
refrigerator();
#endif
#endif
-#endif
AFS_GLOCK();
if (signal_pending(current)) {
retval = EINTR;
code = EINTR;
} else
schedule_timeout(ticks);
-#ifdef AFS_LINUX26_ENV
#ifdef CONFIG_PM
if (
#ifdef PF_FREEZE
refrigerator();
#endif
#endif
-#endif
AFS_GLOCK();
remove_wait_queue(&evp->cond, &wait);
#include "afs/param.h"
-#ifdef AFS_LINUX24_ENV
#include <linux/module.h> /* early to avoid printf->printk mapping */
-#endif
#include "afs/sysincludes.h"
#include "afsincludes.h"
#include "h/unistd.h" /* For syscall numbers. */
#include <linux/proc_fs.h>
#include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#include <linux/init.h>
#include <linux/sched.h>
-#endif
#ifndef NR_syscalls
#define NR_syscalls 222
afs_sys_call_table[_S(SLOT)] = POINTER2SYSCALL FUNC;
#endif
-#if defined(AFS_S390X_LINUX24_ENV) && !defined(AFS_LINUX26_ENV)
-#define _S(x) ((x)<<1)
-#elif defined(AFS_IA64_LINUX20_ENV)
+#if defined(AFS_IA64_LINUX20_ENV)
#define _S(x) ((x)-1024)
#else
#define _S(x) x
extern long afs_xsetgroups(int gidsetsize, gid_t * grouplist);
asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist);
-#ifdef AFS_LINUX24_ENV
extern int afs_xsetgroups32(int gidsetsize, gid_t * grouplist);
asmlinkage int (*sys_setgroups32p) (int gidsetsize,
__kernel_gid32_t * grouplist);
-#endif
-
-#if !defined(AFS_LINUX24_ENV)
-asmlinkage int (*sys_settimeofdayp) (struct timeval * tv, struct timezone * tz);
-#endif
-
/***** AMD64 *****/
#ifdef AFS_AMD64_LINUX20_ENV
extern int afs32_xsetgroups();
asmlinkage long (*sys32_setgroupsp) (int gidsetsize, u16 * grouplist);
-#ifdef AFS_LINUX24_ENV
extern int afs32_xsetgroups32();
asmlinkage long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist);
-#endif /* __NR_ia32_setgroups32 */
#endif /* AFS_AMD64_LINUX20_ENV */
printf("*** error! sys32_setgroups_stub called\n");
}
-#endif /* AFS_AMD64_LINUX20_ENV */
+#endif /* AFS_PPC64_LINUX26_ENV */
/***** SPARC64 *****/
-#ifdef AFS_SPARC64_LINUX20_ENV
#ifdef AFS_SPARC64_LINUX26_ENV
static SYSCALLTYPE *afs_sys_call_table32;
-#else
-extern SYSCALLTYPE *afs_sys_call_table32;
-#endif
static SYSCALLTYPE afs_ni_syscall32 = 0;
extern int afs32_xsetgroups();
-#ifdef AFS_SPARC64_LINUX26_ENV
asmlinkage int (*sys32_setgroupsp) (int gidsetsize,
__kernel_gid32_t * grouplist);
-#else
-asmlinkage int (*sys32_setgroupsp) (int gidsetsize,
- __kernel_gid_t32 * grouplist);
-#endif
-#ifdef AFS_LINUX24_ENV
/* This number is not exported for some bizarre reason. */
#define __NR_setgroups32 82
extern int afs32_xsetgroups32();
-#ifdef AFS_SPARC64_LINUX26_ENV
asmlinkage int (*sys32_setgroups32p) (int gidsetsize,
__kernel_gid32_t * grouplist);
-#else
-asmlinkage int (*sys32_setgroups32p) (int gidsetsize,
- __kernel_gid_t32 * grouplist);
-#endif
-#endif
asmlinkage int
afs_syscall32(long syscall, long parm1, long parm2, long parm3, long parm4,
afs_sys_call_table = osi_find_syscall_table(0);
if (afs_sys_call_table) {
-#if !defined(AFS_LINUX24_ENV)
- /* XXX no sys_settimeofday on IA64? */
-#endif
-
/* check we aren't already loaded */
/* XXX this can't be right */
if (SYSCALL2POINTER afs_sys_call_table[_S(__NR_afs_syscall)]
afs_sys_call_table = osi_find_syscall_table(0);
if (afs_sys_call_table) {
-#if !defined(AFS_LINUX24_ENV)
- sys_settimeofdayp =
- SYSCALL2POINTER afs_sys_call_table[_S(__NR_settimeofday)];
-#endif /* AFS_LINUX24_ENV */
/* check we aren't already loaded */
if (SYSCALL2POINTER afs_sys_call_table[_S(__NR_afs_syscall)]
afs_ia32_sys_call_table[__NR_ia32_setgroups] =
POINTER2SYSCALL afs32_xsetgroups;
-#if AFS_LINUX24_ENV
/* setup setgroups32 for IA32 */
sys32_setgroups32p =
SYSCALL2POINTER afs_ia32_sys_call_table[__NR_ia32_setgroups32];
afs_ia32_sys_call_table[__NR_ia32_setgroups32] =
POINTER2SYSCALL afs32_xsetgroups32;
-#endif /* __NR_ia32_setgroups32 */
}
#endif /* AFS_AMD64_LINUX20_ENV */
sys32_setgroupsp = SYSCALL2POINTER afs_sys_call_table32[__NR_setgroups];
afs_sys_call_table32[__NR_setgroups] = POINTER2SYSCALL afs32_xsetgroups;
-#ifdef AFS_LINUX24_ENV
/* setup setgroups32 for 32-bit SPARC */
sys32_setgroups32p =
SYSCALL2POINTER afs_sys_call_table32[__NR_setgroups32];
afs_sys_call_table32[__NR_setgroups32] =
POINTER2SYSCALL afs32_xsetgroups32;
-#endif
}
#endif /* AFS_SPARC64_LINUX20_ENV */
return 0;
afs_ia32_sys_call_table[__NR_ia32_setgroups] =
POINTER2SYSCALL sys32_setgroupsp;
-#ifdef AFS_LINUX24_ENV
/* put back setgroups32 for IA32 */
afs_ia32_sys_call_table[__NR_ia32_setgroups32] =
POINTER2SYSCALL sys32_setgroups32p;
-#endif
}
#endif
afs_sys_call_table32[__NR_setgroups] =
POINTER2SYSCALL sys32_setgroupsp;
-#ifdef AFS_LINUX24_ENV
/* put back setgroups32 for IA32 */
afs_sys_call_table32[__NR_setgroups32] =
POINTER2SYSCALL sys32_setgroups32p;
-#endif
}
#endif
}
#include "afs/sysincludes.h"
#include "afsincludes.h"
#include "afs/afs_stats.h"
-#if !defined(AFS_LINUX26_ENV)
-#include "h/locks.h"
-#endif
-#if defined(AFS_LINUX24_ENV)
#include "h/smp_lock.h"
-#endif
struct vcache *afs_globalVp = 0;
struct vfs *afs_globalVFS = 0;
-#if defined(AFS_LINUX24_ENV)
struct vfsmount *afs_cacheMnt;
-#endif
int afs_was_mounted = 0; /* Used to force reload if mount/unmount/mount */
extern struct super_operations afs_sops;
-#if defined(AFS_LINUX26_ENV) && !defined(AFS_NONFSTRANS)
+#if !defined(AFS_NONFSTRANS)
extern struct export_operations afs_export_ops;
#endif
extern afs_rwlock_t afs_xvcache;
* read the "super block" for AFS - roughly eguivalent to struct vfs.
* dev, covered, s_rd_only, s_dirt, and s_type will be set by read_super.
*/
-#if defined(AFS_LINUX26_ENV)
#ifdef GET_SB_HAS_STRUCT_VFSMOUNT
int
afs_get_sb(struct file_system_type *fs_type, int flags,
.kill_sb = kill_anon_super,
.fs_flags = FS_BINARY_MOUNTDATA,
};
-#elif defined(AFS_LINUX24_ENV)
-DECLARE_FSTYPE(afs_fs_type, "afs", afs_read_super, 0);
-#else
-struct file_system_type afs_fs_type = {
- "afs", /* name - used by mount operation. */
- 0, /* requires_dev - no for network filesystems. mount() will
- * pass us an "unnamed" device. */
- afs_read_super, /* wrapper to afs_mount */
- NULL /* pointer to next file_system_type once registered. */
-};
-#endif
-#if defined(AFS_LINUX26_ENV)
struct backing_dev_info afs_backing_dev_info = {
.ra_pages = 32,
};
int
afs_fill_super(struct super_block *sb, void *data, int silent)
-#else
-struct super_block *
-afs_read_super(struct super_block *sb, void *data, int silent)
-#endif
{
int code = 0;
printf
("You must reload the AFS kernel extensions before remounting AFS.\n");
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
return -EINVAL;
-#else
- return NULL;
-#endif
}
afs_was_mounted = 1;
/* Set basics of super_block */
-#if !defined(AFS_LINUX24_ENV)
- lock_super(sb);
-#endif
-#if defined(AFS_LINUX26_ENV)
__module_get(THIS_MODULE);
-#else
- MOD_INC_USE_COUNT;
-#endif
afs_globalVFS = sb;
sb->s_blocksize = 1024;
#if defined(HAVE_BDI_INIT)
bdi_init(&afs_backing_dev_info);
#endif
-#if defined(AFS_LINUX26_ENV) && !defined(AFS_NONFSTRANS)
+#if !defined(AFS_NONFSTRANS)
sb->s_export_op = &afs_export_ops;
#endif
#if defined(MAX_NON_LFS)
code = afs_root(sb);
if (code) {
afs_globalVFS = NULL;
-#if defined(AFS_LINUX26_ENV)
module_put(THIS_MODULE);
-#else
- MOD_DEC_USE_COUNT;
-#endif
}
-#if !defined(AFS_LINUX24_ENV)
- unlock_super(sb);
-#endif
-
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
return code ? -EINVAL : 0;
-#else
- return code ? NULL : sb;
-#endif
}
/* setup super_block and mount point inode. */
afs_globalVp = tvp;
-#if defined(AFS_LINUX24_ENV)
afsp->s_root = d_alloc_root(ip);
-#else
- afsp->s_root = d_alloc_root(ip, NULL);
-#endif
afsp->s_root->d_op = &afs_dentry_operations;
} else
code = ENOENT;
VATTR_NULL(&vattr);
iattr2vattr(&vattr, iattrp); /* Convert for AFS vnodeops call. */
-#if defined(AFS_LINUX26_ENV)
lock_kernel();
-#endif
AFS_GLOCK();
code = afs_setattr(VTOAFS(ip), &vattr, credp);
if (!code) {
vattr2inode(ip, &vattr);
}
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
unlock_kernel();
-#endif
crfree(credp);
return -code;
}
static void
#if defined(HAVE_KMEM_CACHE_T)
init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
-#else
-#if defined(KMEM_CACHE_INIT)
+#elif defined(KMEM_CACHE_INIT)
init_once(struct kmem_cache * cachep, void * foo)
#else
init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
#endif
-#endif
{
struct vcache *vcp = (struct vcache *) foo;
AFS_GLOCK();
AFS_STATCNT(afs_unmount);
-#if !defined(AFS_LINUX26_ENV)
- if (!suser()) {
- AFS_GUNLOCK();
- return;
- }
-#endif
-
afs_globalVFS = 0;
afs_globalVp = 0;
osi_linux_free_inode_pages(); /* invalidate and release remaining AFS inodes. */
afs_shutdown();
-#if defined(AFS_LINUX24_ENV)
mntput(afs_cacheMnt);
-#endif
osi_linux_verify_alloced_memory();
#if defined(HAVE_BDI_INIT)
AFS_GUNLOCK();
sbp->s_dev = 0;
-#if defined(AFS_LINUX26_ENV)
module_put(THIS_MODULE);
-#else
- MOD_DEC_USE_COUNT;
-#endif
}
* statp is in user space, so we need to cobble together a statfs, then
* copy it.
*/
-#if defined(AFS_LINUX26_ENV)
int
#if defined(STATFS_TAKES_DENTRY)
afs_statfs(struct dentry *dentry, struct kstatfs *statp)
#else
afs_statfs(struct super_block *sbp, struct kstatfs *statp)
#endif
-#elif defined(AFS_LINUX24_ENV)
-int
-afs_statfs(struct super_block *sbp, struct statfs *statp)
-#else
-int
-afs_statfs(struct super_block *sbp, struct statfs *__statp, int size)
-#endif
{
-#if !defined(AFS_LINUX24_ENV)
- struct statfs stat, *statp;
-
- if (size < sizeof(struct statfs))
- return;
-
- memset(&stat, 0, size);
- statp = &stat;
-#else
memset(statp, 0, sizeof(*statp));
-#endif
AFS_STATCNT(afs_statfs);
statp->f_fsid.val[1] = AFS_VFSFSID;
statp->f_namelen = 256;
-#if !defined(AFS_LINUX24_ENV)
- memcpy_tofs(__statp, &stat, size);
-#endif
return 0;
}
.clear_inode = afs_clear_inode,
.put_super = afs_put_super,
.statfs = afs_statfs,
-#if !defined(AFS_LINUX24_ENV)
- .notify_change = afs_notify_change,
-#endif
};
/************** Support routines ************************/
if (iattrp->ia_valid & ATTR_SIZE)
vattrp->va_size = iattrp->ia_size;
if (iattrp->ia_valid & ATTR_ATIME) {
-#if defined(AFS_LINUX26_ENV)
vattrp->va_atime.tv_sec = iattrp->ia_atime.tv_sec;
-#else
- vattrp->va_atime.tv_sec = iattrp->ia_atime;
-#endif
vattrp->va_atime.tv_usec = 0;
}
if (iattrp->ia_valid & ATTR_MTIME) {
-#if defined(AFS_LINUX26_ENV)
vattrp->va_mtime.tv_sec = iattrp->ia_mtime.tv_sec;
-#else
- vattrp->va_mtime.tv_sec = iattrp->ia_mtime;
-#endif
vattrp->va_mtime.tv_usec = 0;
}
if (iattrp->ia_valid & ATTR_CTIME) {
-#if defined(AFS_LINUX26_ENV)
vattrp->va_ctime.tv_sec = iattrp->ia_ctime.tv_sec;
-#else
- vattrp->va_ctime.tv_sec = iattrp->ia_ctime;
-#endif
vattrp->va_ctime.tv_usec = 0;
}
}
ip->i_uid = vp->va_uid;
ip->i_gid = vp->va_gid;
i_size_write(ip, vp->va_size);
-#if defined(AFS_LINUX26_ENV)
ip->i_atime.tv_sec = vp->va_atime.tv_sec;
ip->i_atime.tv_nsec = 0;
ip->i_mtime.tv_sec = vp->va_mtime.tv_sec;
ip->i_mtime.tv_nsec = afs_sysnamegen;
ip->i_ctime.tv_sec = vp->va_ctime.tv_sec;
ip->i_ctime.tv_nsec = 0;
-#else
- ip->i_atime = vp->va_atime.tv_sec;
- ip->i_mtime = vp->va_mtime.tv_sec;
- ip->i_ctime = vp->va_ctime.tv_sec;
-#endif
}
/* osi_linux_free_inode_pages
if (avc->opens != 0)
return EBUSY;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
return vmtruncate(ip, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
- truncate_inode_pages(ip, 0);
-#else
- invalidate_inode_pages(ip);
-#endif
return 0;
}
{
struct inode *ip = AFSTOV(avc);
-#if defined(AFS_LINUX26_ENV)
invalidate_inode_pages(ip->i_mapping);
-#else
- invalidate_inode_pages(ip);
-#endif
}
/* Flush and invalidate pages, for fsync() with INVAL flag
if (avc->f.states & CPageWrite)
return; /* someone already writing */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
/* filemap_fdatasync() only exported in 2.4.5 and above */
ReleaseWriteLock(&avc->lock);
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
filemap_fdatawrite(ip->i_mapping);
-#else
- filemap_fdatasync(ip->i_mapping);
-#endif
filemap_fdatawait(ip->i_mapping);
AFS_GLOCK();
ObtainWriteLock(&avc->lock, 121);
-#endif
}
/* Purge VM for a file when its callback is revoked.
void
osi_VM_FlushPages(struct vcache *avc, AFS_UCRED *credp)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
struct inode *ip = AFSTOV(avc);
truncate_inode_pages(&ip->i_data, 0);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
- struct inode *ip = AFSTOV(avc);
-
- truncate_inode_pages(ip, 0);
-#else
- invalidate_inode_pages(AFSTOV(avc));
-#endif
}
/* Purge pages beyond end-of-file, when truncating a file.
void
osi_VM_Truncate(struct vcache *avc, int alen, AFS_UCRED *acred)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
vmtruncate(AFSTOV(avc), alen);
-#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
- struct inode *ip = AFSTOV(avc);
-
- truncate_inode_pages(ip, alen);
-#else
- invalidate_inode_pages(AFSTOV(avc));
-#endif
}
#include "h/mm_inline.h"
#endif
#include "h/pagemap.h"
-#if defined(AFS_LINUX24_ENV)
#include "h/smp_lock.h"
-#endif
-#if defined(AFS_LINUX26_ENV)
#include "h/writeback.h"
#include "h/pagevec.h"
-#endif
#if defined(AFS_CACHE_BYPASS)
#include "afs/lock.h"
#include "afs/afs_bypasscache.h"
#define MAX_ERRNO 1000L
#endif
-#if defined(AFS_LINUX26_ENV)
#define LockPage(pp) lock_page(pp)
#define UnlockPage(pp) unlock_page(pp)
extern struct backing_dev_info afs_backing_dev_info;
-#endif
extern struct vcache *afs_globalVp;
extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp);
-#if defined(AFS_LINUX24_ENV)
/* Some uses of BKL are perhaps not needed for bypass or memcache--
* why don't we try it out? */
extern struct afs_cacheOps afs_UfsCacheOps;
if(afs_cacheType == &afs_UfsCacheOps) \
unlock_kernel(); \
} while(0);
-#endif /* AFS_LINUX24_ENV */
/* This function converts a positive error code from AFS into a negative
cred_t *credp = crref();
struct afs_fakestat_state fakestat;
-#if defined(AFS_LINUX26_ENV)
maybe_lock_kernel();
-#endif
AFS_GLOCK();
AFS_STATCNT(afs_readdir);
}
/* filldir returns -EINVAL when the buffer is full. */
-#if defined(AFS_LINUX26_ENV) || ((defined(AFS_LINUX24_ENV) || defined(pgoff2loff)) && defined(DECLARE_FSTYPE))
{
unsigned int type = DT_UNKNOWN;
struct VenusFid afid;
code = (*filldir) (dirbuf, de->name, len, offset, ino, type);
AFS_GLOCK();
}
-#else
- code = (*filldir) (dirbuf, de->name, len, offset, ino);
-#endif
DRelease(de, 0);
if (code)
break;
afs_PutFakeStat(&fakestat);
out1:
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
return code;
}
int code;
AFS_GLOCK();
-#if defined(AFS_LINUX24_ENV)
afs_Trace3(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp,
ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32,
vmap->vm_end - vmap->vm_start);
-#else
- afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp,
- ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32,
- vmap->vm_end - vmap->vm_start, ICL_TYPE_INT32,
- vmap->vm_offset);
-#endif
/* get a validated vcache entry */
code = afs_linux_VerifyVCache(vcp, NULL);
cred_t *credp = crref();
int code;
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
code = afs_open(&vcp, fp->f_flags, credp);
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
cred_t *credp = crref();
int code = 0;
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
code = afs_close(vcp, fp->f_flags, credp);
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
}
static int
-#if defined(AFS_LINUX24_ENV)
afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync)
-#else
-afs_linux_fsync(struct file *fp, struct dentry *dp)
-#endif
{
int code;
struct inode *ip = FILE_INODE(fp);
cred_t *credp = crref();
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
code = afs_fsync(VTOAFS(ip), credp);
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
code = afs_lockctl(vcp, &flock, cmd, credp);
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
if ((code == 0 || flp->fl_type == F_UNLCK) &&
(cmd == F_SETLK || cmd == F_SETLKW)) {
-# ifdef POSIX_LOCK_FILE_WAIT_ARG
+#ifdef POSIX_LOCK_FILE_WAIT_ARG
code = posix_lock_file(fp, flp, 0);
-# else
+#else
flp->fl_flags &=~ FL_SLEEP;
code = posix_lock_file(fp, flp);
-# endif
+#endif
if (code && flp->fl_type != F_UNLCK) {
struct AFS_FLOCK flock2;
flock2 = flock;
* kernel, as lockctl knows nothing about byte range locks
*/
if (code == 0 && cmd == F_GETLK && flock.l_type == F_UNLCK) {
-# if defined(POSIX_TEST_LOCK_CONFLICT_ARG)
+#if defined(POSIX_TEST_LOCK_CONFLICT_ARG)
if (posix_test_lock(fp, flp, &conflict)) {
locks_copy_lock(flp, &conflict);
flp->fl_type = F_UNLCK;
crfree(credp);
return 0;
}
-# elif defined(POSIX_TEST_LOCK_RETURNS_CONFLICT)
+#elif defined(POSIX_TEST_LOCK_RETURNS_CONFLICT)
if ((conflict = posix_test_lock(fp, flp))) {
locks_copy_lock(flp, conflict);
flp->fl_type = F_UNLCK;
crfee(credp);
return 0;
}
-# else
+#else
posix_test_lock(fp, flp);
/* If we found a lock in the kernel's structure, return it */
if (flp->fl_type != F_UNLCK) {
crfree(credp);
return 0;
}
-# endif
+#endif
}
-#endif
/* Convert flock back to Linux's file_lock */
flp->fl_type = flock.l_type;
flp->fl_pid = flock.l_pid;
return afs_convert_code(code);
}
-#if !defined(AFS_LINUX24_ENV)
-/* Not allowed to directly read a directory. */
-ssize_t
-afs_linux_dir_read(struct file * fp, char *buf, size_t count, loff_t * ppos)
-{
- return -EISDIR;
-}
-#endif
-
-
-
struct file_operations afs_dir_fops = {
-#if !defined(AFS_LINUX24_ENV)
- .read = afs_linux_dir_read,
- .lock = afs_linux_lock,
- .fsync = afs_linux_fsync,
-#else
.read = generic_read_dir,
-#endif
.readdir = afs_linux_readdir,
#ifdef HAVE_UNLOCKED_IOCTL
.unlocked_ioctl = afs_unlocked_xioctl,
.mmap = afs_linux_mmap,
.open = afs_linux_open,
.flush = afs_linux_flush,
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_FILE_OPERATIONS_HAS_SENDFILE)
+#if defined(STRUCT_FILE_OPERATIONS_HAS_SENDFILE)
.sendfile = generic_file_sendfile,
#endif
-#if defined(AFS_LINUX26_ENV) && defined(STRUCT_FILE_OPERATIONS_HAS_SPLICE)
+#if defined(STRUCT_FILE_OPERATIONS_HAS_SPLICE)
.splice_write = generic_file_splice_write,
.splice_read = generic_file_splice_read,
#endif
if (afs_shuttingdown)
return EIO;
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
#ifdef notyet
check_bad_parent(dp); /* check and correct mvid */
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
unlock_kernel();
-#endif
return 0;
}
#endif
afs_fill_inode(AFSTOV(vcp), &vattr);
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
return afs_convert_code(code);
}
-#if defined(AFS_LINUX26_ENV)
static int
afs_linux_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
{
}
return err;
}
-#endif
/* Validate a dentry. Return 1 if unchanged, 0 if VFS layer should re-evaluate.
* In kernels 2.2.10 and above, we are passed an additional flags var which
* later on, we shouldn't have to do it until later. Perhaps in the future..
*/
static int
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
#ifdef DOP_REVALIDATE_TAKES_NAMEIDATA
afs_linux_dentry_revalidate(struct dentry *dp, struct nameidata *nd)
#else
afs_linux_dentry_revalidate(struct dentry *dp, int flags)
#endif
-#else
-afs_linux_dentry_revalidate(struct dentry *dp)
-#endif
{
struct vattr vattr;
cred_t *credp = NULL;
int valid;
struct afs_fakestat_state fakestate;
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
afs_InitFakeStat(&fakestate);
credp = crref();
code = afs_InitReq(&treq, credp);
if (
-#ifdef AFS_DARWIN_ENV
- (strcmp(dp->d_name.name, ".DS_Store") == 0) ||
- (strcmp(dp->d_name.name, "Contents") == 0) ||
-#endif
(strcmp(dp->d_name.name, ".directory") == 0)) {
tryEvalOnly = 1;
}
shrink_dcache_parent(dp);
d_drop(dp);
}
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
return valid;
bad_dentry:
}
AFS_GUNLOCK();
#ifdef DCACHE_NFSFS_RENAMED
-#ifdef AFS_LINUX26_ENV
spin_lock(&dp->d_lock);
-#endif
dp->d_flags &= ~DCACHE_NFSFS_RENAMED;
-#ifdef AFS_LINUX26_ENV
spin_unlock(&dp->d_lock);
#endif
-#endif
iput(ip);
}
vattr.va_mode = mode;
vattr.va_type = mode & S_IFMT;
-#if defined(AFS_LINUX26_ENV)
maybe_lock_kernel();
-#endif
AFS_GLOCK();
code = afs_create(VTOAFS(dip), (char *)name, &vattr, NONEXCL, mode,
&vcp, credp);
}
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
}
/* afs_linux_lookup */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
static struct dentry *
#ifdef IOP_LOOKUP_TAKES_NAMEIDATA
afs_linux_lookup(struct inode *dip, struct dentry *dp,
#else
afs_linux_lookup(struct inode *dip, struct dentry *dp)
#endif
-#else
-static int
-afs_linux_lookup(struct inode *dip, struct dentry *dp)
-#endif
{
cred_t *credp = crref();
struct vcache *vcp = NULL;
const char *comp = dp->d_name.name;
struct inode *ip = NULL;
-#if defined(AFS_LINUX26_ENV)
struct dentry *newdp = NULL;
-#endif
int code;
-#if defined(AFS_LINUX26_ENV)
maybe_lock_kernel();
-#endif
AFS_GLOCK();
code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp);
if (
#ifdef HAVE_KERNEL_HLIST_UNHASHED
hlist_unhashed(&ip->i_hash)
-#elif defined(AFS_LINUX26_ENV)
- ip->i_hash.pprev == NULL
#else
- ip->i_hash.prev == NULL
+ ip->i_hash.pprev == NULL
#endif
)
insert_inode_hash(ip);
dp->d_time = hgetlo(VTOAFS(dip)->f.m.DataVersion);
AFS_GUNLOCK();
-#if defined(AFS_LINUX24_ENV)
if (ip && S_ISDIR(ip->i_mode)) {
struct dentry *alias;
/* Try to invalidate an existing alias in favor of our new one */
alias = d_find_alias(ip);
-#if defined(AFS_LINUX26_ENV)
/* But not if it's disconnected; then we want d_splice_alias below */
if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) {
-#else
- if (alias) {
-#endif
if (d_invalidate(alias) == 0) {
dput(alias);
} else {
iput(ip);
-#if defined(AFS_LINUX26_ENV)
unlock_kernel();
-#endif
crfree(credp);
return alias;
}
}
}
-#endif
-#if defined(AFS_LINUX26_ENV)
newdp = d_splice_alias(ip, dp);
-#else
- d_add(dp, ip);
-#endif
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
crfree(credp);
/* It's ok for the file to not be found. That's noted by the caller by
* seeing that the dp->d_inode field is NULL.
*/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
-#if defined(AFS_LINUX26_ENV)
if (!code || code == ENOENT)
return newdp;
-#else
- if (code == ENOENT)
- return ERR_PTR(0);
-#endif
else
return ERR_PTR(afs_convert_code(code));
-#else
- if (code == ENOENT)
- code = 0;
- return afs_convert_code(code);
-#endif
}
static int
const char *name = dp->d_name.name;
struct vcache *tvc = VTOAFS(dp->d_inode);
-#if defined(AFS_LINUX26_ENV)
maybe_lock_kernel();
-#endif
if (VREFCOUNT(tvc) > 1 && tvc->opens > 0
&& !(tvc->f.states & CUnlinked)) {
struct dentry *__dp;
tvc->uncred = credp;
tvc->f.states |= CUnlinked;
#ifdef DCACHE_NFSFS_RENAMED
-#ifdef AFS_LINUX26_ENV
spin_lock(&dp->d_lock);
-#endif
dp->d_flags |= DCACHE_NFSFS_RENAMED;
-#ifdef AFS_LINUX26_ENV
spin_unlock(&dp->d_lock);
#endif
-#endif
} else {
osi_FreeSmallSpace(__name);
}
if (!code)
d_drop(dp);
out:
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
}
struct vattr vattr;
const char *name = dp->d_name.name;
-#if defined(AFS_LINUX26_ENV)
maybe_lock_kernel();
-#endif
VATTR_NULL(&vattr);
vattr.va_mask = ATTR_MODE;
vattr.va_mode = mode;
}
AFS_GUNLOCK();
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
}
const char *newname = newdp->d_name.name;
struct dentry *rehash = NULL;
-#if defined(AFS_LINUX26_ENV)
/* Prevent any new references during rename operation. */
maybe_lock_kernel();
d_drop(newdp);
rehash = newdp;
}
-#else
- if (!list_empty(&newdp->d_hash)) {
- d_drop(newdp);
- rehash = newdp;
- }
-#endif
-#if defined(AFS_LINUX24_ENV)
if (atomic_read(&olddp->d_count) > 1)
shrink_dcache_parent(olddp);
-#endif
AFS_GLOCK();
code = afs_rename(VTOAFS(oldip), (char *)oldname, VTOAFS(newip), (char *)newname, credp);
if (rehash)
d_rehash(rehash);
-#if defined(AFS_LINUX26_ENV)
maybe_unlock_kernel();
-#endif
crfree(credp);
return afs_convert_code(code);
/* afs_linux_follow_link
* a file system dependent link following routine.
*/
-#if defined(AFS_LINUX24_ENV)
static int afs_linux_follow_link(struct dentry *dentry, struct nameidata *nd)
{
int code;
return code;
}
-#else /* !defined(AFS_LINUX24_ENV) */
-
-static struct dentry *
-afs_linux_follow_link(struct dentry *dp, struct dentry *basep,
- unsigned int follow)
-{
- int code = 0;
- char *name;
- struct dentry *res;
-
-
- AFS_GLOCK();
- name = osi_Alloc(PATH_MAX + 1);
- if (!name) {
- AFS_GUNLOCK();
- dput(basep);
- return ERR_PTR(-EIO);
- }
-
- code = afs_linux_ireadlink(dp->d_inode, name, PATH_MAX, AFS_UIOSYS);
- AFS_GUNLOCK();
-
- if (code < 0) {
- dput(basep);
- if (code < -MAX_ERRNO)
- res = ERR_PTR(-EIO);
- else
- res = ERR_PTR(code);
- } else {
- name[code] = '\0';
- res = lookup_dentry(name, basep, follow);
- }
-
- AFS_GLOCK();
- osi_Free(name, PATH_MAX + 1);
- AFS_GUNLOCK();
- return res;
-}
-#endif /* AFS_LINUX24_ENV */
#endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */
#if defined(AFS_CACHE_BYPASS)
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-
static inline int
afs_linux_can_bypass(struct inode *ip) {
switch(cache_bypass_strategy) {
return afs_convert_code(code);
}
-#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
#endif /* defined(AFS_CACHE_BYPASS */
static int
afs_linux_readpage(struct file *fp, struct page *pp)
{
afs_int32 code;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
char *address;
afs_offs_t offset = ((loff_t) pp->index) << PAGE_CACHE_SHIFT;
-#else
- ulong address = afs_linux_page_address(pp);
- afs_offs_t offset = pageoff(pp);
-#endif
#if defined(AFS_CACHE_BYPASS)
afs_int32 bypasscache = 0; /* bypass for this read */
struct nocache_read_request *ancr;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
afs_int32 isize;
#endif
-#endif
uio_t *auio;
struct iovec *iovecp;
struct inode *ip = FILE_INODE(fp);
struct vcache *avc = VTOAFS(ip);
cred_t *credp;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
AFS_GLOCK();
if (afs_linux_readpage_fastpath(fp, pp, &code)) {
AFS_GUNLOCK();
return code;
}
AFS_GUNLOCK();
-#endif
credp = crref();
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
address = kmap(pp);
ClearPageError(pp);
-#else
- atomic_add(1, &pp->count);
- set_bit(PG_locked, &pp->flags); /* other bits? See mm.h */
- clear_bit(PG_error, &pp->flags);
-#endif
+
/* if bypasscache, receiver frees, else we do */
auio = osi_Alloc(sizeof(uio_t));
iovecp = osi_Alloc(sizeof(struct iovec));
}
#endif
-#ifdef AFS_LINUX24_ENV
maybe_lock_kernel();
-#endif
AFS_GLOCK();
AFS_DISCON_LOCK();
afs_Trace4(afs_iclSetp, CM_TRACE_READPAGE, ICL_TYPE_POINTER, ip,
code);
AFS_DISCON_UNLOCK();
AFS_GUNLOCK();
-#ifdef AFS_LINUX24_ENV
maybe_unlock_kernel();
-#endif
if (!code) {
/* XXX valid for no-cache also? Check last bits of files... :)
* Cognate code goes in afs_NoCacheFetchProc. */
memset((void *)(address + (PAGE_SIZE - auio->uio_resid)), 0,
auio->uio_resid);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
flush_dcache_page(pp);
SetPageUptodate(pp);
-#else
- set_bit(PG_uptodate, &pp->flags);
-#endif
} /* !code */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
kunmap(pp);
UnlockPage(pp);
-#else
- clear_bit(PG_locked, &pp->flags);
- wake_up(&pp->wait);
- free_page(address);
-#endif
#if defined(AFS_CACHE_BYPASS)
/* do not call afs_GetDCache if cache is bypassed */
return 0;
}
-#if defined(AFS_LINUX24_ENV)
static int
afs_linux_writepage_sync(struct inode *ip, struct page *pp,
unsigned long offset, unsigned int count)
maybe_unlock_kernel();
crfree(credp);
kunmap(pp);
-#ifdef AFS_LINUX26_ENV
#if defined(WRITEPAGE_ACTIVATE)
return WRITEPAGE_ACTIVATE;
#else
return AOP_WRITEPAGE_ACTIVATE;
#endif
-#else
- /* should mark it dirty? */
- return(0);
-#endif
}
vcp->f.states |= CPageWrite;
ReleaseWriteLock(&vcp->lock);
unsigned offset = PAGE_CACHE_SIZE;
long status;
-#if defined(AFS_LINUX26_ENV)
if (PageReclaim(pp)) {
-# if defined(WRITEPAGE_ACTIVATE)
+#if defined(WRITEPAGE_ACTIVATE)
return WRITEPAGE_ACTIVATE;
-# else
- return AOP_WRITEPAGE_ACTIVATE;
-# endif
- }
#else
- if (PageLaunder(pp)) {
- return(fail_writepage(pp));
- }
+ return AOP_WRITEPAGE_ACTIVATE;
#endif
+ }
inode = (struct inode *)mapping->host;
end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
do_it:
status = afs_linux_writepage_sync(inode, pp, 0, offset);
SetPageUptodate(pp);
-#if defined(AFS_LINUX26_ENV)
#if defined(WRITEPAGE_ACTIVATE)
if ( status != WRITEPAGE_ACTIVATE )
#else
if ( status != AOP_WRITEPAGE_ACTIVATE )
#endif
-#endif
UnlockPage(pp);
if (status == offset)
return 0;
else
return status;
}
-#else
-/* afs_linux_updatepage
- * What one would have thought was writepage - write dirty page to file.
- * Called from generic_file_write. buffer is still in user space. pagep
- * has been filled in with old data if we're updating less than a page.
- */
-static int
-afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset,
- unsigned int count, int sync)
-{
- struct vcache *vcp = VTOAFS(FILE_INODE(fp));
- u8 *page_addr = (u8 *) afs_linux_page_address(pp);
- int code = 0;
- cred_t *credp;
- uio_t tuio;
- struct iovec iovec;
-
- set_bit(PG_locked, &pp->flags);
-
- credp = crref();
- AFS_GLOCK();
- AFS_DISCON_LOCK();
- afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
- ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
- ICL_TYPE_INT32, 99999);
- setup_uio(&tuio, &iovec, page_addr + offset,
- (afs_offs_t) (pageoff(pp) + offset), count, UIO_WRITE,
- AFS_UIOSYS);
-
- code = afs_write(vcp, &tuio, fp->f_flags, credp, 0);
-
- i_size_write(ip, vcp->f.m.Length);
- ip->i_blocks = ((vcp->f.m.Length + 1023) >> 10) << 1;
-
- if (!code) {
- struct vrequest treq;
-
- ObtainWriteLock(&vcp->lock, 533);
- vcp->f.m.Date = osi_Time(); /* set modification time */
- if (!afs_InitReq(&treq, credp))
- code = afs_DoPartialWrite(vcp, &treq);
- ReleaseWriteLock(&vcp->lock);
- }
-
- code = code ? afs_convert_code(code) : count - tuio.uio_resid;
- afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
- ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
- ICL_TYPE_INT32, code);
-
- AFS_DISCON_UNLOCK();
- AFS_GUNLOCK();
- crfree(credp);
-
- clear_bit(PG_locked, &pp->flags);
- return code;
-}
-#endif
/* afs_linux_permission
* Check access rights - returns error if can't check or permission denied.
return afs_convert_code(code);
}
-#if defined(AFS_LINUX24_ENV) && !defined(HAVE_WRITE_BEGIN)
+#if !defined(HAVE_WRITE_BEGIN)
static int
afs_linux_commit_write(struct file *file, struct page *page, unsigned offset,
unsigned to)
code = afs_linux_writepage_sync(file->f_dentry->d_inode, page,
offset, to - offset);
-#if !defined(AFS_LINUX26_ENV)
- kunmap(page);
-#endif
return code;
}
afs_linux_prepare_write(struct file *file, struct page *page, unsigned from,
unsigned to)
{
-/* sometime between 2.4.0 and 2.4.19, the callers of prepare_write began to
- call kmap directly instead of relying on us to do it */
-#if !defined(AFS_LINUX26_ENV)
- kmap(page);
-#endif
return 0;
}
-#endif
+#else
-#if defined(HAVE_WRITE_BEGIN)
static int
afs_linux_write_end(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned copied,
static struct inode_operations afs_file_iops = {
-#if defined(AFS_LINUX26_ENV)
.permission = afs_linux_permission,
.getattr = afs_linux_getattr,
.setattr = afs_notify_change,
-#elif defined(AFS_LINUX24_ENV)
- .permission = afs_linux_permission,
- .revalidate = afs_linux_revalidate,
- .setattr = afs_notify_change,
-#else
- .default_file_ops = &afs_file_fops,
- .readpage = afs_linux_readpage,
- .revalidate = afs_linux_revalidate,
- .updatepage = afs_linux_updatepage,
-#endif
};
-#if defined(AFS_LINUX24_ENV)
static struct address_space_operations afs_file_aops = {
.readpage = afs_linux_readpage,
.readpages = afs_linux_readpages,
.prepare_write = afs_linux_prepare_write,
#endif
};
-#endif
/* Separate ops vector for directories. Linux 2.2 tests type of inode
*/
static struct inode_operations afs_dir_iops = {
-#if !defined(AFS_LINUX24_ENV)
- .default_file_ops = &afs_dir_fops,
-#else
.setattr = afs_notify_change,
-#endif
.create = afs_linux_create,
.lookup = afs_linux_lookup,
.link = afs_linux_link,
.mkdir = afs_linux_mkdir,
.rmdir = afs_linux_rmdir,
.rename = afs_linux_rename,
-#if defined(AFS_LINUX26_ENV)
.getattr = afs_linux_getattr,
-#else
- .revalidate = afs_linux_revalidate,
-#endif
.permission = afs_linux_permission,
};
static struct inode_operations afs_symlink_iops = {
#if defined(USABLE_KERNEL_PAGE_SYMLINK_CACHE)
.readlink = page_readlink,
-#if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
+# if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
.follow_link = page_follow_link,
-#else
+# else
.follow_link = page_follow_link_light,
.put_link = page_put_link,
-#endif
+# endif
#else /* !defined(USABLE_KERNEL_PAGE_SYMLINK_CACHE) */
.readlink = afs_linux_readlink,
.follow_link = afs_linux_follow_link,
-#if !defined(AFS_LINUX24_ENV)
- .permission = afs_linux_permission,
- .revalidate = afs_linux_revalidate,
-#endif
#endif /* USABLE_KERNEL_PAGE_SYMLINK_CACHE */
-#if defined(AFS_LINUX24_ENV)
.setattr = afs_notify_change,
-#endif
};
void
if (vattr)
vattr2inode(ip, vattr);
-#if defined(AFS_LINUX26_ENV)
ip->i_mapping->backing_dev_info = &afs_backing_dev_info;
-#endif
/* Reset ops if symlink or directory. */
if (S_ISREG(ip->i_mode)) {
ip->i_op = &afs_file_iops;
-#if defined(AFS_LINUX24_ENV)
ip->i_fop = &afs_file_fops;
ip->i_data.a_ops = &afs_file_aops;
-#endif
} else if (S_ISDIR(ip->i_mode)) {
ip->i_op = &afs_dir_iops;
-#if defined(AFS_LINUX24_ENV)
ip->i_fop = &afs_dir_fops;
-#endif
} else if (S_ISLNK(ip->i_mode)) {
ip->i_op = &afs_symlink_iops;