From 3239d37b3094d81bed35e09ad264cf72a20c198b Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 18 Oct 2004 18:43:44 +0000 Subject: [PATCH] STABLE14-resync-20041018 cheat. pull in all the 1.3.72->head changes in one delta --- configure-libafs.in | 2 +- configure.in | 2 +- src/WINNT/pthread/pthread.c | 20 ++++--- src/afs/LINUX/osi_module.c | 15 ------ src/afs/LINUX/osi_vnodeops.c | 17 +++--- src/afs/VNOPS/afs_vnop_create.c | 8 +-- src/afs/VNOPS/afs_vnop_dirops.c | 10 ++-- src/afs/VNOPS/afs_vnop_link.c | 4 +- src/afs/VNOPS/afs_vnop_lookup.c | 12 ++--- src/afs/VNOPS/afs_vnop_readdir.c | 26 ++------- src/afs/VNOPS/afs_vnop_remove.c | 6 +-- src/afs/VNOPS/afs_vnop_rename.c | 22 ++++---- src/afs/VNOPS/afs_vnop_symlink.c | 4 +- src/afs/afs.h | 4 +- src/afs/afs_dcache.c | 6 +-- src/afs/afs_pioctl.c | 18 ++++--- src/afs/afs_segments.c | 8 ++- src/afs/afs_vcache.c | 15 ++++-- src/bozo/bos.c | 2 +- src/butc/tcmain.c | 4 +- src/cf/osconf.m4 | 4 +- src/config/afs_sysnames.h | 2 + src/des/Makefile.in | 4 +- src/des/des.c | 29 ++++++----- src/libafs/MakefileProto.LINUX.in | 24 ++++----- src/rx/LINUX/rx_knet.c | 5 ++ src/rx/rx.c | 30 +++++++++-- src/rx/rx_packet.c | 7 ++- src/rx/rx_user.c | 27 ++++++---- src/rx/rxdebug.c | 4 ++ src/rxkad/domestic/fcrypt.c | 20 +++---- src/rxkad/rxkad.p.h | 5 -- src/rxkad/rxkad_prototypes.h | 4 +- src/sys/pioctl_nt.c | 87 +++++++++++++++++++++++-------- src/ubik/beacon.c | 3 +- src/ubik/ubik.p.h | 11 ++++ src/util/snprintf.c | 8 +-- src/vol/namei_ops.c | 27 +++++----- src/vol/nuke.c | 19 ++++--- src/vol/vol-salvage.c | 4 +- 40 files changed, 315 insertions(+), 214 deletions(-) diff --git a/configure-libafs.in b/configure-libafs.in index e2bc7a75b..eaf1f0a5b 100644 --- a/configure-libafs.in +++ b/configure-libafs.in @@ -1,5 +1,5 @@ AC_INIT(src/libafs/Makefile.common.in) -AM_INIT_AUTOMAKE(openafs-libafs,1.3.72) +AM_INIT_AUTOMAKE(openafs-libafs,1.3.73) AC_CONFIG_HEADER(src/config/afsconfig.h) define(OPENAFS_CONFIGURE_LIBAFS) diff --git a/configure.in b/configure.in index 84067d4ff..298ae1841 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(src/config/stds.h) -AM_INIT_AUTOMAKE(openafs,1.3.72) +AM_INIT_AUTOMAKE(openafs,1.3.73) AC_CONFIG_HEADER(src/config/afsconfig.h) AC_PROG_CC diff --git a/src/WINNT/pthread/pthread.c b/src/WINNT/pthread/pthread.c index 4c72ab6c1..33a17a4a0 100644 --- a/src/WINNT/pthread/pthread.c +++ b/src/WINNT/pthread/pthread.c @@ -590,11 +590,14 @@ static void pthread_sync_terminate_thread(void) { (pthread_cache_done || pthread_once(&pthread_cache_once, create_once)); if (terminate_thread_handle == INVALID_HANDLE_VALUE) { - terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, - TRUE, FALSE, (LPCTSTR) 0); - terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, - terminate_thread_routine, (LPVOID) 0, 0, - &terminate_thread_id); + CHAR eventName[MAX_PATH]; + static eventCount = 0; + sprintf(eventName, "terminate_thread_wakeup_event %d::%d", _getpid(), eventCount++); + terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, + TRUE, FALSE, (LPCTSTR) eventName); + terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, + terminate_thread_routine, (LPVOID) 0, 0, + &terminate_thread_id); } else { SetEvent (terminate_thread_wakeup_event); } @@ -711,8 +714,11 @@ static cond_waiters_t *get_waiter() { if (queue_IsEmpty(&waiter_cache)) { new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t)); if (new != NULL) { - new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE, - FALSE, (LPCTSTR) 0); + CHAR eventName[MAX_PATH]; + static eventCount = 0; + sprintf(eventName, "cond_waiters_t %d::%d", _getpid(), eventCount++); + new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE, + FALSE, (LPCTSTR) eventName); if (new->event == NULL) { free(new); new = NULL; diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index dba52d595..af2d9503e 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -223,11 +223,6 @@ asmlinkage int (*sys_setgroups32p) (int gidsetsize, #define SYSCALL2POINTER (void *) #endif -#ifdef AFS_PPC64_LINUX20_ENV -extern void *set_afs_syscall(void*); -extern void *set_afs_xsetgroups_syscall(void*); -extern void *set_afs_xsetgroups_syscall32(void*); -#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) int __init @@ -525,11 +520,6 @@ init_module(void) #endif /* AFS_AMD64_LINUX20_ENV */ #endif /* AFS_IA64_LINUX20_ENV */ -#ifdef AFS_PPC64_LINUX20_ENV - afs_ni_syscall = set_afs_syscall(afs_syscall); - sys_setgroupsp = set_afs_xsetgroups_syscall(afs_xsetgroups); - sys32_setgroupsp = set_afs_xsetgroups_syscall32(afs32_xsetgroups); -#endif } osi_sysctl_init(); @@ -582,11 +572,6 @@ cleanup_module(void) } #endif } -#ifdef AFS_PPC64_LINUX20_ENV - set_afs_syscall(afs_ni_syscall); - set_afs_xsetgroups_syscall(sys_setgroupsp); - set_afs_xsetgroups_syscall32(sys32_setgroupsp); -#endif unregister_filesystem(&afs_fs_type); osi_linux_free_inode_pages(); /* Invalidate all pages using AFS inodes. */ diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 4025b5a75..8178d0bbe 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -333,11 +333,11 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) code = 0; offset = (int) fp->f_pos; while (1) { - dirpos = BlobScan(&tdc->f.inode, offset); + dirpos = BlobScan(&tdc->f, offset); if (!dirpos) break; - de = afs_dir_GetBlob(&tdc->f.inode, dirpos); + de = afs_dir_GetBlob(&tdc->f, dirpos); if (!de) break; @@ -649,12 +649,7 @@ afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp) int code = 0; struct vcache *vcp = ITOAFS(FILE_INODE(fp)); cred_t *credp = crref(); -#ifdef AFS_LINUX24_ENV - struct flock64 flock; -#else - struct flock flock; -#endif - + struct AFS_FLOCK flock; /* Convert to a lock format afs_lockctl understands. */ memset((char *)&flock, 0, sizeof(flock)); flock.l_type = flp->fl_type; @@ -1485,6 +1480,12 @@ afs_linux_writepage(struct page *pp) unsigned offset = PAGE_CACHE_SIZE; long status; +#ifdef PageLaunder + if (PageLaunder(pp)) { + return(fail_writepage(pp)); + } +#endif + inode = (struct inode *)mapping->host; end_index = inode->i_size >> PAGE_CACHE_SHIFT; diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index ad0f0e0c8..c16f411b9 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -154,7 +154,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, if (tdc) { /* see if file already exists. If it does, we only set * the size attributes (to handle O_TRUNC) */ - code = afs_dir_Lookup(&tdc->f.inode, aname, &newFid.Fid); /* use dnlc first xxx */ + code = afs_dir_Lookup(&tdc->f, aname, &newFid.Fid); /* use dnlc first xxx */ if (code == 0) { ReleaseSharedLock(&tdc->lock); afs_PutDCache(tdc); @@ -368,10 +368,10 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, UpgradeSToWLock(&tdc->lock, 631); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); + code = afs_dir_Create(&tdc->f, aname, &newFid.Fid); if (code) { ZapDCE(tdc); - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { @@ -531,7 +531,7 @@ afs_LocalHero(register struct vcache *avc, register struct dcache *adc, } else { if (adc) { ZapDCE(adc); - DZap(&adc->f.inode); + DZap(&adc->f); } if (avc->states & CStatd) { osi_dnlc_purgedp(avc); diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c index 8f71cd136..0cd7cedd5 100644 --- a/src/afs/VNOPS/afs_vnop_dirops.c +++ b/src/afs/VNOPS/afs_vnop_dirops.c @@ -147,10 +147,10 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) ObtainWriteLock(&tdc->lock, 632); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); + code = afs_dir_Create(&tdc->f, aname, &newFid.Fid); if (code) { ZapDCE(tdc); /* surprise error -- use invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { @@ -250,7 +250,7 @@ afs_rmdir(adp, aname, acred) struct VenusFid unlinkFid; unlinkFid.Fid.Vnode = 0; - code = afs_dir_Lookup(&tdc->f.inode, aname, &unlinkFid.Fid); + code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid); if (code == 0) { afs_int32 cached = 0; @@ -304,10 +304,10 @@ afs_rmdir(adp, aname, acred) UpgradeSToWLock(&tdc->lock, 634); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Delete(&tdc->f.inode, aname); + code = afs_dir_Delete(&tdc->f, aname); if (code) { ZapDCE(tdc); /* surprise error -- invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { diff --git a/src/afs/VNOPS/afs_vnop_link.c b/src/afs/VNOPS/afs_vnop_link.c index e48ca7831..22ac2bc1c 100644 --- a/src/afs/VNOPS/afs_vnop_link.c +++ b/src/afs/VNOPS/afs_vnop_link.c @@ -137,10 +137,10 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) ObtainWriteLock(&tdc->lock, 635); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Create(&tdc->f.inode, aname, &avc->fid.Fid); + code = afs_dir_Create(&tdc->f, aname, &avc->fid.Fid); if (code) { ZapDCE(tdc); /* surprise error -- invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index bb908163d..8add8d8c7 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -674,7 +674,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) /* look for first safe entry to examine in the directory. BlobScan * looks for a the 1st allocated dir after the dirCookie slot. */ - newIndex = BlobScan(&dcp->f.inode, (dirCookie >> 5)); + newIndex = BlobScan(&dcp->f, (dirCookie >> 5)); if (newIndex == 0) break; @@ -683,7 +683,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) /* get a ptr to the dir entry */ dirEntryp = - (struct DirEntry *)afs_dir_GetBlob(&dcp->f.inode, newIndex); + (struct DirEntry *)afs_dir_GetBlob(&dcp->f, newIndex); if (!dirEntryp) break; @@ -1293,7 +1293,7 @@ afs_lookup(adp, aname, avcp, acred) { /* sub-block just to reduce stack usage */ register struct dcache *tdc; afs_size_t dirOffset, dirLen; - ino_t theDir; + struct fcache *theDir; struct VenusFid tfid; /* now we have to lookup the next fid */ @@ -1351,15 +1351,15 @@ afs_lookup(adp, aname, avcp, acred) /* lookup the name in the appropriate dir, and return a cache entry * on the resulting fid */ - theDir = tdc->f.inode; + theDir = &tdc->f; code = - afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, + afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid, &dirCookie); /* If the first lookup doesn't succeed, maybe it's got @sys in the name */ while (code == ENOENT && Next_AtSys(adp, &treq, &sysState)) code = - afs_dir_LookupOffset(&theDir, sysState.name, &tfid.Fid, + afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid, &dirCookie); tname = sysState.name; diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index c681c136a..d1d0330ae 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -66,24 +66,8 @@ extern struct DirEntry *afs_dir_GetBlob(); BlobScan is used by the Linux port in a separate file, so it should not become static. */ -#if defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV) int -BlobScan(ino64_t * afile, afs_int32 ablob) -#else -#if defined(AFS_HPUX1123_ENV) -/*DEE should use afs_inode_t for all */ -int -BlobScan(ino_t * afile, afs_int32 ablob) -#else -#ifdef AFS_LINUX_64BIT_KERNEL -int -BlobScan(long *afile, afs_int32 ablob) -#else -int -BlobScan(afs_int32 * afile, afs_int32 ablob) -#endif -#endif -#endif +BlobScan(struct fcache * afile, afs_int32 ablob) { register afs_int32 relativeBlob; afs_int32 pageBlob; @@ -657,8 +641,8 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred) origOffset = auio->afsio_offset; /* scan for the next interesting entry scan for in-use blob otherwise up point at * this blob note that ode, if non-zero, also represents a held dir page */ - if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5))) - || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f.inode, us))) { + if (!(us = BlobScan(&tdc->f, (origOffset >> 5))) + || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) { /* failed to setup nde, return what we've got, and release ode */ if (len) { /* something to hand over. */ @@ -948,8 +932,8 @@ afs1_readdir(avc, auio, acred) /* scan for the next interesting entry scan for in-use blob otherwise up point at * this blob note that ode, if non-zero, also represents a held dir page */ - if (!(us = BlobScan(&tdc->f.inode, (origOffset >> 5))) - || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f.inode, us))) { + if (!(us = BlobScan(&tdc->f, (origOffset >> 5))) + || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) { /* failed to setup nde, return what we've got, and release ode */ if (len) { /* something to hand over. */ diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 7b2583310..363bc2290 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -154,10 +154,10 @@ afsremove(register struct vcache *adp, register struct dcache *tdc, UpgradeSToWLock(&tdc->lock, 637); if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Delete(&tdc->f.inode, aname); + code = afs_dir_Delete(&tdc->f, aname); if (code) { ZapDCE(tdc); /* surprise error -- invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { @@ -357,7 +357,7 @@ afs_remove(OSI_VC_ARG(adp), aname, acred) * done the work */ if (!tvc) if (tdc) { - code = afs_dir_Lookup(&tdc->f.inode, aname, &unlinkFid.Fid); + code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid); if (code == 0) { afs_int32 cached = 0; diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c index cd71a798f..642c421e7 100644 --- a/src/afs/VNOPS/afs_vnop_rename.c +++ b/src/afs/VNOPS/afs_vnop_rename.c @@ -146,7 +146,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, } if (code == 0) - code = afs_dir_Lookup(&tdc1->f.inode, aname1, &fileFid.Fid); + code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid); if (code) { if (tdc1) { ReleaseWriteLock(&tdc1->lock); @@ -205,38 +205,38 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, if (!doLocally) { if (tdc1) { ZapDCE(tdc1); - DZap(&tdc1->f.inode); + DZap(&tdc1->f); } if (tdc2) { ZapDCE(tdc2); - DZap(&tdc2->f.inode); + DZap(&tdc2->f); } } } /* now really do the work */ if (doLocally) { /* first lookup the fid of the dude we're moving */ - code = afs_dir_Lookup(&tdc1->f.inode, aname1, &fileFid.Fid); + code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid); if (code == 0) { /* delete the source */ - code = afs_dir_Delete(&tdc1->f.inode, aname1); + code = afs_dir_Delete(&tdc1->f, aname1); } /* first see if target is there */ if (code == 0 - && afs_dir_Lookup(&tdc2->f.inode, aname2, + && afs_dir_Lookup(&tdc2->f, aname2, &unlinkFid.Fid) == 0) { /* target already exists, and will be unlinked by server */ - code = afs_dir_Delete(&tdc2->f.inode, aname2); + code = afs_dir_Delete(&tdc2->f, aname2); } if (code == 0) { - code = afs_dir_Create(&tdc2->f.inode, aname2, &fileFid.Fid); + code = afs_dir_Create(&tdc2->f, aname2, &fileFid.Fid); } if (code != 0) { ZapDCE(tdc1); - DZap(&tdc1->f.inode); + DZap(&tdc1->f); if (!oneDir) { ZapDCE(tdc2); - DZap(&tdc2->f.inode); + DZap(&tdc2->f); } } } @@ -339,7 +339,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, if (tdc1) { ObtainWriteLock(&tdc1->lock, 648); ZapDCE(tdc1); /* mark as unknown */ - DZap(&tdc1->f.inode); + DZap(&tdc1->f); ReleaseWriteLock(&tdc1->lock); afs_PutDCache(tdc1); /* put it back */ } diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index b33f970b4..cd5008d5c 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -184,10 +184,10 @@ int afs_symlink /* otherwise, we should see if we can make the change to the dir locally */ if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Create(&tdc->f.inode, aname, &newFid.Fid); + code = afs_dir_Create(&tdc->f, aname, &newFid.Fid); if (code) { ZapDCE(tdc); /* surprise error -- use invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } if (tdc) { diff --git a/src/afs/afs.h b/src/afs/afs.h index 11e4843e5..334277dd4 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -43,7 +43,7 @@ extern int afs_shuttingdown; #if defined(AFS_HPUX102_ENV) #define AFS_FLOCK k_flock #else -#if defined(AFS_SUN56_ENV) || defined(AFS_LINUX24_ENV) +#if defined(AFS_SUN56_ENV) || (defined(AFS_LINUX24_ENV) && !defined(AFS_PPC64_LINUX26_ENV) && !defined(AFS_AMD64_LINUX26_ENV)) #define AFS_FLOCK flock64 #else #define AFS_FLOCK flock @@ -1195,7 +1195,7 @@ struct afs_fakestat_state { extern int afs_fakestat_enable; struct buffer { - ino_t fid[1]; /* Unique cache key + i/o addressing */ + struct fcache *fid; afs_int32 page; afs_int32 accesstime; struct buffer *hashNext; diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index f8f4b4845..6124c273f 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -686,7 +686,7 @@ afs_HashOutDCache(struct dcache *adc) AFS_STATCNT(afs_glink); #endif /* we know this guy's in the LRUQ. We'll move dude into DCQ below */ - DZap(&adc->f.inode); + DZap(&adc->f); /* if this guy is in the hash table, pull him out */ if (adc->f.fid.Fid.Volume != 0) { /* remove entry from first hash chains */ @@ -2038,7 +2038,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, * Right now, we only have one tool, and it's a hammer. So, we * fetch the whole file. */ - DZap(&tdc->f.inode); /* pages in cache may be old */ + DZap(&tdc->f); /* pages in cache may be old */ #ifdef IHINT if (file = tdc->ihint) { if (tdc->f.inode == file->inum) @@ -2415,7 +2415,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, afs_CFileClose(file); ZapDCE(tdc); /* sets DFEntryMod */ if (vType(avc) == VDIR) { - DZap(&tdc->f.inode); + DZap(&tdc->f); } ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 8ab51ac02..a8c3a3b41 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -268,7 +268,11 @@ copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst) #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) +#ifdef AFS_PPC64_LINUX26_ENV + if (current->thread_info->flags & _TIF_32BIT) +#else /*Linux 2.6*/ + if (current->thread.flags & PPC_FLAG_32BIT) +#endif #elif defined(AFS_S390X_LINUX20_ENV) if (current->thread.flags & S390_FLAG_31BIT) #else @@ -488,7 +492,7 @@ struct afs_ioctl_sys { unsigned int com; unsigned long arg; }; -asmlinkage int +int afs_xioctl(struct inode *ip, struct file *fp, unsigned int com, unsigned long arg) { @@ -1713,7 +1717,7 @@ DECL_PIOCTL(PNewStatMount) Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); /* we're done with the data */ @@ -2393,7 +2397,7 @@ DECL_PIOCTL(PRemoveMount) Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); bufp = sysState.name; @@ -2464,10 +2468,10 @@ DECL_PIOCTL(PRemoveMount) ObtainWriteLock(&tdc->lock, 661); if (afs_LocalHero(avc, tdc, &OutDirStatus, 1)) { /* we can do it locally */ - code = afs_dir_Delete(&tdc->f.inode, bufp); + code = afs_dir_Delete(&tdc->f, bufp); if (code) { ZapDCE(tdc); /* surprise error -- invalid value */ - DZap(&tdc->f.inode); + DZap(&tdc->f); } } ReleaseWriteLock(&tdc->lock); @@ -3499,7 +3503,7 @@ DECL_PIOCTL(PFlushMount) Check_AtSys(avc, ain, &sysState, areq); ObtainReadLock(&tdc->lock); do { - code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid); + code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid); } while (code == ENOENT && Next_AtSys(avc, areq, &sysState)); ReleaseReadLock(&tdc->lock); afs_PutDCache(tdc); /* we're done with the data */ diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index f9d5b8068..41c65cee2 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -898,7 +898,7 @@ afs_InvalidateAllSegments(struct vcache *avc) ObtainWriteLock(&tdc->lock, 679); ZapDCE(tdc); if (vType(avc) == VDIR) - DZap(&tdc->f.inode); + DZap(&tdc->f); ReleaseWriteLock(&tdc->lock); afs_PutDCache(tdc); } @@ -1041,6 +1041,12 @@ afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen, afs_CFileTruncate(tfile, newSize); afs_CFileClose(tfile); afs_AdjustSize(tdc, newSize); + if (alen < tdc->validPos) { + if (alen < AFS_CHUNKTOBASE(tdc->f.chunk)) + tdc->validPos = 0; + else + tdc->validPos = alen; + } ConvertWToSLock(&tdc->lock); } ReleaseSharedLock(&tdc->lock); diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 87c467f16..249e27228 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -840,9 +840,18 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) #elif defined(AFS_LINUX22_ENV) if (tvc != afs_globalVp && VREFCOUNT(tvc) && tvc->opens == 0) { #if defined(AFS_LINUX26_ENV) - AFS_GUNLOCK(); - d_prune_aliases(AFSTOI(tvc)); - AFS_GLOCK(); + struct dentry *dentry; + struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry; + AFS_GUNLOCK(); + cur=head; + while ((cur = cur->next) != head) { + dentry = list_entry(cur, struct dentry, d_alias); + if (!d_unhashed(dentry) && + !list_empty(&dentry->d_subdirs)) + shrink_dcache_parent(dentry); + } + d_prune_aliases(AFSTOI(tvc)); + AFS_GLOCK(); #else afs_TryFlushDcacheChildren(tvc); #endif diff --git a/src/bozo/bos.c b/src/bozo/bos.c index d5ced10e3..ad5a00f4f 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -239,7 +239,7 @@ GetConn(as, aencrypt) code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL); if (code == 0) { /* have tickets, will travel */ - if (ttoken.kvno >= 0 && ttoken.kvno <= 255); + if (ttoken.kvno >= 0 && ttoken.kvno <= 256); else { fprintf(stderr, "bos: funny kvno (%d) in ticket, proceeding\n", diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index d804794f6..787fa8da3 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -856,6 +856,7 @@ WorkerBee(as, arock) #else PROCESS dbWatcherPid; #endif + time_t t; debugLevel = 0; @@ -1131,7 +1132,8 @@ WorkerBee(as, arock) TLog(0, "Starting Tape Coordinator: Port offset %u Debug level %u\n", portOffset, debugLevel); - TLog(0, "Token expires: %s\n", cTIME(&ttoken.endTime)); + t = ttoken.endTime; + TLog(0, "Token expires: %s\n", cTIME(&t)); rx_StartServer(1); /* Donate this process to the server process pool */ TLog(0, "Error: StartServer returned"); diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 688b752c3..5712e488c 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -229,12 +229,14 @@ case $AFS_SYSNAME in SHLIB_LINKER="${MT_CC} -shared" ;; - amd64_linux24) + amd64_linux*) + CCOBJ="${CC} -fPIC" KERN_OPTMZ=-O2 LEX="flex -l" MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}' MT_LIBS="-lpthread" PAM_CFLAGS="-g -O2 -Dlinux -DLINUX_PAM -fPIC" + SHLIB_CFLAGS="-fPIC" SHLIB_LDFLAGS="-shared -Xlinker -x" TXLIBS="-lncurses" XCFLAGS="-g -O2 -D_LARGEFILE64_SOURCE" diff --git a/src/config/afs_sysnames.h b/src/config/afs_sysnames.h index db042c3b1..ac6d74cf1 100644 --- a/src/config/afs_sysnames.h +++ b/src/config/afs_sysnames.h @@ -206,6 +206,7 @@ #define SYS_NAME_ID_amd64_linux2 2700 #define SYS_NAME_ID_amd64_linux22 2701 #define SYS_NAME_ID_amd64_linux24 2702 +#define SYS_NAME_ID_amd64_linux26 2703 #define SYS_NAME_ID_i386_umlinux2 2800 #define SYS_NAME_ID_i386_umlinux22 2801 @@ -214,6 +215,7 @@ #define SYS_NAME_ID_ppc64_linux2 2900 #define SYS_NAME_ID_ppc64_linux22 2901 #define SYS_NAME_ID_ppc64_linux24 2902 +#define SYS_NAME_ID_ppc64_linux26 2903 /* * Placeholder to keep system-wide standard flags since this file is included by all diff --git a/src/des/Makefile.in b/src/des/Makefile.in index 8f8d08ba9..a415f1470 100644 --- a/src/des/Makefile.in +++ b/src/des/Makefile.in @@ -88,9 +88,9 @@ make_s: make_s.o misc.o main.o crypt.o: crypt.c case ${SYS_NAME} in \ rs_aix*)\ - ${CC} -c ${COMMON_INCL} -o crypt.o crypt.c ;;\ + ${CCOBJ} -c ${COMMON_INCL} -o crypt.o crypt.c ;;\ *)\ - ${CC} -c ${CFLAGS} -o crypt.o crypt.c ;;\ + ${CCOBJ} -c ${CFLAGS} -o crypt.o crypt.c ;;\ esac # # Table/code generation targets diff --git a/src/des/des.c b/src/des/des.c index 732e266bb..5536066c6 100644 --- a/src/des/des.c +++ b/src/des/des.c @@ -72,12 +72,13 @@ pthread_mutex_t rxkad_stats_mutex; /* encrypt == 0 ==> decrypt, else encrypt */ afs_int32 -des_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, +des_ecb_encrypt(void * clear, void * cipher, register des_key_schedule schedule, int encrypt) { /* better pass 8 bytes, length not checked here */ - register afs_uint32 R1 = 0, L1 = 0; /* R1 = r10, L1 = r9 */ + register afs_uint32 R1 = 0; + register afs_uint32 L1 = 0; /* R1 = r10, L1 = r9 */ register afs_uint32 R2 = 0, L2 = 0; /* R2 = r8, L2 = r7 */ afs_int32 i; /* one more registers left on VAX, see below P_temp_p */ @@ -128,20 +129,22 @@ des_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, abort(); } #endif - if ((afs_int32) clear & 3) { - memcpy((char *)&L_save, (char *)clear++, sizeof(L_save)); - memcpy((char *)&R_save, (char *)clear, sizeof(R_save)); + if ((afs_uint32) clear & 3) { + memcpy((char *)(&L_save), (char *)clear, sizeof(L_save)); + clear=((afs_uint32*)clear)+1; + memcpy((char *)(&R_save), (char *)clear, sizeof(R_save)); L1 = L_save; R1 = R_save; } else #endif { - if (clear) - L1 = *clear++; - else + if (clear) { + L1 = *((afs_uint32 *)clear); + clear=((afs_uint32*)clear)+1; + } else L1 = 0; if (clear) - R1 = *clear; + R1 = *((afs_uint32 *)clear); else R1 = 0; } @@ -441,13 +444,15 @@ des_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, if ((afs_int32) cipher & 3) { L_save = L2; /* cant bcopy a reg */ R_save = R2; - memcpy((char *)cipher++, (char *)&L_save, sizeof(L_save)); + memcpy((char *)cipher, (char *)&L_save, sizeof(L_save)); + cipher=((afs_uint32*)cipher)+1; memcpy((char *)cipher, (char *)&R_save, sizeof(R_save)); } else #endif { - *cipher++ = L2; - *cipher = R2; + *((afs_uint32*)cipher)= L2; + cipher = ((afs_int32 *)cipher)+1; + *((afs_uint32 *)cipher) = R2; } #ifdef DEBUG diff --git a/src/libafs/MakefileProto.LINUX.in b/src/libafs/MakefileProto.LINUX.in index 3527948cd..6d6673834 100644 --- a/src/libafs/MakefileProto.LINUX.in +++ b/src/libafs/MakefileProto.LINUX.in @@ -144,29 +144,29 @@ ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: $(RM) -f asm-generic ln -fs ${LINUX_KERNEL_PATH}/include/asm-generic asm-generic $(RM) -f asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-parisc asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-alpha asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-i386 asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-um asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-x86_64 asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-s390 asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-s390x asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-ppc asm - + ln -s ${LINUX_KERNEL_PATH}/include/asm-ppc64 asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-sparc asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-sparc64 asm - + ln -fs ${LINUX_KERNEL_PATH}/include/asm-ia64 asm for m in ${MPS} ; do \ diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c index 46d93a625..d03f485ef 100644 --- a/src/rx/LINUX/rx_knet.c +++ b/src/rx/LINUX/rx_knet.c @@ -35,6 +35,8 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) struct socket *sockp; struct sockaddr_in myaddr; int code; + KERNEL_SPACE_DECL; + int pmtu = IP_PMTUDISC_DONT; /* We need a better test for this. if you need it back, tell us @@ -64,6 +66,9 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) return NULL; } + TO_USER_SPACE(); + sockp->ops->setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu)); + TO_KERNEL_SPACE(); return (struct osi_socket *)sockp; } diff --git a/src/rx/rx.c b/src/rx/rx.c index 2ae09e0ef..c7299d8b6 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -662,7 +662,7 @@ void rx_StartServer(int donateMe) { register struct rx_service *service; - register int i, nProcs = 0; + register int i; SPLVAR; clock_NewTime(); @@ -701,6 +701,7 @@ rx_StartServer(int donateMe) #ifndef AFS_NT40_ENV #ifndef KERNEL char name[32]; + static int nProcs; #ifdef AFS_PTHREAD_ENV pid_t pid; pid = (pid_t) pthread_self(); @@ -816,15 +817,16 @@ rxi_CleanupConnection(struct rx_connection *conn) * idle (refCount == 0) after rx_idlePeerTime (60 seconds) have passed. */ MUTEX_ENTER(&rx_peerHashTable_lock); - if (--conn->peer->refCount <= 0) { + if (conn->peer->refCount < 2) { conn->peer->idleWhen = clock_Sec(); - if (conn->peer->refCount < 0) { - conn->peer->refCount = 0; + if (conn->peer->refCount < 1) { + conn->peer->refCount = 1; MUTEX_ENTER(&rx_stats_mutex); rxi_lowPeerRefCount++; MUTEX_EXIT(&rx_stats_mutex); } } + conn->peer->refCount--; MUTEX_EXIT(&rx_peerHashTable_lock); MUTEX_ENTER(&rx_stats_mutex); @@ -1014,6 +1016,20 @@ rx_DestroyConnection(register struct rx_connection *conn) USERPRI; } +void +rx_GetConnection(register struct rx_connection *conn) +{ + SPLVAR; + + NETPRI; + AFS_RXGLOCK(); + MUTEX_ENTER(&conn->conn_data_lock); + conn->refCount++; + MUTEX_EXIT(&conn->conn_data_lock); + AFS_RXGUNLOCK(); + USERPRI; +} + /* Start a new rx remote procedure call, on the specified connection. * If wait is set to 1, wait for a free call channel; otherwise return * 0. Maxtime gives the maximum number of seconds this call may take, @@ -3984,6 +4000,7 @@ rxi_AttachServerProc(register struct rx_call *call, call->flags |= RX_CALL_WAIT_PROC; MUTEX_ENTER(&rx_stats_mutex); rx_nWaiting++; + rx_nWaited++; MUTEX_EXIT(&rx_stats_mutex); rxi_calltrace(RX_CALL_ARRIVAL, call); SET_CALL_QUEUE_LOCK(call, &rx_serverPool_lock); @@ -5747,7 +5764,7 @@ rxi_ReapConnections(void) MUTEX_ENTER(&rx_stats_mutex); rx_stats.nPeerStructs--; MUTEX_EXIT(&rx_stats_mutex); - if (prev == *peer_ptr) { + if (peer == *peer_ptr) { *peer_ptr = next; prev = next; } else @@ -6218,6 +6235,9 @@ rx_GetServerDebug(osi_socket socket, afs_uint32 remoteAddr, if (stat->version >= RX_DEBUGI_VERSION_W_GETPEER) { *supportedValues |= RX_SERVER_DEBUG_ALL_PEER; } + if (stat->version >= RX_DEBUGI_VERSION_W_WAITED) { + *supportedValues |= RX_SERVER_DEBUG_WAITED_CNT; + } stat->nFreePackets = ntohl(stat->nFreePackets); stat->packetReclaims = ntohl(stat->packetReclaims); diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index 749777429..2185d43e9 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -865,7 +865,11 @@ rxi_ReadPacket(int socket, register struct rx_packet *p, afs_uint32 * host, * never be cleaned up. */ peer = rxi_FindPeer(*host, *port, 0, 0); - if (peer) { + /* Since this may not be associated with a connection, + * it may have no refCount, meaning we could race with + * ReapConnections + */ + if (peer && (peer->refCount > 0)) { MUTEX_ENTER(&peer->peer_lock); hadd32(peer->bytesReceived, p->length); MUTEX_EXIT(&peer->peer_lock); @@ -1160,6 +1164,7 @@ rxi_ReceiveDebugPacket(register struct rx_packet *ap, osi_socket asocket, tstat.packetReclaims = htonl(rx_packetReclaims); tstat.usedFDs = CountFDs(64); tstat.nWaiting = htonl(rx_nWaiting); + tstat.nWaited = htonl(rx_nWaited); queue_Count(&rx_idleServerQueue, np, nqe, rx_serverQueueEntry, tstat.idleThreads); MUTEX_EXIT(&rx_serverPool_lock); diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index a3c632479..e4c7f9ca0 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -100,7 +100,9 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port) osi_socket socketFd = OSI_NULLSOCKET; struct sockaddr_in taddr; char *name = "rxi_GetUDPSocket: "; - int greedy = 0; +#ifdef AFS_LINUX22_ENV + int pmtu=IP_PMTUDISC_DONT; +#endif #if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV) if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) { @@ -147,15 +149,16 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port) fcntl(socketFd, F_SETFD, 1); #endif +#ifndef AFS_DJGPP_ENV /* Use one of three different ways of getting a socket buffer expanded to * a reasonable size. */ { + int greedy = 0; int len1, len2; len1 = 32766; len2 = rx_UdpBufSize; -#ifndef AFS_DJGPP_ENV greedy = (setsockopt (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2, @@ -172,14 +175,19 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port) (setsockopt (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2, sizeof(len2)) >= 0); -#endif /* AFS_DJGPP_ENV */ + if (!greedy) + (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n", + name); + MUTEX_ENTER(&rx_stats_mutex); + rx_stats.socketGreedy = greedy; + MUTEX_EXIT(&rx_stats_mutex); } - -#ifndef AFS_DJGPP_ENV - if (!greedy) - (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n", - name); #endif /* AFS_DJGPP_ENV */ + +#ifdef AFS_LINUX22_ENV + setsockopt(socketFd, SOL_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu)); +#endif + if (rxi_Listen(socketFd) < 0) { goto error; } @@ -195,9 +203,6 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port) close(socketFd); #endif - MUTEX_ENTER(&rx_stats_mutex); - rx_stats.socketGreedy = greedy; - MUTEX_EXIT(&rx_stats_mutex); return OSI_NULLSOCKET; } diff --git a/src/rx/rxdebug.c b/src/rx/rxdebug.c index db94347e1..587e80c84 100644 --- a/src/rx/rxdebug.c +++ b/src/rx/rxdebug.c @@ -109,6 +109,7 @@ MainCommand(as, arock) int withRxStats; int withWaiters; int withIdleThreads; + int withWaited; int withPeers; struct rx_debugStats tstats; char *portName, *hostName; @@ -253,6 +254,7 @@ MainCommand(as, arock) withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS); withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT); withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS); + withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT); withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER); printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n", @@ -265,6 +267,8 @@ MainCommand(as, arock) printf("%d calls waiting for a thread\n", tstats.nWaiting); if (withIdleThreads) printf("%d threads are idle\n", tstats.idleThreads); + if (withWaited) + printf("%d calls have waited for a thread\n", tstats.nWaited); if (rxstats) { if (!withRxStats) { diff --git a/src/rxkad/domestic/fcrypt.c b/src/rxkad/domestic/fcrypt.c index b395f7902..b7c959ea6 100644 --- a/src/rxkad/domestic/fcrypt.c +++ b/src/rxkad/domestic/fcrypt.c @@ -110,7 +110,7 @@ fc_keysched(struct ktc_encryptionKey *key, fc_KeySchedule schedule) /* IN int encrypt; * 0 ==> decrypt, else encrypt */ afs_int32 -fc_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, +fc_ecb_encrypt(void * clear, void * cipher, fc_KeySchedule schedule, int encrypt) { afs_uint32 L, R; @@ -135,8 +135,8 @@ fc_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, memcpy(&L, clear, sizeof(afs_int32)); memcpy(&R, clear + 1, sizeof(afs_int32)); #else - L = ntohl(*clear); - R = ntohl(*(clear + 1)); + L = ntohl(*((afs_uint32 *)clear)); + R = ntohl(*((afs_uint32 *)clear + 1)); #endif if (encrypt) { @@ -185,8 +185,8 @@ fc_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, memcpy(cipher, &L, sizeof(afs_int32)); memcpy(cipher + 1, &R, sizeof(afs_int32)); #else - *cipher = htonl(L); - *(cipher + 1) = htonl(R); + *((afs_int32 *)cipher) = htonl(L); + *((afs_int32 *)cipher + 1) = htonl(R); #endif return 0; } @@ -203,7 +203,7 @@ fc_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, afs_uint32 *xor; * 8 bytes of initialization vector * */ afs_int32 -fc_cbc_encrypt(char *input, char *output, afs_int32 length, +fc_cbc_encrypt(void *input, void *output, afs_int32 length, fc_KeySchedule key, afs_uint32 * xor, int encrypt) { afs_uint32 i, j; @@ -215,7 +215,7 @@ fc_cbc_encrypt(char *input, char *output, afs_int32 length, for (i = 0; length > 0; i++, length -= 8) { /* get input */ memcpy(t_input, input, sizeof(t_input)); - input += sizeof(t_input); + input=((char *)input) + sizeof(t_input); /* zero pad */ for (j = length; j <= 7; j++) @@ -229,7 +229,7 @@ fc_cbc_encrypt(char *input, char *output, afs_int32 length, /* copy temp output and save it for cbc */ memcpy(output, t_output, sizeof(t_output)); - output += sizeof(t_output); + output=(char *)output + sizeof(t_output); /* calculate xor value for next round from plain & cipher text */ xor[0] = t_input[0] ^ t_output[0]; @@ -244,7 +244,7 @@ fc_cbc_encrypt(char *input, char *output, afs_int32 length, for (i = 0; length > 0; i++, length -= 8) { /* get input */ memcpy(t_input, input, sizeof(t_input)); - input += sizeof(t_input); + input=((char *)input) + sizeof(t_input); /* no padding for decrypt */ fc_ecb_encrypt(t_input, t_output, key, encrypt); @@ -255,7 +255,7 @@ fc_cbc_encrypt(char *input, char *output, afs_int32 length, /* copy temp output */ memcpy(output, t_output, sizeof(t_output)); - output += sizeof(t_output); + output=((char *)output) + sizeof(t_output); /* calculate xor value for next round from plain & cipher text */ xor[0] = t_input[0] ^ t_output[0]; diff --git a/src/rxkad/rxkad.p.h b/src/rxkad/rxkad.p.h index 83a4f53fb..5887d23cf 100644 --- a/src/rxkad/rxkad.p.h +++ b/src/rxkad/rxkad.p.h @@ -16,12 +16,7 @@ /* no ticket good for longer than 30 days */ #define MAXKTCTICKETLIFETIME (30*24*3600) #define MINKTCTICKETLEN 32 -#ifdef AFS_AIX_ENV -#define MAXKTCTICKETLEN 344 /* XXX why must this be small? */ -#else #define MAXKTCTICKETLEN 12000 /* was 344 */ -#endif - #define MAXKTCNAMELEN 64 /* name & inst should be 256 */ #define MAXKTCREALMLEN 64 /* should be 256 */ #define KTC_TIME_UNCERTAINTY (15*60) /* max skew bet. machines' clocks */ diff --git a/src/rxkad/rxkad_prototypes.h b/src/rxkad/rxkad_prototypes.h index adffe54fa..471b8ac13 100644 --- a/src/rxkad/rxkad_prototypes.h +++ b/src/rxkad/rxkad_prototypes.h @@ -28,9 +28,9 @@ extern afs_int32 rxkad_EncryptPacket(const struct rx_connection *conn, /* domestic/fcrypt.c */ extern int fc_keysched(struct ktc_encryptionKey *key, fc_KeySchedule schedule); -extern afs_int32 fc_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, +extern afs_int32 fc_ecb_encrypt(void * clear, void * cipher, fc_KeySchedule schedule, int encrypt); -extern afs_int32 fc_cbc_encrypt(char *input, char *output, afs_int32 length, +extern afs_int32 fc_cbc_encrypt(void *input, void *output, afs_int32 length, fc_KeySchedule key, afs_uint32 * xor, int encrypt); diff --git a/src/sys/pioctl_nt.c b/src/sys/pioctl_nt.c index 8eb938e7a..2441a450f 100644 --- a/src/sys/pioctl_nt.c +++ b/src/sys/pioctl_nt.c @@ -98,6 +98,30 @@ InitFSRequest(fs_ioctlRequest_t * rp) rp->nbytes = 0; } +static BOOL +IoctlDebug(void) +{ + static int init = 0; + static BOOL debug = 0; + + if ( !init ) { + HKEY hk; + + if (RegOpenKey (HKEY_LOCAL_MACHINE, + TEXT("Software\\OpenAFS\\Client"), &hk) == 0) + { + DWORD dwSize = sizeof(BOOL); + DWORD dwType = REG_DWORD; + RegQueryValueEx (hk, TEXT("IoctlDebug"), NULL, &dwType, (PBYTE)&debug, &dwSize); + RegCloseKey (hk); + } + + init = 1; + } + + return debug; +} + static long GetIoctlHandle(char *fileNamep, HANDLE * handlep) { @@ -170,18 +194,9 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep) char szPath[MAX_PATH] = ""; NETRESOURCE nr; DWORD res; - DWORD ioctlDebug = 0; + DWORD ioctlDebug = IoctlDebug(); DWORD gle; - if (RegOpenKey (HKEY_LOCAL_MACHINE, - TEXT("Software\\OpenAFS\\Client"), &hk) == 0) - { - DWORD dwSize = sizeof(DWORD); - DWORD dwType = REG_DWORD; - RegQueryValueEx (hk, TEXT("IoctlDebug"), NULL, &dwType, (PBYTE)&ioctlDebug, &dwSize); - RegCloseKey (hk); - } - gle = GetLastError(); if (gle && ioctlDebug ) { char buf[4096]; @@ -264,19 +279,31 @@ Transceive(HANDLE handle, fs_ioctlRequest_t * reqp) { long rcount; long ioCount; + DWORD gle; rcount = reqp->mp - reqp->data; - if (rcount <= 0) + if (rcount <= 0) { + if ( IoctlDebug() ) + fprintf(stderr, "pioctl Transceive rcount <= 0: %d\r\n",rcount); return EINVAL; /* not supposed to happen */ + } if (!WriteFile(handle, reqp->data, rcount, &ioCount, NULL)) { /* failed to write */ - return GetLastError(); + gle = GetLastError(); + + if ( IoctlDebug() ) + fprintf(stderr, "pioctl Transceive WriteFile failed: 0x%X\r\n",gle); + return gle; } if (!ReadFile(handle, reqp->data, sizeof(reqp->data), &ioCount, NULL)) { /* failed to read */ - return GetLastError(); + gle = GetLastError(); + + if ( IoctlDebug() ) + fprintf(stderr, "pioctl Transceive ReadFile failed: 0x%X\r\n",gle); + return gle; } reqp->nbytes = ioCount; /* set # of bytes available */ @@ -299,6 +326,9 @@ UnmarshallLong(fs_ioctlRequest_t * reqp, long *valp) { /* not enough data left */ if (reqp->nbytes < 4) { + if ( IoctlDebug() ) + fprintf(stderr, "pioctl UnmarshallLong reqp->nbytes < 4: %d\r\n", + reqp->nbytes); return -1; } @@ -320,8 +350,11 @@ MarshallString(fs_ioctlRequest_t * reqp, char *stringp) count = 1; /* watch for buffer overflow */ - if ((reqp->mp - reqp->data) + count > sizeof(reqp->data)) + if ((reqp->mp - reqp->data) + count > sizeof(reqp->data)) { + if ( IoctlDebug() ) + fprintf(stderr, "pioctl MarshallString buffer overflow\r\n"); return -1; + } if (stringp) memcpy(reqp->mp, stringp, count); @@ -389,15 +422,19 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize) newPath[2] = 0; if (!SetCurrentDirectory(newPath)) { code = GetLastError(); + + if ( IoctlDebug() ) + fprintf(stderr, "pioctl fs_GetFullPath SetCurrentDirectory(%s) failed: 0x%X\r\n", + newPath, code); return code; } } /* now get the absolute path to the current wdir in this drive */ GetCurrentDirectory(sizeof(tpath), tpath); - if (tpath[1] == ':') - strcpy(outPathp, tpath + 2); /* skip drive letter */ - else if ( tpath[0] == '\\' && tpath[1] == '\\') { + if (tpath[1] == ':') + strcpy(outPathp, tpath + 2); /* skip drive letter */ + else if ( tpath[0] == '\\' && tpath[1] == '\\') { /* UNC path - strip off the server and sharename */ int i, count; for ( i=2,count=2; count < 4 && tpath[i]; i++ ) { @@ -417,10 +454,10 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize) /* if there is a non-null name after the drive, append it */ if (*firstp != 0) { - int len = strlen(outPathp); - if (outPathp[len-1] != '\\' && outPathp[len-1] != '/') - strcat(outPathp, "\\"); - strcat(outPathp, firstp); + int len = strlen(outPathp); + if (outPathp[len-1] != '\\' && outPathp[len-1] != '/') + strcat(outPathp, "\\"); + strcat(outPathp, firstp); } /* finally, if necessary, switch back to our home drive letter */ @@ -484,10 +521,16 @@ pioctl(char *pathp, long opcode, struct ViceIoctl *blobp, int follow) } /* now unmarshall the return value */ - UnmarshallLong(&preq, &temp); + if (UnmarshallLong(&preq, &temp) != 0) { + CloseHandle(reqHandle); + return -1; + } + if (temp != 0) { CloseHandle(reqHandle); errno = CMtoUNIXerror(temp); + if ( IoctlDebug() ) + fprintf(stderr, "pioctl temp != 0: %d\r\n",temp); return -1; } diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c index e4f6bddb6..d5b152640 100644 --- a/src/ubik/beacon.c +++ b/src/ubik/beacon.c @@ -569,8 +569,7 @@ verifyInterfaceAddress(ame, info, aservers) for (j = 0, found = 0; j < count; j++) { for (i = 0; i < totalServers; i++) { if (info) - tmpAddr = - (afs_uint32) info->hostAddr[i].sin_addr.s_addr; + tmpAddr = (afs_uint32) info->hostAddr[i].sin_addr.s_addr; else tmpAddr = aservers[i]; if (myAddr[j] == tmpAddr) { diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index b72a82232..b69a66fe4 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -359,4 +359,15 @@ extern int ubik_BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr); extern int ubik_EndTrans(register struct ubik_trans *transPtr); +/* uinit.c */ + +extern afs_int32 ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, + afs_int32 sauth, + struct ubik_client **uclientp, + int (*secproc) (), char *funcName, + afs_int32 gen_rxkad_level, + afs_int32 maxservers, afs_int32 serviceid, + afs_int32 deadtime, afs_uint32 server, + afs_uint32 port, afs_int32 usrvid); + #endif /* UBIK_H */ diff --git a/src/util/snprintf.c b/src/util/snprintf.c index 0d804083e..603d174d6 100644 --- a/src/util/snprintf.c +++ b/src/util/snprintf.c @@ -436,9 +436,11 @@ afs_vsnprintf(char *p, size_t avail, const char *fmt, va_list ap) } else { x = "%u.%u.%u.%u"; } - sprintf(xbuf, x, (UVAL & 0xff000000) >> 24, - (UVAL & 0x00ff0000) >> 16, (UVAL & 0x0000ff00) >> 8, - (UVAL & 0x000000ff)); + /* typecast to whatever '%u' is! */ + sprintf(xbuf, x, (unsigned int)((UVAL & 0xff000000) >> 24), + (unsigned int)((UVAL & 0x00ff0000) >> 16), + (unsigned int)((UVAL & 0x0000ff00) >> 8), + (unsigned int)(UVAL & 0x000000ff)); x = xbuf; len = strlen(xbuf); } diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 1cad3f1c6..3bd5167a5 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -1041,8 +1041,8 @@ static int namei_ListAFSSubDirs(IHandle_t * dirIH, struct ViceInodeInfo *, char *, char *), FILE * fp, int (*judgeFun) (struct ViceInodeInfo *, - int vid), - int singleVolumeNumber); + int vid, void *), + int singleVolumeNumber, void *rock); /* WriteInodeInfo @@ -1093,8 +1093,9 @@ VerifyDirPerms(char *path) */ int ListViceInodes(char *devname, char *mountedOn, char *resultFile, - int (*judgeInode) (struct ViceInodeInfo * info, int vid), - int singleVolumeNumber, int *forcep, int forceR, char *wpath) + int (*judgeInode) (struct ViceInodeInfo * info, int vid, void *rock), + int singleVolumeNumber, int *forcep, int forceR, char *wpath, + void *rock) { FILE *fp = (FILE *) - 1; int ninodes; @@ -1114,7 +1115,7 @@ ListViceInodes(char *devname, char *mountedOn, char *resultFile, ninodes = namei_ListAFSFiles(mountedOn, WriteInodeInfo, fp, judgeInode, - singleVolumeNumber); + singleVolumeNumber, rock); if (!resultFile) return ninodes; @@ -1167,8 +1168,8 @@ int namei_ListAFSFiles(char *dev, int (*writeFun) (FILE *, struct ViceInodeInfo *, char *, char *), FILE * fp, - int (*judgeFun) (struct ViceInodeInfo *, int), - int singleVolumeNumber) + int (*judgeFun) (struct ViceInodeInfo *, int, void *), + int singleVolumeNumber, void *rock) { IHandle_t ih; namei_t name; @@ -1188,7 +1189,7 @@ namei_ListAFSFiles(char *dev, namei_HandleToVolDir(&name, &ih); ninodes = namei_ListAFSSubDirs(&ih, writeFun, fp, judgeFun, - singleVolumeNumber); + singleVolumeNumber, rock); if (ninodes < 0) return ninodes; } else { @@ -1212,7 +1213,7 @@ namei_ListAFSFiles(char *dev, if (!DecodeVolumeName(dp2->d_name, &ih.ih_vid)) { ninodes += namei_ListAFSSubDirs(&ih, writeFun, fp, judgeFun, - 0); + 0, rock); } } closedir(dirp2); @@ -1239,8 +1240,8 @@ static int namei_ListAFSSubDirs(IHandle_t * dirIH, int (*writeFun) (FILE *, struct ViceInodeInfo *, char *, char *), FILE * fp, - int (*judgeFun) (struct ViceInodeInfo *, int), - int singleVolumeNumber) + int (*judgeFun) (struct ViceInodeInfo *, int, void *), + int singleVolumeNumber, void *rock) { IHandle_t myIH = *dirIH; namei_t name; @@ -1283,7 +1284,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH, info.linkCount = namei_GetLinkCount(&linkHandle, (Inode) 0, 0); } - if (judgeFun && !(*judgeFun) (&info, singleVolumeNumber)) + if (judgeFun && !(*judgeFun) (&info, singleVolumeNumber, rock)) continue; if ((*writeFun) (fp, &info, path1, dp1->d_name) < 0) { @@ -1345,7 +1346,7 @@ namei_ListAFSSubDirs(IHandle_t * dirIH, continue; } if (judgeFun - && !(*judgeFun) (&info, singleVolumeNumber)) + && !(*judgeFun) (&info, singleVolumeNumber, rock)) continue; if ((*writeFun) (fp, &info, path3, dp3->d_name) < diff --git a/src/vol/nuke.c b/src/vol/nuke.c index 7194503e6..f787b5ae3 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -65,14 +65,14 @@ struct ilist { afs_int32 freePtr; /* first free index in this table */ Inode inode[MAXATONCE]; /* inode # */ afs_int32 count[MAXATONCE]; /* link count */ -} *allInodes = 0; +}; /* called with a structure specifying info about the inode, and our rock (which * is the volume ID. Returns true if we should keep this inode, otherwise false. * Note that ainfo->u.param[0] is always the volume ID, for any vice inode. */ static int -NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid) +NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid, struct ilist *allInodes) { struct ilist *ti; register afs_int32 i; @@ -113,7 +113,7 @@ nuke(char *aname, afs_int32 avolid) { /* first process the partition containing this junk */ struct afs_stat tstat; - struct ilist *ti, *ni; + struct ilist *ti, *ni, *li=NULL; register afs_int32 code; int i, forceSal; char devName[64], wpath[100]; @@ -127,6 +127,7 @@ nuke(char *aname, afs_int32 avolid) #endif #endif /* AFS_NAMEI_ENV */ IHandle_t *fileH; + struct ilist *allInodes = 0; if (avolid == 0) return EINVAL; @@ -169,11 +170,11 @@ nuke(char *aname, afs_int32 avolid) #ifdef AFS_NAMEI_ENV code = ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid, &forceSal, - 0, wpath); + 0, wpath, allInodes); #else code = ListViceInodes(lastDevComp, aname, "/tmp/vNukeXX", NukeProc, avolid, - &forceSal, 0, wpath); + &forceSal, 0, wpath, allInodes); unlink("/tmp/vNukeXX"); /* clean it up now */ #endif if (code == 0) { @@ -211,8 +212,10 @@ nuke(char *aname, afs_int32 avolid) #endif /* AFS_NAMEI_ENV */ } ni = ti->next; - free(ti); + if (li) free(li); + li = ti; } + if (li) free(li); code = 0; /* we really don't care about it except for debugging */ allInodes = NULL; @@ -236,8 +239,10 @@ nuke(char *aname, afs_int32 avolid) /* just free things */ for (ti = allInodes; ti; ti = ni) { ni = ti->next; - free(ti); + if (li) free(li); + li = ti; } + if (li) free(li); allInodes = NULL; } ReleaseWriteLock(&localLock); diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index f7d931d4b..0e673b0cb 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -1520,7 +1520,7 @@ CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes, } int -OnlyOneVolume(struct ViceInodeInfo *inodeinfo, VolumeId singleVolumeNumber) +OnlyOneVolume(struct ViceInodeInfo *inodeinfo, VolumeId singleVolumeNumber, void *rock) { if (inodeinfo->u.vnode.vnodeNumber == INODESPECIAL) return (inodeinfo->u.special.parentId == singleVolumeNumber); @@ -1556,7 +1556,7 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber) if ((err = ListViceInodes(dev, fileSysPath, path, singleVolumeNumber ? OnlyOneVolume : 0, - singleVolumeNumber, &forceSal, forceR, wpath)) < 0) { + singleVolumeNumber, &forceSal, forceR, wpath, NULL)) < 0) { if (err == -2) { Log("*** I/O error %d when writing a tmp inode file %s; Not salvaged %s ***\nIncrease space on partition or use '-tmpdir'\n", errno, path, dev); return -1; -- 2.39.5