From: Sam Hartman Date: Sun, 13 Apr 2003 19:08:27 +0000 (+0000) Subject: This commit was generated by cvs2svn to compensate for changes in r570, X-Git-Tag: debian/1.2.9-1~18 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=495b9221491fe75f7fea8708965921ce4ba2ae07;p=packages%2Fo%2Fopenafs.git This commit was generated by cvs2svn to compensate for changes in r570, which included commits to RCS files with non-trunk default branches. --- diff --git a/acconfig.h b/acconfig.h index 6244b45a9..679dd81ad 100644 --- a/acconfig.h +++ b/acconfig.h @@ -29,17 +29,26 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #undef FAST_RESTART #undef FULL_LISTVOL_SWITCH +#undef COMPLETION_H_EXISTS +#undef DEFINED_FOR_EACH_PROCESS +#undef DEFINED_PREV_TASK +#undef EXPORTED_KALLSYMS_ADDRESS +#undef EXPORTED_KALLSYMS_SYMBOL +#undef EXPORTED_SYS_CALL_TABLE +#undef EXPORTED_TASKLIST_LOCK #undef INODE_SETATTR_NOT_VOID +#undef RECALC_SIGPENDING_TAKES_VOID #undef STRUCT_ADDRESS_SPACE_HAS_GFP_MASK #undef STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK -#undef STRUCT_INODE_HAS_I_TRUNCATE_SEM -#undef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS +#undef STRUCT_FS_HAS_FS_ROLLED #undef STRUCT_INODE_HAS_I_DEVICES -#undef EXPORTED_TASKLIST_LOCK -#undef EXPORTED_SYS_CALL_TABLE -#undef EXPORTED_KALLSYMS_SYMBOL -#undef EXPORTED_KALLSYMS_ADDRESS -#undef COMPLETION_H_EXISTS +#undef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS +#undef STRUCT_INODE_HAS_I_TRUNCATE_SEM +#undef STRUCT_TASK_STRUCT_HAS_PARENT +#undef STRUCT_TASK_STRUCT_HAS_REAL_PARENT +#undef STRUCT_TASK_STRUCT_HAS_SIG +#undef STRUCT_TASK_STRUCT_HAS_SIGHAND +#undef STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK #undef ssize_t /* glue for RedHat kernel bug */ diff --git a/acinclude.m4 b/acinclude.m4 index 5f0f74363..abbbaf8af 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -87,7 +87,10 @@ case $system in if test "x$with_linux_kernel_headers" != "x"; then LINUX_KERNEL_PATH="$with_linux_kernel_headers" else - LINUX_KERNEL_PATH="/usr/src/linux" + LINUX_KERNEL_PATH="/usr/src/linux-2.4" + if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then + LINUX_KERNEL_PATH="/usr/src/linux" + fi fi if test -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_PATH/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -1` @@ -140,24 +143,34 @@ case $system in [LINUX_BUILD_VNODE_FROM_INODE(config,afs)], [LINUX_BUILD_VNODE_FROM_INODE(src/config,src/afs/LINUX)] ) + LINUX_COMPLETION_H_EXISTS + LINUX_DEFINES_FOR_EACH_PROCESS + LINUX_DEFINES_PREV_TASK + LINUX_EXPORTS_TASKLIST_LOCK LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_GFP_MASK LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS LINUX_FS_STRUCT_INODE_HAS_I_DEVICES LINUX_INODE_SETATTR_RETURN_TYPE - LINUX_COMPLETION_H_EXISTS - LINUX_EXPORTS_TASKLIST_LOCK LINUX_NEED_RHCONFIG + LINUX_RECALC_SIGPENDING_ARG_TYPE + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_PARENT + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_REAL_PARENT + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIG + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGHAND + LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK LINUX_WHICH_MODULES if test "x$ac_cv_linux_config_modversions" = "xno"; then AC_MSG_WARN([Cannot determine sys_call_table status. assuming it's exported]) ac_cv_linux_exports_sys_call_table=yes else - LINUX_EXPORTS_SYS_CALL_TABLE - LINUX_EXPORTS_KALLSYMS_SYMBOL - LINUX_EXPORTS_KALLSYMS_ADDRESS LINUX_EXPORTS_INIT_MM + LINUX_EXPORTS_KALLSYMS_ADDRESS + LINUX_EXPORTS_KALLSYMS_SYMBOL + LINUX_EXPORTS_SYS_CALL_TABLE + LINUX_EXPORTS_SYS_CHDIR + LINUX_EXPORTS_SYS_CLOSE if test "x$ac_cv_linux_exports_sys_call_table" = "xno"; then linux_syscall_method=none if test "x$ac_cv_linux_exports_init_mm" = "xyes"; then @@ -172,6 +185,12 @@ case $system in if test "x$linux_syscall_method" = "xnone"; then AC_MSG_ERROR([no available sys_call_table access method]) fi + if test "x$ac_cv_linux_exports_sys_chdir" = "xyes" ; then + AC_DEFINE(EXPORTED_SYS_CHDIR, 1, [define if your linux kernel exports sys_chdir]) + fi + if test "x$ac_cv_linux_exports_sys_close" = "xyes" ; then + AC_DEFINE(EXPORTED_SYS_CLOSE, 1, [define if your linux kernel exports sys_close]) + fi fi fi if test "x$ac_cv_linux_exports_tasklist_lock" = "xyes" ; then @@ -187,7 +206,13 @@ case $system in AC_DEFINE(EXPORTED_KALLSYMS_ADDRESS) fi if test "x$ac_cv_linux_completion_h_exists" = "xyes" ; then - AC_DEFINE(COMPLETION_H_EXISTS, 1, [define if your h_exists exists]) + AC_DEFINE(COMPLETION_H_EXISTS, 1, [define if completion_h exists]) + fi + if test "x$ac_cv_linux_defines_for_each_process" = "xyes" ; then + AC_DEFINE(DEFINED_FOR_EACH_PROCESS, 1, [define if for_each_process defined]) + fi + if test "x$ac_cv_linux_defines_prev_task" = "xyes" ; then + AC_DEFINE(DEFINED_PREV_TASK, 1, [define if prev_task defined]) fi if test "x$ac_cv_linux_func_inode_setattr_returns_int" = "xyes" ; then AC_DEFINE(INODE_SETATTR_NOT_VOID, 1, [define if your setattr return return non-void]) @@ -205,7 +230,25 @@ case $system in AC_DEFINE(STRUCT_INODE_HAS_I_DEVICES, 1, [define if you struct inode has i_devices]) fi if test "x$ac_cv_linux_fs_struct_inode_has_i_dirty_data_buffers" = "xyes"; then - AC_DEFINE(STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS, 1, [define if you struct inode has data_buffers]) + AC_DEFINE(STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS, 1, [define if your struct inode has data_buffers]) + fi + if test "x$ac_cv_linux_func_recalc_sigpending_takes_void" = "xyes"; then + AC_DEFINE(RECALC_SIGPENDING_TAKES_VOID, 1, [define if your recalc_sigpending takes void]) + fi + if test "x$ac_cv_linux_sched_struct_task_struct_has_parent" = "xyes"; then + AC_DEFINE(STRUCT_TASK_STRUCT_HAS_PARENT, 1, [define if your struct task_struct has parent]) + fi + if test "x$ac_cv_linux_sched_struct_task_struct_has_real_parent" = "xyes"; then + AC_DEFINE(STRUCT_TASK_STRUCT_HAS_REAL_PARENT, 1, [define if your struct task_struct has real_parent]) + fi + if test "x$ac_cv_linux_sched_struct_task_struct_has_sigmask_lock" = "xyes"; then + AC_DEFINE(STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK, 1, [define if your struct task_struct has sigmask_lock]) + fi + if test "x$ac_cv_linux_sched_struct_task_struct_has_sighand" = "xyes"; then + AC_DEFINE(STRUCT_TASK_STRUCT_HAS_SIGHAND, 1, [define if your struct task_struct has sighand]) + fi + if test "x$ac_cv_linux_sched_struct_task_struct_has_sig" = "xyes"; then + AC_DEFINE(STRUCT_TASK_STRUCT_HAS_SIG, 1, [define if your struct task_struct has sig]) fi : fi @@ -215,6 +258,7 @@ case $system in AC_MSG_RESULT(sun4) SOLARIS_UFSVFS_HAS_DQRWLOCK SOLARIS_PROC_HAS_P_COREFILE + SOLARIS_FS_HAS_FS_ROLLED ;; *-sunos*) MKAFS_OSTYPE=SUNOS @@ -328,6 +372,15 @@ else powerpc-apple-darwin6.2*) AFS_SYSNAME="ppc_darwin_60" ;; + powerpc-apple-darwin6.3*) + AFS_SYSNAME="ppc_darwin_60" + ;; + powerpc-apple-darwin6.4*) + AFS_SYSNAME="ppc_darwin_60" + ;; + powerpc-apple-darwin6.5*) + AFS_SYSNAME="ppc_darwin_60" + ;; sparc-sun-solaris2.5*) AFS_SYSNAME="sun4x_55" ;; @@ -361,6 +414,9 @@ else alpha*-dec-osf5.0*) AFS_SYSNAME="alpha_dux50" ;; + alpha*-dec-osf5.1*) + AFS_SYSNAME="alpha_dux51" + ;; mips-sgi-irix6.5) AFS_SYSNAME="sgi_65" ;; diff --git a/configure-libafs.in b/configure-libafs.in index ddcde4c1c..7777c8e5f 100644 --- a/configure-libafs.in +++ b/configure-libafs.in @@ -1,5 +1,5 @@ AC_INIT(Makefile.common) -AM_INIT_AUTOMAKE(openafs-libafs,1.2.8) +AM_INIT_AUTOMAKE(openafs-libafs,1.2.9) AC_CONFIG_HEADER(config/afsconfig.h) define(OPENAFS_CONFIGURE_LIBAFS) diff --git a/src/WINNT/afsd/afsd.c b/src/WINNT/afsd/afsd.c index a481f2e7d..cbcea8453 100644 --- a/src/WINNT/afsd/afsd.c +++ b/src/WINNT/afsd/afsd.c @@ -148,7 +148,7 @@ BOOL InitInstance( main_rect.right = GetDeviceCaps(hDC, HORZRES); main_rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4; /* 1/4 inch */ ReleaseDC(hWnd, hDC); - main_rect.bottom = rect.top + nLineHeight; + main_rect.bottom = main_rect.top + nLineHeight; osi_InitPanic(afsd_notifier); diff --git a/src/WINNT/afsd/cm_callback.c b/src/WINNT/afsd/cm_callback.c index c01099cc2..5862c1292 100644 --- a/src/WINNT/afsd/cm_callback.c +++ b/src/WINNT/afsd/cm_callback.c @@ -112,6 +112,7 @@ void cm_CallbackNotifyChange(cm_scache_t *scp) smb_NotifyChange(0, FILE_NOTIFY_GENERIC_FILE_FILTER, dscp, NULL, NULL, TRUE); + if (dscp) cm_ReleaseSCache(dscp); } } @@ -856,3 +857,11 @@ void cm_CheckCBExpiration(void) } lock_ReleaseWrite(&cm_scacheLock); } + +/* debug interface: not implemented */ +int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, + char **a_name, serverList *a_hosts) +{ + /* XXXX */ + return RXGEN_OPCODE; +} diff --git a/src/WINNT/afsd/cm_conn.c b/src/WINNT/afsd/cm_conn.c index 3b326022e..f38d6f6f8 100644 --- a/src/WINNT/afsd/cm_conn.c +++ b/src/WINNT/afsd/cm_conn.c @@ -18,7 +18,7 @@ #include #include #ifndef DJGPP -#include +#include #else #include #endif diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index 8ae076640..f2016fbe8 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -30,7 +30,7 @@ #include "smb.h" #ifndef DJGPP -#include +#include #include "afsrpc.h" #else #include @@ -1735,7 +1735,9 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) * leading "/afs" when writing out the submount. */ WritePrivateProfileString("AFS Submounts", - submountreqp, &afspath[strlen("/afs")], + submountreqp, + (strlen(&afspath[strlen("/afs")])) ? + &afspath[strlen("/afs")]:"/", "afsdsbmt.ini"); strcpy(ioctlp->outDatap, submountreqp); @@ -1848,8 +1850,9 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp) sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount); WritePrivateProfileString("AFS Submounts", ioctlp->outDatap, - &afspath[lstrlen("/afs")], - "afsdsbmt.ini"); + (strlen(&afspath[lstrlen("/afs")])) ? + &afspath[lstrlen("/afs")]:"/", + "afsdsbmt.ini"); ioctlp->outDatap += strlen(ioctlp->outDatap) +1; lock_ReleaseMutex(&cm_Afsdsbmt_Lock); diff --git a/src/WINNT/afsd/cm_rpc.c b/src/WINNT/afsd/cm_rpc.c index 33f4c8ee4..882e056a6 100644 --- a/src/WINNT/afsd/cm_rpc.c +++ b/src/WINNT/afsd/cm_rpc.c @@ -26,7 +26,7 @@ #include "smb.h" -#include +#include /* * The motivation for this whole module is that in transmitting tokens @@ -81,15 +81,16 @@ BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]) te = tokenEvents; ltep = &tokenEvents; while (te) { - if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) + if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) { *ltep = te->next; lock_ReleaseMutex(&tokenEventLock); memcpy(sessionKey, te->sessionKey, sizeof(te->sessionKey)); free(te); return TRUE; - ltep = &te->next; - te = te->next; + } + ltep = &te->next; + te = te->next; } lock_ReleaseMutex(&tokenEventLock); return FALSE; diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 0fa49bc84..b6de8c3b7 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -2363,8 +2363,9 @@ nextEntry: * or if something went wrong, close the search. */ /* ((searchFlags & 1) || ((searchFlags & 2) && eos) */ - if ((searchFlags & 1) || (returnedNames == 0) - || code != 0) smb_DeleteDirSearch(dsp); + if ((searchFlags & 1) || (returnedNames == 0) || ((searchFlags & 2) && + eos) || code != 0) + smb_DeleteDirSearch(dsp); if (code) smb_SendTran2Error(vcp, p, opx, code); else { @@ -3136,7 +3137,7 @@ long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp) || (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE))) { /* look up parent directory */ code = cm_NameI(baseDirp, spacep->data, - CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD, + CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD | CM_FLAG_CHECKPATH, userp, tidPathp, &req, &dscp); if (baseFid != 0) smb_ReleaseFID(baseFidp); diff --git a/src/WINNT/client_creds/shortcut.cpp b/src/WINNT/client_creds/shortcut.cpp index b6c4adef7..2b83e70cd 100644 --- a/src/WINNT/client_creds/shortcut.cpp +++ b/src/WINNT/client_creds/shortcut.cpp @@ -13,7 +13,6 @@ extern "C" { } #include -#include #include #include #undef INITGUID diff --git a/src/WINNT/client_exp/shell_ext.cpp b/src/WINNT/client_exp/shell_ext.cpp index 37e0f1102..304cd7796 100644 --- a/src/WINNT/client_exp/shell_ext.cpp +++ b/src/WINNT/client_exp/shell_ext.cpp @@ -14,6 +14,7 @@ extern "C" { #include #include "stdafx.h" +#include #include #include #include "afs_shl_ext.h" diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c index 153c49536..084c26f13 100644 --- a/src/afs/DARWIN/osi_vnodeops.c +++ b/src/afs/DARWIN/osi_vnodeops.c @@ -1,7 +1,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.1.1.7 2002/09/26 18:58:05 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.1.1.8 2003/04/13 19:02:42 hartmans Exp $"); #include /* Standard vendor system headers */ #include /* Afs-based standard headers */ @@ -283,7 +283,7 @@ afs_vop_open(ap) panic("AFS open changed vnode!"); #endif afs_BozonLock(&vc->pvnLock, vc); - osi_FlushPages(vc); + osi_FlushPages(vc, ap->a_cred); afs_BozonUnlock(&vc->pvnLock, vc); AFS_GUNLOCK(); return error; @@ -306,7 +306,7 @@ afs_vop_close(ap) else code=afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); #ifdef AFS_DARWIN14_ENV @@ -381,7 +381,7 @@ afs_vop_read(ap) struct vcache *avc=VTOAFS(ap->a_vp); AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ code=afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0); afs_BozonUnlock(&avc->pvnLock, avc); AFS_GUNLOCK(); @@ -458,7 +458,7 @@ afs_vop_pagein(ap) aiov.iov_base = (caddr_t)ioaddr; AFS_GLOCK(); afs_BozonLock(&tvc->pvnLock, tvc); - osi_FlushPages(tvc); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ code=afs_read(tvc, uio, cred, 0, 0, 0); if (code == 0) { ObtainWriteLock(&tvc->lock, 2); @@ -467,6 +467,11 @@ afs_vop_pagein(ap) } afs_BozonUnlock(&tvc->pvnLock, tvc); AFS_GUNLOCK(); + + /* Zero out rest of last page if there wasn't enough data in the file */ + if (code == 0 && auio.uio_resid > 0) + memset(aiov.iov_base, 0, auio.uio_resid); + kernel_upl_unmap(kernel_map, pl); if (!nocommit) { if (code) @@ -494,7 +499,7 @@ afs_vop_write(ap) void *object; AFS_GLOCK(); afs_BozonLock(&avc->pvnLock, avc); - osi_FlushPages(avc); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ if (UBCINFOEXISTS(ap->a_vp)) ubc_clean(ap->a_vp, 1); if (UBCINFOEXISTS(ap->a_vp)) @@ -622,7 +627,7 @@ afs_vop_pageout(ap) AFS_GLOCK(); afs_BozonLock(&tvc->pvnLock, tvc); - osi_FlushPages(tvc); /* hold bozon lock, but not basic vnode lock */ + osi_FlushPages(tvc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */ ObtainWriteLock(&tvc->lock, 1); afs_FakeOpen(tvc); ReleaseWriteLock(&tvc->lock); diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c index 0fec7f045..0b8b596d8 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -13,7 +13,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/IRIX/osi_vfsops.c,v 1.1.1.6 2002/05/10 23:43:59 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/IRIX/osi_vfsops.c,v 1.1.1.7 2003/04/13 19:02:45 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -518,7 +518,6 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) { struct VenusFid vfid; struct vrequest treq; - extern struct cell *afs_GetCellByIndex(); register struct cell *tcell; register afs_int32 code = 0; afs_int32 ret; @@ -537,13 +536,13 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t **avcp, struct fid *fidp) afid2 = (afs_fid2_t*)fidp; if (afid2->af_len == sizeof(afs_fid2_t) - sizeof(afid2->af_len)) { /* It's a checkpoint restart fid. */ - tcell = afs_GetCellByIndex(afid2->af_cell, READ_LOCK, 0 /* !refresh */); + tcell = afs_GetCellByIndex(afid2->af_cell, READ_LOCK); if (!tcell) { code = ENOENT; goto out; - } - vfid.Cell = tcell->cell; - afs_PutCell(tcell, WRITE_LOCK); + } + vfid.Cell = tcell->cellNum; + afs_PutCell(tcell, READ_LOCK); vfid.Fid.Volume = afid2->af_volid; vfid.Fid.Vnode = afid2->af_vno; vfid.Fid.Unique = afid2->af_uniq; diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index d6a8fc5ae..ff97f1953 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -16,7 +16,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_groups.c,v 1.1.1.10 2002/12/11 02:36:15 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_groups.c,v 1.1.1.11 2003/04/13 19:02:45 hartmans Exp $"); #include "../afs/sysincludes.h" #include "../afs/afsincludes.h" @@ -33,14 +33,20 @@ static int afs_setgroups(cred_t **cr, int ngroups, gid_t *gidset, int change_par */ int set_pag_in_parent(int pag, int g0, int g1) { +#ifdef STRUCT_TASK_STRUCT_HAS_PARENT + gid_t *gp = current->parent->groups; +#else gid_t *gp = current->p_pptr->groups; +#endif int ngroups; int i; +#ifdef STRUCT_TASK_STRUCT_HAS_PARENT + ngroups = current->parent->ngroups; +#else ngroups = current->p_pptr->ngroups; - gp = current->p_pptr->groups; - +#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 */ @@ -57,7 +63,11 @@ int set_pag_in_parent(int pag, int g0, int 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; } diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c index edf1e6dfa..91dde0e29 100644 --- a/src/afs/LINUX/osi_sleep.c +++ b/src/afs/LINUX/osi_sleep.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_sleep.c,v 1.1.1.9 2002/08/02 04:28:56 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/LINUX/osi_sleep.c,v 1.1.1.10 2003/04/13 19:02:46 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -192,18 +192,19 @@ void afs_osi_Sleep(char *event) set_current_state(TASK_INTERRUPTIBLE); AFS_ASSERT_GLOCK(); AFS_GUNLOCK(); - spin_lock_irq(¤t->sigmask_lock); + + SIG_LOCK(current); saved_set = current->blocked; sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); schedule(); - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); current->blocked = saved_set; - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); AFS_GLOCK(); } remove_wait_queue(&evp->cond, &wait); diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c index 43a0182b0..966b52074 100644 --- a/src/afs/UKERNEL/afs_usrops.c +++ b/src/afs/UKERNEL/afs_usrops.c @@ -14,7 +14,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.1.1.9 2002/12/11 02:36:21 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.1.1.10 2003/04/13 19:02:48 hartmans Exp $"); #ifdef UKERNEL @@ -932,6 +932,11 @@ void afs_osi_Free(void *ptr, size_t size) free(ptr); } +void afs_osi_FreeStr(char *ptr) +{ + free(ptr); +} + void *osi_AllocLargeSpace(size_t size) { AFS_STATCNT(osi_AllocLargeSpace); diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 35c94e23c..3f54ac699 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -13,7 +13,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_analyze.c,v 1.1.1.9 2002/09/26 18:57:48 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_analyze.c,v 1.1.1.10 2003/04/13 19:02:33 hartmans Exp $"); #include "../afs/stds.h" #include "../afs/sysincludes.h" /* Standard vendor system headers */ @@ -179,7 +179,7 @@ static int VLDB_Same (afid, areq) do { VSleep(2); /* Better safe than sorry. */ tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cell, &treq, SHARED_LOCK); + tcell->cellNum, &treq, SHARED_LOCK); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -392,8 +392,8 @@ int afs_Analyze(aconn, acode, afid, areq, op, locktype, cellp) if (aerrP) (aerrP->err_Network)++; if (hm_retry_int && !(areq->flags & O_NONBLOCK) && /* "hard" mount */ - ((afid && afid->Cell == LOCALCELL) || - (cellp && cellp->cell == LOCALCELL))) { + ((afid && afs_IsPrimaryCellNum(afid->Cell)) || + (cellp && afs_IsPrimaryCell(cellp)))) { if (!afid) { afs_warnuser("afs: hard-mount waiting for a vlserver to return to service\n"); VSleep(hm_retry_int); @@ -492,7 +492,7 @@ int afs_Analyze(aconn, acode, afid, areq, op, locktype, cellp) if (aerrP) (aerrP->err_Protection)++; - tu = afs_FindUser(areq->uid, tsp->cell->cell, READ_LOCK); + tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK); if (tu) { if ((acode == VICETOKENDEAD) || (acode == RXKADEXPIRED)) afs_warnuser("afs: Tokens for user of AFS id %d for cell %s have expired\n", diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 6eb2d4e0d..9608523c6 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -16,7 +16,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_callback.c,v 1.1.1.9 2002/06/10 11:39:52 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_callback.c,v 1.1.1.10 2003/04/13 19:02:34 hartmans Exp $"); #include "../afs/sysincludes.h" /*Standard vendor system headers*/ #include "../afs/afsincludes.h" /*AFS-based standard headers*/ @@ -1137,7 +1137,7 @@ int SRXAFSCB_GetCellServDB( #endif /* RX_ENABLE_LOCKS */ AFS_STATCNT(SRXAFSCB_GetCellServDB); - tcell = afs_GetCellByIndex(a_index, READ_LOCK, 0); + tcell = afs_GetCellByIndex(a_index, READ_LOCK); if (!tcell) { i = 0; @@ -1203,7 +1203,6 @@ int SRXAFSCB_GetLocalCell( { int plen; struct cell *tcell; - struct afs_q *cq, *tq; char *t_name, *p_name = NULL; #ifdef RX_ENABLE_LOCKS @@ -1214,27 +1213,16 @@ int SRXAFSCB_GetLocalCell( /* Search the list for the primary cell. Cell number 1 is only * the primary cell is when no other cell is explicitly marked as * the primary cell. */ - ObtainReadLock(&afs_xcell); - - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tq = QNext(cq); - tcell = QTOC(cq); - if (tcell->states & CPrimary) { - p_name = tcell->cellName; - break; - } - if (tcell->cell == 1) { - p_name = tcell->cellName; - } - } - + tcell = afs_GetPrimaryCell(READ_LOCK); + if (tcell) + p_name = tcell->cellName; if (p_name) plen = strlen(p_name); else plen = 0; t_name = (char *)afs_osi_Alloc(plen+1); if (t_name == NULL) { - ReleaseReadLock(&afs_xcell); + if (tcell) afs_PutCell(tcell, READ_LOCK); #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS */ @@ -1245,13 +1233,12 @@ int SRXAFSCB_GetLocalCell( if (p_name) memcpy(t_name, p_name, plen); - ReleaseReadLock(&afs_xcell); - #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS */ *a_name = t_name; + if (tcell) afs_PutCell(tcell, READ_LOCK); return 0; } @@ -1369,3 +1356,69 @@ int SRXAFSCB_GetCacheConfig( return 0; } + +/*------------------------------------------------------------------------ + * EXPORTED SRXAFSCB_GetCellByNum + * + * Description: + * Routine to get information about a cell specified by its + * cell number (returned by GetCE/GetCE64). + * + * Arguments: + * a_call : Ptr to Rx call on which this request came in. + * a_cellnum : Input cell number + * a_name : Output cell name (one zero byte when no such cell). + * a_hosts : Output cell database servers in host byte order. + * + * Returns: + * 0 on success + * + * Environment: + * Nothing interesting. + * + * Side Effects: + * As advertised. + *------------------------------------------------------------------------*/ + +int SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum, + char **a_name, serverList *a_hosts) +{ + afs_int32 i, sn; + struct cell *tcell; + +#ifdef RX_ENABLE_LOCKS + AFS_GLOCK(); +#endif /* RX_ENABLE_LOCKS */ + AFS_STATCNT(SRXAFSCB_GetCellByNum); + + a_hosts->serverList_val = 0; + a_hosts->serverList_len = 0; + + tcell = afs_GetCellStale(a_cellnum, READ_LOCK); + if (!tcell) { + *a_name = afs_strdup(""); +#ifdef RX_ENABLE_LOCKS + AFS_GUNLOCK(); +#endif /* RX_ENABLE_LOCKS */ + return 0; + } + + ObtainReadLock(&tcell->lock); + *a_name = afs_strdup(tcell->cellName); + + for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++) + ; + a_hosts->serverList_len = sn; + a_hosts->serverList_val = (afs_int32 *) afs_osi_Alloc(sn*sizeof(afs_int32)); + + for (i = 0; i < sn; i++) + a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip); + ReleaseReadLock(&tcell->lock); + afs_PutCell(tcell, READ_LOCK); + +#ifdef RX_ENABLE_LOCKS + AFS_GUNLOCK(); +#endif /* RX_ENABLE_LOCKS */ + return 0; +} + diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index f514304e3..b6f72d864 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -11,523 +11,674 @@ * Implements: */ #include -#include "../afs/param.h" +#include "afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_cell.c,v 1.1.1.11 2002/09/26 18:57:50 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_cell.c,v 1.1.1.12 2003/04/13 19:02:34 hartmans Exp $"); -#include "../afs/stds.h" -#include "../afs/sysincludes.h" /* Standard vendor system headers */ - -#if !defined(UKERNEL) -#include -#include - -#ifdef AFS_SGI62_ENV -#include "../h/hashing.h" -#endif -#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN60_ENV) -#include -#endif /* ! ASF_HPUX110_ENV */ -#endif /* !defined(UKERNEL) */ - -#include "../afs/afsincludes.h" /* Afs-based standard headers */ -#include "../afs/afs_stats.h" /* afs statistics */ - -#if defined(AFS_SUN56_ENV) -#include -#include -#if defined(AFS_SUN58_ENV) -#include -#endif -#include -#endif - -/* Exported variables */ -afs_rwlock_t afs_xcell; /* allocation lock for cells */ -struct afs_q CellLRU; -afs_int32 afs_cellindex=0; -afs_int32 afs_realcellindex=0; -afs_uint32 afs_nextCellNum = 0x100; +#include "afs/stds.h" +#include "afs/sysincludes.h" /* Standard vendor system headers */ +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* afs statistics */ +#include "afs/afs_osi.h" /* Local variables. */ -struct cell *afs_rootcell = 0; - -/* Handler waiting for request from client */ -static char afs_AfsdbHandlerWait; -/* Client waiting for handler to become available or finish request */ -static char afs_AfsdbLookupWait; - -/* Set to 1 when we've seen the userspace AFSDB process at least once */ -char afs_AfsdbHandlerPresent = 0; -/* Set to 1 when there is a client interacting with the AFSDB handler. - * Protects the in and out variables below. Protected by GLOCK. */ -char afs_AfsdbHandlerInuse = 0; -/* Set to 1 when AFSDB has been shut down */ -char afs_AfsdbHandlerShutdown = 0; - -/* Input to handler from the client: cell name to look up */ -char *afs_AfsdbHandler_CellName; -/* Outputs from handler to client: cell hosts, TTL, and real cell name */ -afs_int32 *afs_AfsdbHandler_CellHosts; -int *afs_AfsdbHandler_Timeout; -char **afs_AfsdbHandler_RealName; - -/* Client sets ReqPending to 1 whenever it queues a request for it */ -char afs_AfsdbHandler_ReqPending = 0; -/* Handler sets Completed to 1 when it completes the client request */ -char afs_AfsdbHandler_Completed = 0; - - -struct cell *afs_GetCellByName2(); - -int afs_strcasecmp(s1, s2) - register char *s1, *s2; -{ - while (*s1 && *s2) { - register char c1, c2; - - c1 = *s1++; - c2 = *s2++; - if (c1 >= 'A' && c1 <= 'Z') c1 += 0x20; - if (c2 >= 'A' && c2 <= 'Z') c2 += 0x20; - if (c1 != c2) - return c1-c2; - } - - return *s1 - *s2; -} +afs_rwlock_t afs_xcell; /* Export for cmdebug peeking at locks */ +/* + * AFSDB implementation: + * + * afs_StopAFSDB: terminate the AFSDB handler, used on shutdown + * afs_AFSDBHandler: entry point for user-space AFSDB request handler + * afs_GetCellHostsAFSDB: query the AFSDB handler and wait for response + * afs_LookupAFSDB: look up AFSDB for given cell name and create locally + */ #ifdef AFS_AFSDB_ENV -void afs_StopAfsdb() +static afs_rwlock_t afsdb_client_lock; /* Serializes client requests */ +static char afsdb_handler_running; /* Protected by GLOCK */ +static char afsdb_handler_shutdown; /* Protected by GLOCK */ + +static struct { + afs_rwlock_t lock; + char pending; + char complete; + char *cellname; + afs_int32 *cellhosts; + int *timeout; + char **realname; +} afsdb_req; + +void afs_StopAFSDB() { - if (afs_AfsdbHandlerPresent) { - afs_osi_Wakeup(&afs_AfsdbHandlerWait); + if (afsdb_handler_running) { + afs_osi_Wakeup(&afsdb_req); } else { - afs_AfsdbHandlerShutdown = 1; + afsdb_handler_shutdown = 1; afs_termState = AFSOP_STOP_RXEVENT; } } -int afs_AfsdbHandler(acellName, acellNameLen, kernelMsg) - char *acellName; - int acellNameLen; - afs_int32 *kernelMsg; +int afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 *kernelMsg) { - /* afs_syscall_call() has already grabbed the global lock */ - - if (afs_AfsdbHandlerShutdown) return -2; - afs_AfsdbHandlerPresent = 1; + if (afsdb_handler_shutdown) return -2; + afsdb_handler_running = 1; - if (afs_AfsdbHandler_ReqPending) { + ObtainSharedLock(&afsdb_req.lock, 683); + if (afsdb_req.pending) { int i, hostCount; + UpgradeSToWLock(&afsdb_req.lock, 684); hostCount = kernelMsg[0]; - *afs_AfsdbHandler_Timeout = kernelMsg[1]; - if (*afs_AfsdbHandler_Timeout) *afs_AfsdbHandler_Timeout += osi_Time(); - - *afs_AfsdbHandler_RealName = afs_osi_Alloc(strlen(acellName) + 1); - strcpy(*afs_AfsdbHandler_RealName, acellName); + *afsdb_req.timeout = kernelMsg[1]; + if (*afsdb_req.timeout) *afsdb_req.timeout += osi_Time(); + *afsdb_req.realname = afs_strdup(acellName); for (i=0; i= hostCount) - afs_AfsdbHandler_CellHosts[i] = 0; + afsdb_req.cellhosts[i] = 0; else - afs_AfsdbHandler_CellHosts[i] = kernelMsg[2+i]; + afsdb_req.cellhosts[i] = kernelMsg[2+i]; } /* Request completed, wake up the relevant thread */ - afs_AfsdbHandler_ReqPending = 0; - afs_AfsdbHandler_Completed = 1; - afs_osi_Wakeup(&afs_AfsdbLookupWait); + afsdb_req.pending = 0; + afsdb_req.complete = 1; + afs_osi_Wakeup(&afsdb_req); + ConvertWToSLock(&afsdb_req.lock); } + ConvertSToRLock(&afsdb_req.lock); /* Wait for a request */ - while (afs_AfsdbHandler_ReqPending == 0 && afs_termState != AFSOP_STOP_AFSDB) - afs_osi_Sleep(&afs_AfsdbHandlerWait); + while (afsdb_req.pending == 0 && afs_termState != AFSOP_STOP_AFSDB) { + ReleaseReadLock(&afsdb_req.lock); + afs_osi_Sleep(&afsdb_req); + ObtainReadLock(&afsdb_req.lock); + } /* Check if we're shutting down */ if (afs_termState == AFSOP_STOP_AFSDB) { + ReleaseReadLock(&afsdb_req.lock); + /* Inform anyone waiting for us that we're going away */ - afs_AfsdbHandlerShutdown = 1; - afs_AfsdbHandlerPresent = 0; - afs_osi_Wakeup(&afs_AfsdbLookupWait); + afsdb_handler_shutdown = 1; + afsdb_handler_running = 0; + afs_osi_Wakeup(&afsdb_req); afs_termState = AFSOP_STOP_RXEVENT; afs_osi_Wakeup(&afs_termState); return -2; } - /* Copy the requested cell name into the request buffer */ - strncpy(acellName, afs_AfsdbHandler_CellName, acellNameLen); - /* Return the lookup request to userspace */ + strncpy(acellName, afsdb_req.cellname, acellNameLen); + ReleaseReadLock(&afsdb_req.lock); return 0; } -#endif +static int afs_GetCellHostsAFSDB(char *acellName, afs_int32 *acellHosts, + int *timeout, char **realName) +{ + AFS_ASSERT_GLOCK(); + if (!afsdb_handler_running) return ENOENT; + + ObtainWriteLock(&afsdb_client_lock, 685); + ObtainWriteLock(&afsdb_req.lock, 686); -int afs_GetCellHostsFromDns(acellName, acellHosts, timeout, realName) - char *acellName; - afs_int32 *acellHosts; - int *timeout; - char **realName; + *acellHosts = 0; + afsdb_req.cellname = acellName; + afsdb_req.cellhosts = acellHosts; + afsdb_req.timeout = timeout; + afsdb_req.realname = realName; + + afsdb_req.complete = 0; + afsdb_req.pending = 1; + afs_osi_Wakeup(&afsdb_req); + ConvertWToRLock(&afsdb_req.lock); + + while (afsdb_handler_running && !afsdb_req.complete) { + ReleaseReadLock(&afsdb_req.lock); + afs_osi_Sleep(&afsdb_req); + ObtainReadLock(&afsdb_req.lock); + }; + ReleaseReadLock(&afsdb_req.lock); + ReleaseWriteLock(&afsdb_client_lock); + + if (*acellHosts) + return 0; + else + return ENOENT; +} +#endif + +void afs_LookupAFSDB(char *acellName) { #ifdef AFS_AFSDB_ENV - char grab_glock = 0; + afs_int32 cellHosts[MAXCELLHOSTS]; + char *realName = NULL; + int code, timeout; + + code = afs_GetCellHostsAFSDB(acellName, cellHosts, &timeout, &realName); + if (code) goto done; + code = afs_NewCell(realName, cellHosts, CNoSUID, NULL, 0, 0, timeout); + if (code) goto done; - if (!afs_AfsdbHandlerPresent) return ENOENT; + /* If we found an alias, create it */ + if (afs_strcasecmp(acellName, realName)) + afs_NewCellAlias(acellName, realName); - /* Initialize host list to empty in case the handler is gone */ - *acellHosts = 0; +done: + if (realName) + afs_osi_FreeStr(realName); +#endif +} - if (!ISAFS_GLOCK()) { - grab_glock = 1; - AFS_GLOCK(); - } +/* + * Cell name-to-ID mapping + * + * afs_cellname_new: create a new cell name, optional cell number + * afs_cellname_lookup_id: look up a cell name + * afs_cellname_lookup_name: look up a cell number + * afs_cellname_ref: note that this cell name was referenced somewhere + * afs_cellname_init: load the list of cells from given inode + * afs_cellname_write: write in-kernel list of cells to disk + */ - /* Wait until the AFSDB handler is available, and grab it */ - while (afs_AfsdbHandlerInuse) - afs_osi_Sleep(&afs_AfsdbLookupWait); - afs_AfsdbHandlerInuse = 1; +struct cell_name *afs_cellname_head; /* Export for kdump */ +static ino_t afs_cellname_inode; +static int afs_cellname_inode_set; +static int afs_cellname_dirty; +static afs_int32 afs_cellnum_next; - /* Set up parameters for the handler */ - afs_AfsdbHandler_CellName = acellName; - afs_AfsdbHandler_CellHosts = acellHosts; - afs_AfsdbHandler_Timeout = timeout; - afs_AfsdbHandler_RealName = realName; +static struct cell_name *afs_cellname_new(char *name, afs_int32 cellnum) +{ + struct cell_name *cn; - /* Wake up the AFSDB handler */ - afs_AfsdbHandler_Completed = 0; - afs_AfsdbHandler_ReqPending = 1; - afs_osi_Wakeup(&afs_AfsdbHandlerWait); + if (cellnum == 0) + cellnum = afs_cellnum_next; - /* Wait for the handler to get back to us with the reply */ - while (afs_AfsdbHandlerPresent && !afs_AfsdbHandler_Completed) - afs_osi_Sleep(&afs_AfsdbLookupWait); + cn = (struct cell_name *) afs_osi_Alloc(sizeof(*cn)); + cn->next = afs_cellname_head; + cn->cellnum = cellnum; + cn->cellname = afs_strdup(name); + cn->used = 0; + afs_cellname_head = cn; - /* Release the AFSDB handler and wake up others waiting for it */ - afs_AfsdbHandlerInuse = 0; - afs_osi_Wakeup(&afs_AfsdbLookupWait); + if (cellnum >= afs_cellnum_next) + afs_cellnum_next = cellnum + 1; - if (grab_glock) AFS_GUNLOCK(); + return cn; +} - if (*acellHosts) return 0; - return ENOENT; -#else - return ENOENT; -#endif +static struct cell_name *afs_cellname_lookup_id(afs_int32 cellnum) +{ + struct cell_name *cn; + + for (cn = afs_cellname_head; cn; cn = cn->next) + if (cn->cellnum == cellnum) + return cn; + + return NULL; } +static struct cell_name *afs_cellname_lookup_name(char *name) +{ + struct cell_name *cn; + + for (cn = afs_cellname_head; cn; cn = cn->next) + if (strcmp(cn->cellname, name) == 0) + return cn; -void afs_RefreshCell(ac) - register struct cell *ac; + return NULL; +} + +static void afs_cellname_ref(struct cell_name *cn) { - afs_int32 cellHosts[MAXCELLHOSTS]; - char *realName = NULL; - struct cell *tc; - int timeout; - - /* Don't need to do anything if no timeout or it's not expired */ - if (!ac->timeout || ac->timeout > osi_Time()) return; - - if (afs_GetCellHostsFromDns(ac->cellName, cellHosts, &timeout, &realName)) - /* In case of lookup failure, keep old data */ - goto done; - - /* Refresh the DB servers for the real cell; other values stay the same. */ - afs_NewCell(realName, cellHosts, 0, (char *) 0, 0, 0, timeout, (char *) 0); - - /* If this is an alias, update the alias entry too */ - if (afs_strcasecmp(ac->cellName, realName)) { - /* - * Look up the entry we just updated, to compensate for - * uppercase-vs-lowercase lossage with DNS. - */ - tc = afs_GetCellByName2(realName, READ_LOCK, 0 /* no AFSDB */); - - if (tc) { - afs_NewCell(ac->cellName, 0, CAlias, (char *) 0, 0, 0, - timeout, tc->cellName); - afs_PutCell(tc, READ_LOCK); + if (!cn->used) { + cn->used = 1; + afs_cellname_dirty = 1; + } +} + +int afs_cellname_init(ino_t inode, int lookupcode) +{ + struct osi_file *tfile; + int cc, off = 0; + + ObtainWriteLock(&afs_xcell, 692); + + afs_cellnum_next = 1; + afs_cellname_dirty = 0; + + if (cacheDiskType == AFS_FCACHE_TYPE_MEM) { + ReleaseWriteLock(&afs_xcell); + return 0; + } + if (lookupcode) { + ReleaseWriteLock(&afs_xcell); + return lookupcode; + } + + tfile = osi_UFSOpen(inode); + if (!tfile) { + ReleaseWriteLock(&afs_xcell); + return EIO; + } + + afs_cellname_inode = inode; + afs_cellname_inode_set = 1; + + while (1) { + afs_int32 cellnum, clen, magic; + struct cell_name *cn; + char *cellname; + + cc = afs_osi_Read(tfile, off, &magic, sizeof(magic)); + if (cc != sizeof(magic)) + break; + if (magic != AFS_CELLINFO_MAGIC) + break; + off += cc; + + cc = afs_osi_Read(tfile, off, &cellnum, sizeof(cellnum)); + if (cc != sizeof(cellnum)) + break; + off += cc; + + cc = afs_osi_Read(tfile, off, &clen, sizeof(clen)); + if (cc != sizeof(clen)) + break; + off += cc; + + cellname = afs_osi_Alloc(clen + 1); + if (!cellname) + break; + + cc = afs_osi_Read(tfile, off, cellname, clen); + if (cc != clen) { + afs_osi_Free(cellname, clen + 1); + break; + } + off += cc; + cellname[clen] = '\0'; + + if (afs_cellname_lookup_name(cellname) || + afs_cellname_lookup_id(cellnum)) { + afs_osi_Free(cellname, clen + 1); + break; } + + cn = afs_cellname_new(cellname, cellnum); + afs_osi_Free(cellname, clen + 1); } -done: - if (realName) - afs_osi_Free(realName, strlen(realName) + 1); + osi_UFSClose(tfile); + ReleaseWriteLock(&afs_xcell); + return 0; } - -struct cell *afs_GetCellByName_Dns(acellName, locktype) - register char *acellName; - afs_int32 locktype; +int afs_cellname_write() { - afs_int32 cellHosts[MAXCELLHOSTS]; - char *realName = NULL; - struct cell *tc; - int timeout; + struct osi_file *tfile; + struct cell_name *cn; + int off; + + if (!afs_cellname_dirty || !afs_cellname_inode_set) + return 0; + if (afs_initState != 300) + return 0; + + ObtainWriteLock(&afs_xcell, 693); + afs_cellname_dirty = 0; + off = 0; + tfile = osi_UFSOpen(afs_cellname_inode); + if (!tfile) { + ReleaseWriteLock(&afs_xcell); + return EIO; + } - if (afs_GetCellHostsFromDns(acellName, cellHosts, &timeout, &realName)) - goto bad; - if (afs_NewCell(realName, cellHosts, CNoSUID, (char *) 0, 0, 0, - timeout, (char *) 0)) - goto bad; + for (cn = afs_cellname_head; cn; cn = cn->next) { + afs_int32 magic, cellnum, clen; + int cc; - /* If this is an alias, create an entry for it too */ - if (afs_strcasecmp(acellName, realName)) { - /* - * Look up the entry we just updated, to compensate for - * uppercase-vs-lowercase lossage with DNS. - */ - tc = afs_GetCellByName2(realName, READ_LOCK, 0 /* no AFSDB */); - if (!tc) - goto bad; + if (!cn->used) + continue; - if (afs_NewCell(acellName, 0, CAlias, (char *) 0, 0, 0, - timeout, tc->cellName)) { - afs_PutCell(tc, READ_LOCK); - goto bad; - } + magic = AFS_CELLINFO_MAGIC; + cc = afs_osi_Write(tfile, off, &magic, sizeof(magic)); + if (cc != sizeof(magic)) + break; + off += cc; - afs_PutCell(tc, READ_LOCK); + cellnum = cn->cellnum; + cc = afs_osi_Write(tfile, off, &cellnum, sizeof(cellnum)); + if (cc != sizeof(cellnum)) + break; + off += cc; + + clen = strlen(cn->cellname); + cc = afs_osi_Write(tfile, off, &clen, sizeof(clen)); + if (cc != sizeof(clen)) + break; + off += cc; + + cc = afs_osi_Write(tfile, off, cn->cellname, clen); + if (cc != clen) + break; + off += clen; } - if (realName) - afs_osi_Free(realName, strlen(realName) + 1); - return afs_GetCellByName2(acellName, locktype, 0); + osi_UFSClose(tfile); + ReleaseWriteLock(&afs_xcell); + return 0; +} -bad: - if (realName) - afs_osi_Free(realName, strlen(realName) + 1); - return (struct cell *) 0; +/* + * Cell alias implementation + * + * afs_FindCellAlias: look up cell alias by alias name + * afs_GetCellAlias: get cell alias by index (starting at 0) + * afs_PutCellAlias: put back a cell alias returned by Find or Get + * afs_NewCellAlias: create new cell alias entry + */ + +struct cell_alias *afs_cellalias_head; /* Export for kdump */ +static afs_int32 afs_cellalias_index; +static int afs_CellOrAliasExists_nl(char *aname); /* Forward declaration */ + +static struct cell_alias *afs_FindCellAlias(char *alias) +{ + struct cell_alias *tc; + + for (tc = afs_cellalias_head; tc != NULL; tc = tc->next) + if (!strcmp(alias, tc->alias)) + break; + return tc; } +struct cell_alias *afs_GetCellAlias(int index) +{ + struct cell_alias *tc; -struct cell *afs_GetCellByName2(acellName, locktype, trydns) - register char *acellName; - afs_int32 locktype; - char trydns; + ObtainReadLock(&afs_xcell); + for (tc = afs_cellalias_head; tc != NULL; tc = tc->next) + if (tc->index == index) + break; + ReleaseReadLock(&afs_xcell); + + return tc; +} + +void afs_PutCellAlias(struct cell_alias *a) { - register struct cell *tc; - register struct afs_q *cq, *tq; - int didAlias = 0; + return; +} - AFS_STATCNT(afs_GetCellByName); -retry: - ObtainWriteLock(&afs_xcell,100); - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (!afs_strcasecmp(tc->cellName, acellName)) { - QRemove(&tc->lruq); - QAdd(&CellLRU, &tc->lruq); - ReleaseWriteLock(&afs_xcell); - afs_RefreshCell(tc); - if ((tc->states & CAlias) && (didAlias == 0)) { - acellName = tc->realName; - if (!acellName) return (struct cell *) 0; - didAlias = 1; - goto retry; - } - return tc; - } +afs_int32 afs_NewCellAlias(char *alias, char *cell) +{ + struct cell_alias *tc; + + ObtainSharedLock(&afs_xcell, 681); + if (afs_CellOrAliasExists_nl(alias)) { + ReleaseSharedLock(&afs_xcell); + return EEXIST; } + + UpgradeSToWLock(&afs_xcell, 682); + tc = (struct cell_alias *) afs_osi_Alloc(sizeof(struct cell_alias)); + tc->alias = afs_strdup(alias); + tc->cell = afs_strdup(cell); + tc->next = afs_cellalias_head; + tc->index = afs_cellalias_index++; + afs_cellalias_head = tc; ReleaseWriteLock(&afs_xcell); - return trydns ? afs_GetCellByName_Dns(acellName, locktype) - : (struct cell *) 0; -} /*afs_GetCellByName2*/ + afs_DynrootInvalidate(); + return 0; +} +/* + * Actual cell list implementation + * + * afs_UpdateCellLRU: bump given cell up to the front of the LRU queue + * afs_RefreshCell: look up cell information in AFSDB if timeout expired + * + * afs_TraverseCells: execute a callback for each existing cell + * afs_TraverseCells_nl: same as above except without locking afs_xcell + * afs_choose_cell_by_{name,num,index}: useful traversal callbacks + * + * afs_FindCellByName: return a cell with a given name, if it exists + * afs_FindCellByName_nl: same as above, without locking afs_xcell + * afs_GetCellByName: same as FindCellByName but tries AFSDB if not found + * afs_GetCell: return a cell with a given cell number + * afs_GetCellStale: same as GetCell, but does not try to refresh the data + * afs_GetCellByIndex: return a cell with a given index number (starting at 0) + * + * afs_GetPrimaryCell: return the primary cell, if any + * afs_IsPrimaryCell: returns true iff the given cell is the primary cell + * afs_IsPrimaryCellNum: returns afs_IsPrimaryCell(afs_GetCell(cellnum)) + * afs_SetPrimaryCell: set the primary cell name to the given cell name + * + * afs_NewCell: create or update a cell entry + */ -struct cell *afs_GetCellByName(acellName, locktype) - register char *acellName; - afs_int32 locktype; +struct afs_q CellLRU; /* Export for kdump */ +static char *afs_thiscell; +static afs_int32 afs_cellindex; + +static void afs_UpdateCellLRU(struct cell *c) { - return afs_GetCellByName2(acellName, locktype, 1); + ObtainWriteLock(&afs_xcell, 100); + QRemove(&c->lruq); + QAdd(&CellLRU, &c->lruq); + ReleaseWriteLock(&afs_xcell); +} -} /*afs_GetCellByName*/ +static void afs_RefreshCell(struct cell *ac) +{ + if (ac->states & CNoAFSDB) + return; + if (!ac->cellHosts[0] || (ac->timeout && ac->timeout <= osi_Time())) + afs_LookupAFSDB(ac->cellName); +} -static struct cell *afs_GetCellInternal(acell, locktype, holdxcell) - register afs_int32 acell; - afs_int32 locktype; - int holdxcell; +static void *afs_TraverseCells_nl(void *(*cb)(struct cell *, void *), void *arg) { - register struct cell *tc; - register struct afs_q *cq, *tq; + struct afs_q *cq, *tq; + struct cell *tc; + void *ret = NULL; - AFS_STATCNT(afs_GetCell); - if (acell == 1 && afs_rootcell) return afs_rootcell; - if (holdxcell) - ObtainWriteLock(&afs_xcell,101); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tc = QTOC(cq); tq = QNext(cq); - if (tc->cell == acell) { - QRemove(&tc->lruq); - QAdd(&CellLRU, &tc->lruq); - if (holdxcell) - ReleaseWriteLock(&afs_xcell); - afs_RefreshCell(tc); - return tc; - } + ret = cb(tc, arg); + if (ret) break; } - if (holdxcell) - ReleaseWriteLock(&afs_xcell); - return (struct cell *) 0; -} /*afs_GetCell*/ + return ret; +} + +void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg) +{ + void *ret; + + ObtainReadLock(&afs_xcell); + ret = afs_TraverseCells_nl(cb, arg); + ReleaseReadLock(&afs_xcell); + + return ret; +} -struct cell *afs_GetCell(acell, locktype) - register afs_int32 acell; - afs_int32 locktype; +static void *afs_choose_cell_by_name(struct cell *cell, void *arg) { - return afs_GetCellInternal(acell, locktype, 1); + return strcmp(cell->cellName, (char *) arg) ? NULL : cell; } -/* This is only to be called if the caller is already holding afs_xcell */ -struct cell *afs_GetCellNoLock(acell, locktype) - register afs_int32 acell; - afs_int32 locktype; +static void *afs_choose_cell_by_num(struct cell *cell, void *arg) { - return afs_GetCellInternal(acell, locktype, 0); + return (cell->cellNum == *((afs_int32 *) arg)) ? cell : NULL; } -struct cell *afs_GetCellByIndex(cellindex, locktype, refresh) - register afs_int32 cellindex; - afs_int32 locktype; - afs_int32 refresh; +static void *afs_choose_cell_by_index(struct cell *cell, void *arg) { - register struct cell *tc; - register struct afs_q *cq, *tq; + return (cell->cellIndex == *((afs_int32 *) arg)) ? cell : NULL; +} - AFS_STATCNT(afs_GetCellByIndex); - ObtainWriteLock(&afs_xcell,102); - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (tc->cellIndex == cellindex) { - QRemove(&tc->lruq); - QAdd(&CellLRU, &tc->lruq); - ReleaseWriteLock(&afs_xcell); - if (refresh) afs_RefreshCell(tc); - return tc; - } +static struct cell *afs_FindCellByName_nl(char *acellName, afs_int32 locktype) +{ + return afs_TraverseCells_nl(&afs_choose_cell_by_name, acellName); +} + +static struct cell *afs_FindCellByName(char *acellName, afs_int32 locktype) +{ + return afs_TraverseCells(&afs_choose_cell_by_name, acellName); +} + +struct cell *afs_GetCellByName(char *acellName, afs_int32 locktype) +{ + struct cell *tc; + + tc = afs_FindCellByName(acellName, locktype); + if (!tc) { + afs_LookupAFSDB(acellName); + tc = afs_FindCellByName(acellName, locktype); } - ReleaseWriteLock(&afs_xcell); - return (struct cell *) 0; + if (tc) { + afs_cellname_ref(tc->cnamep); + afs_UpdateCellLRU(tc); + afs_RefreshCell(tc); + } + + return tc; +} -} /*afs_GetCellByIndex*/ +struct cell *afs_GetCell(afs_int32 cellnum, afs_int32 locktype) +{ + struct cell *tc; + struct cell_name *cn; + tc = afs_GetCellStale(cellnum, locktype); + if (tc) { + afs_RefreshCell(tc); + } else { + ObtainReadLock(&afs_xcell); + cn = afs_cellname_lookup_id(cellnum); + ReleaseReadLock(&afs_xcell); + if (cn) + tc = afs_GetCellByName(cn->cellname, locktype); + } + return tc; +} -struct cell *afs_GetRealCellByIndex(cellindex, locktype, refresh) - register afs_int32 cellindex; - afs_int32 locktype; - afs_int32 refresh; +struct cell *afs_GetCellStale(afs_int32 cellnum, afs_int32 locktype) { - register struct cell *tc; - register struct afs_q *cq, *tq; + struct cell *tc; - AFS_STATCNT(afs_GetCellByIndex); - ObtainWriteLock(&afs_xcell,102); - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (tc->realcellIndex == cellindex) { - QRemove(&tc->lruq); - QAdd(&CellLRU, &tc->lruq); - ReleaseWriteLock(&afs_xcell); - if (refresh) afs_RefreshCell(tc); - return tc; - } + tc = afs_TraverseCells(&afs_choose_cell_by_num, &cellnum); + if (tc) { + afs_cellname_ref(tc->cnamep); + afs_UpdateCellLRU(tc); } - ReleaseWriteLock(&afs_xcell); - return (struct cell *) 0; -} /*afs_GetRealCellByIndex*/ + return tc; +} + +struct cell *afs_GetCellByIndex(afs_int32 index, afs_int32 locktype) +{ + struct cell *tc; + tc = afs_TraverseCells(&afs_choose_cell_by_index, &index); + if (tc) + afs_UpdateCellLRU(tc); + return tc; +} -afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport, timeout, aliasFor) - int aflags; - char *acellName; - register afs_int32 *acellHosts; - char *linkedcname; - u_short fsport, vlport; - int timeout; - char *aliasFor; +struct cell *afs_GetPrimaryCell(afs_int32 locktype) { - register struct cell *tc, *tcl=0; - register afs_int32 i, newc=0, code=0; - register struct afs_q *cq, *tq; + return afs_GetCellByName(afs_thiscell, locktype); +} - AFS_STATCNT(afs_NewCell); - if (!(aflags & CAlias) && *acellHosts == 0) - /* need >= one host to gen cell # */ - return EINVAL; +int afs_IsPrimaryCell(struct cell *cell) +{ + return strcmp(cell->cellName, afs_thiscell) ? 0 : 1; +} - ObtainWriteLock(&afs_xcell,103); +int afs_IsPrimaryCellNum(afs_int32 cellnum) +{ + struct cell *tc; + int primary = 0; - /* Find the cell and mark its servers as not down but gone */ - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (afs_strcasecmp(tc->cellName, acellName) == 0) { - /* if the cell we've found has the correct name but no timeout, - * and we're called with a non-zero timeout, bail out: never - * override static configuration entries with AFSDB ones. */ - if (timeout && !tc->timeout) { - ReleaseWriteLock(&afs_xcell); - return 0; - } - /* we don't want to keep pinging old vlservers which were down, - * since they don't matter any more. It's easier to do this than - * to remove the server from its various hash tables. */ - for (i=0; icellHosts[i]) break; - tc->cellHosts[i]->flags &= ~SRVR_ISDOWN; - tc->cellHosts[i]->flags |= SRVR_ISGONE; - } - break; - } + tc = afs_GetCellStale(cellnum, READ_LOCK); + if (tc) { + primary = afs_IsPrimaryCell(tc); + afs_PutCell(tc, READ_LOCK); } - if (cq != &CellLRU) { + return primary; +} + +afs_int32 afs_SetPrimaryCell(char *acellName) +{ + ObtainWriteLock(&afs_xcell, 691); + if (afs_thiscell) + afs_osi_FreeStr(afs_thiscell); + afs_thiscell = afs_strdup(acellName); + ReleaseWriteLock(&afs_xcell); + return 0; +} + +afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, int aflags, + char *linkedcname, u_short fsport, u_short vlport, int timeout) +{ + struct cell *tc, *tcl=0; + afs_int32 i, newc=0, code=0; + + AFS_STATCNT(afs_NewCell); + + ObtainWriteLock(&afs_xcell, 103); + + tc = afs_FindCellByName_nl(acellName, READ_LOCK); + if (tc) { aflags &= ~CNoSUID; - } - else { + } else { tc = (struct cell *) afs_osi_Alloc(sizeof(struct cell)); - memset((char *)tc, 0, sizeof(*tc)); - QAdd(&CellLRU, &tc->lruq); /* put in lruq */ - tc->cellName = (char *) afs_osi_Alloc(strlen(acellName)+1); - strcpy(tc->cellName, acellName); - tc->cellIndex = afs_cellindex++; - if (aflags & CPrimary) { - extern int afs_rootCellIndex; - tc->cell = 1; /* primary cell is always 1 */ - afs_rootcell = tc; - afs_rootCellIndex = tc->cellIndex; - } else { - tc->cell = afs_nextCellNum++; - } - tc->states = 0; - tc->lcellp = (struct cell *)0; - tc->fsport = (fsport ? fsport : AFS_FSPORT); - tc->vlport = (vlport ? vlport : AFS_VLPORT); - afs_stats_cmperf.numCellsVisible++; - newc++; - if (!(aflags & CAlias)) { - tc->realcellIndex = afs_realcellindex++; - } else { - tc->realcellIndex = -1; - } + memset((char *) tc, 0, sizeof(*tc)); + tc->cellName = afs_strdup(acellName); + tc->fsport = AFS_FSPORT; + tc->vlport = AFS_VLPORT; + RWLOCK_INIT(&tc->lock, "cell lock"); + newc = 1; + if (afs_thiscell && !strcmp(acellName, afs_thiscell)) + aflags &= ~CNoSUID; + } + ObtainWriteLock(&tc->lock, 688); + + /* If the cell we've found has the correct name but no timeout, + * and we're called with a non-zero timeout, bail out: never + * override static configuration entries with AFSDB ones. + * One exception: if the original cell entry had no servers, + * it must get servers from AFSDB. + */ + if (timeout && !tc->timeout && tc->cellHosts[0]) { + code = EINVAL; + goto bad; + } + + /* we don't want to keep pinging old vlservers which were down, + * since they don't matter any more. It's easier to do this than + * to remove the server from its various hash tables. */ + for (i=0; icellHosts[i]) break; + tc->cellHosts[i]->flags &= ~SRVR_ISDOWN; + tc->cellHosts[i]->flags |= SRVR_ISGONE; } + if (fsport) tc->fsport = fsport; + if (vlport) tc->vlport = vlport; + if (aflags & CLinkedCell) { if (!linkedcname) { code = EINVAL; goto bad; } - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tcl = QTOC(cq); tq = QNext(cq); - if (!afs_strcasecmp(tcl->cellName, linkedcname)) { - break; - } - tcl = 0; - } + tcl = afs_FindCellByName_nl(linkedcname, READ_LOCK); if (!tcl) { code = ENOENT; goto bad; @@ -542,71 +693,154 @@ afs_int32 afs_NewCell(acellName, acellHosts, aflags, linkedcname, fsport, vlport tc->states |= aflags; tc->timeout = timeout; - /* Allow converting an alias into a real cell */ - if ((!(aflags & CAlias)) && (tc->states & CAlias)) { - tc->states &= ~CAlias; - tc->realcellIndex = afs_realcellindex++; - } - memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts)); - if (aflags & CAlias) { - if (!aliasFor) { - code = EINVAL; - goto bad; - } - if (tc->realName) afs_osi_Free(tc->realName, strlen(tc->realName)+1); - tc->realName = (char *) afs_osi_Alloc(strlen(aliasFor)+1); - strcpy(tc->realName, aliasFor); - goto done; - } - for (i=0; ivlport, WRITE_LOCK, (afsUUID *)0, 0); - ts->cell = tc; + ts = afs_GetServer(&temp, 1, 0, tc->vlport, WRITE_LOCK, NULL, 0); + ts->cell = tc; ts->flags &= ~SRVR_ISGONE; tc->cellHosts[i] = ts; afs_PutServer(ts, WRITE_LOCK); } afs_SortServers(tc->cellHosts, MAXCELLHOSTS); /* randomize servers */ -done: + + if (newc) { + struct cell_name *cn; + + cn = afs_cellname_lookup_name(acellName); + if (!cn) + cn = afs_cellname_new(acellName, 0); + + tc->cnamep = cn; + tc->cellNum = cn->cellnum; + tc->cellIndex = afs_cellindex++; + afs_stats_cmperf.numCellsVisible++; + QAdd(&CellLRU, &tc->lruq); + } + + ReleaseWriteLock(&tc->lock); ReleaseWriteLock(&afs_xcell); + afs_PutCell(tc, 0); + afs_DynrootInvalidate(); return 0; + bad: if (newc) { - QRemove(&tc->lruq); - afs_osi_Free(tc->cellName, strlen(tc->cellName)+1); - afs_osi_Free((char *)tc, sizeof(struct cell)); + afs_osi_FreeStr(tc->cellName); + afs_osi_Free(tc, sizeof(struct cell)); } + ReleaseWriteLock(&tc->lock); ReleaseWriteLock(&afs_xcell); return code; +} -} /*afs_NewCell*/ +/* + * Miscellaneous stuff + * + * afs_CellInit: perform whatever initialization is necessary + * shutdown_cell: called on shutdown, should deallocate memory, etc + * afs_RemoveCellEntry: remove a server from a cell's server list + * afs_CellOrAliasExists: check if the given name exists as a cell or alias + * afs_CellOrAliasExists_nl: same as above without locking afs_xcell + * afs_CellNumValid: check if a cell number is valid (also set the used flag) + */ -afs_RemoveCellEntry(struct server *srvp) +void afs_CellInit() { - struct cell *tc; - afs_int32 j, k; + RWLOCK_INIT(&afs_xcell, "afs_xcell"); +#ifdef AFS_AFSDB_ENV + RWLOCK_INIT(&afsdb_req.lock, "afsdb_req.lock"); +#endif + QInit(&CellLRU); - tc = srvp->cell; - if (!tc) return; + afs_cellindex = 0; + afs_cellalias_index = 0; +} - /* Remove the server structure from the cell list - if there */ - ObtainWriteLock(&afs_xcell,200); - for (j=k=0; jcellHosts[j]) break; - if (tc->cellHosts[j] != srvp) { - tc->cellHosts[k++] = tc->cellHosts[j]; - } - } - if (k == 0) { - /* What do we do if we remove the last one? */ - } - for (; kcellHosts[k] = 0; - } - ReleaseWriteLock(&afs_xcell); +void shutdown_cell() +{ + struct afs_q *cq, *tq; + struct cell *tc; + + RWLOCK_INIT(&afs_xcell, "afs_xcell"); + + for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { + tc = QTOC(cq); tq = QNext(cq); + if (tc->cellName) afs_osi_FreeStr(tc->cellName); + afs_osi_Free(tc, sizeof(struct cell)); + } + QInit(&CellLRU); +} + +void afs_RemoveCellEntry(struct server *srvp) +{ + struct cell *tc; + afs_int32 j, k; + + tc = srvp->cell; + if (!tc) return; + + /* Remove the server structure from the cell list - if there */ + ObtainWriteLock(&tc->lock, 200); + for (j=k=0; jcellHosts[j]) break; + if (tc->cellHosts[j] != srvp) { + tc->cellHosts[k++] = tc->cellHosts[j]; + } + } + if (k == 0) { + /* What do we do if we remove the last one? */ + } + for (; kcellHosts[k] = 0; + } + ReleaseWriteLock(&tc->lock); +} + +static int afs_CellOrAliasExists_nl(char *aname) +{ + struct cell *c; + struct cell_alias *ca; + + c = afs_FindCellByName_nl(aname, READ_LOCK); + if (c) { + afs_PutCell(c, READ_LOCK); + return 1; + } + + ca = afs_FindCellAlias(aname); + if (ca) { + afs_PutCellAlias(ca); + return 1; + } + + return 0; } +int afs_CellOrAliasExists(char *aname) +{ + int ret; + + ObtainReadLock(&afs_xcell); + ret = afs_CellOrAliasExists_nl(aname); + ReleaseReadLock(&afs_xcell); + + return ret; +} + +int afs_CellNumValid(afs_int32 cellnum) +{ + struct cell_name *cn; + + ObtainReadLock(&afs_xcell); + cn = afs_cellname_lookup_id(cellnum); + ReleaseReadLock(&afs_xcell); + if (cn) { + cn->used = 1; + return 1; + } else { + return 0; + } +} diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 94fa47325..3e145e632 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -13,7 +13,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_dcache.c,v 1.1.1.8 2002/05/10 23:43:12 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_dcache.c,v 1.1.1.9 2003/04/13 19:02:35 hartmans Exp $"); #include "../afs/sysincludes.h" /*Standard vendor system headers*/ #include "../afs/afsincludes.h" /*AFS-based standard headers*/ @@ -2128,7 +2128,7 @@ done: /* * See if this was a reference to a file in the local cell. */ - if (avc->fid.Cell == LOCALCELL) + if (afs_IsPrimaryCellNum(avc->fid.Cell)) afs_stats_cmperf.dlocalAccesses++; else afs_stats_cmperf.dremoteAccesses++; @@ -2297,6 +2297,7 @@ struct dcache *afs_UFSGetDSlot(aslot, tmpdc) register afs_int32 code; register struct dcache *tdc; + int entryok; AFS_STATCNT(afs_UFSGetDSlot); if (CheckLock(&afs_xdcache) != -1) osi_Panic("getdslot nolock"); @@ -2345,9 +2346,16 @@ struct dcache *afs_UFSGetDSlot(aslot, tmpdc) /* * Seek to the aslot'th entry and read it in. */ - code = afs_osi_Read(afs_cacheInodep, sizeof(struct fcache) * aslot + sizeof(struct afs_fheader), - (char *)(&tdc->f), sizeof(struct fcache)); - if (code != sizeof(struct fcache)) { + code = afs_osi_Read(afs_cacheInodep, sizeof(struct fcache) * aslot + + sizeof(struct afs_fheader), + (char *)(&tdc->f), sizeof(struct fcache)); + entryok = 1; + if (code != sizeof(struct fcache)) + entryok = 0; + if (!afs_CellNumValid(tdc->f.fid.Cell)) + entryok = 0; + + if (!entryok) { tdc->f.fid.Cell = 0; tdc->f.fid.Fid.Volume = 0; tdc->f.chunk = -1; @@ -2406,8 +2414,10 @@ afs_WriteDCache(adc, atime) /* * Seek to the right dcache slot and write the in-memory image out to disk. */ - code = afs_osi_Write(afs_cacheInodep, sizeof(struct fcache) * adc->index + sizeof(struct afs_fheader), - (char *)(&adc->f), sizeof(struct fcache)); + afs_cellname_write(); + code = afs_osi_Write(afs_cacheInodep, sizeof(struct fcache) * adc->index + + sizeof(struct afs_fheader), + (char *)(&adc->f), sizeof(struct fcache)); if (code != sizeof(struct fcache)) return EIO; return 0; diff --git a/src/afs/afs_dynroot.c b/src/afs/afs_dynroot.c index 107b3a8bd..724116625 100644 --- a/src/afs/afs_dynroot.c +++ b/src/afs/afs_dynroot.c @@ -14,7 +14,7 @@ * afs_IsDynrootFid * afs_GetDynrootFid * afs_IsDynroot - * afs_RefreshDynroot + * afs_DynrootInvalidate * afs_GetDynroot * afs_PutDynroot * afs_DynrootNewVnode @@ -38,7 +38,7 @@ #include "../afs/prs_fs.h" #include "../afs/dir.h" -#define AFS_DYNROOT_CELL 1 +#define AFS_DYNROOT_CELLNAME "dynroot" #define AFS_DYNROOT_VOLUME 1 #define AFS_DYNROOT_VNODE 1 #define AFS_DYNROOT_UNIQUE 1 @@ -48,7 +48,8 @@ * and a type-specific identifier in the lower 24 bits. */ #define VN_TYPE_CELL 0x01 /* Corresponds to a struct cell */ -#define VN_TYPE_SYMLINK 0x02 /* User-created symlink in /afs */ +#define VN_TYPE_ALIAS 0x02 /* Corresponds to a struct cell_alias */ +#define VN_TYPE_SYMLINK 0x03 /* User-created symlink in /afs */ #define VNUM_TO_VNTYPE(vnum) ((vnum) >> 24) #define VNUM_TO_VNID(vnum) ((vnum) & 0x00ffffff) @@ -59,15 +60,19 @@ #define VNUM_FROM_CIDX_RW(cidx, rw) \ VNUM_FROM_TYPEID(VN_TYPE_CELL, \ ((cidx) << 2 | (rw) << 1)) +#define VNUM_FROM_CAIDX_RW(caidx, rw) \ + VNUM_FROM_TYPEID(VN_TYPE_ALIAS, \ + ((caidx) << 2 | (rw) << 1)) static int afs_dynrootEnable = 0; +static int afs_dynrootCell = 0; static afs_rwlock_t afs_dynrootDirLock; /* Start of variables protected by afs_dynrootDirLock */ static char *afs_dynrootDir = NULL; static int afs_dynrootDirLen; static int afs_dynrootDirLinkcnt; -static int afs_dynrootCellCount; +static int afs_dynrootDirVersion; static int afs_dynrootVersion = 1; static int afs_dynrootVersionHigh = 1; /* End of variables protected by afs_dynrootDirLock */ @@ -89,6 +94,30 @@ static int afs_dynSymlinkIndex = 0; extern afs_int32 afs_cellindex; extern afs_rwlock_t afs_xvcache; +/* + * Set up a cell for dynroot if it's not there yet. + */ +static int afs_dynrootCellInit() +{ + if (afs_dynrootEnable && !afs_dynrootCell) { + afs_int32 cellHosts[MAXCELLHOSTS]; + struct cell *tc; + int code; + + memset(cellHosts, 0, sizeof(cellHosts)); + code = afs_NewCell(AFS_DYNROOT_CELLNAME, cellHosts, CNoSUID | CNoAFSDB, + NULL, 0, 0, 0); + if (code) + return code; + tc = afs_GetCellByName(AFS_DYNROOT_CELLNAME, READ_LOCK); + if (!tc) + return ENODEV; + afs_dynrootCell = tc->cellNum; + afs_PutCell(tc, READ_LOCK); + } + return 0; +} + /* * Returns non-zero iff fid corresponds to the top of the dynroot volume. */ @@ -97,7 +126,7 @@ afs_IsDynrootFid(struct VenusFid *fid) { return (afs_dynrootEnable && - fid->Cell == AFS_DYNROOT_CELL && + fid->Cell == afs_dynrootCell && fid->Fid.Volume == AFS_DYNROOT_VOLUME && fid->Fid.Vnode == AFS_DYNROOT_VNODE && fid->Fid.Unique == AFS_DYNROOT_UNIQUE); @@ -109,7 +138,7 @@ afs_IsDynrootFid(struct VenusFid *fid) void afs_GetDynrootFid(struct VenusFid *fid) { - fid->Cell = AFS_DYNROOT_CELL; + fid->Cell = afs_dynrootCell; fid->Fid.Volume = AFS_DYNROOT_VOLUME; fid->Fid.Vnode = AFS_DYNROOT_VNODE; fid->Fid.Unique = AFS_DYNROOT_UNIQUE; @@ -213,32 +242,61 @@ afs_dynroot_addDirEnt(dirHeader, curPageP, curChunkP, name, vnode) *curChunkP = curChunk; } +/* + * Invalidate the /afs vnode for dynroot; called when the underlying + * directory has changed and needs to be re-read. + */ +void afs_DynrootInvalidate(void) +{ + afs_int32 retry; + struct vcache *tvc; + struct VenusFid tfid; + + if (!afs_dynrootEnable) + return; + + ObtainWriteLock(&afs_dynrootDirLock, 687); + afs_dynrootVersion++; + afs_dynrootVersionHigh = osi_Time(); + ReleaseWriteLock(&afs_dynrootDirLock); + + afs_GetDynrootFid(&tfid); + do { + retry = 0; + ObtainReadLock(&afs_xvcache); + tvc = afs_FindVCache(&tfid, 0, 0, &retry, 0); + ReleaseReadLock(&afs_xvcache); + } while (retry); + if (tvc) { + tvc->states &= ~(CStatd | CUnique); + osi_dnlc_purgedp(tvc); + afs_PutVCache(tvc); + } +} + /* * Regenerates the dynroot contents from the current list of * cells. Useful when the list of cells has changed due to * an AFSDB lookup, for instance. */ -void -afs_RefreshDynroot() +static void afs_RebuildDynroot(void) { int cellidx, maxcellidx, i; + int aliasidx, maxaliasidx; struct cell *c; + struct cell_alias *ca; int curChunk, curPage; int dirSize, sizeOfCurEntry, dotLen; char *newDir, *dotCell; struct DirHeader *dirHeader; - struct PageHeader *pageHeader; struct DirEntry *dirEntry; - int doFlush = 0; int linkCount = 0; struct afs_dynSymlink *ts; - int newCellCount; + int newVersion; - /* - * Save afs_cellindex here, in case it changes between the - * two loops. - */ - maxcellidx = afs_cellindex; + ObtainReadLock(&afs_dynrootDirLock); + newVersion = afs_dynrootVersion; + ReleaseReadLock(&afs_dynrootDirLock); /* * Compute the amount of space we need for the fake dir @@ -249,9 +307,10 @@ afs_RefreshDynroot() /* Reserve space for "." and ".." */ curChunk += 2; - for (cellidx = 0; cellidx < maxcellidx; cellidx++) { - c = afs_GetCellByIndex(cellidx, READ_LOCK, 0 /* don't refresh */); - if (!c) continue; + for (cellidx = 0; ; cellidx++) { + c = afs_GetCellByIndex(cellidx, READ_LOCK); + if (!c) break; + if (c->cellNum == afs_dynrootCell) continue; sizeOfCurEntry = afs_dir_NameBlobs(c->cellName); if (curChunk + sizeOfCurEntry > EPP) { @@ -274,6 +333,32 @@ afs_RefreshDynroot() afs_osi_Free(dotCell, dotLen); afs_PutCell(c, READ_LOCK); } + maxcellidx = cellidx; + + for (aliasidx = 0; ; aliasidx++) { + ca = afs_GetCellAlias(aliasidx); + if (!ca) break; + + sizeOfCurEntry = afs_dir_NameBlobs(ca->alias); + if (curChunk + sizeOfCurEntry > EPP) { + curPage++; + curChunk = 1; + } + curChunk += sizeOfCurEntry; + + dotCell = afs_osi_Alloc(strlen(ca->alias) + 2); + strcpy(dotCell, "."); + strcat(dotCell, ca->alias); + sizeOfCurEntry = afs_dir_NameBlobs(dotCell); + if (curChunk + sizeOfCurEntry > EPP) { + curPage++; + curChunk = 1; + } + curChunk += sizeOfCurEntry; + + afs_PutCellAlias(ca); + } + maxaliasidx = aliasidx; ObtainReadLock(&afs_dynSymlinkLock); ts = afs_dynSymlinkBase; @@ -317,8 +402,9 @@ afs_RefreshDynroot() linkCount += 2; for (cellidx = 0; cellidx < maxcellidx; cellidx++) { - c = afs_GetCellByIndex(cellidx, READ_LOCK, 0 /* don't refresh */); + c = afs_GetCellByIndex(cellidx, READ_LOCK); if (!c) continue; + if (c->cellNum == afs_dynrootCell) continue; dotLen = strlen(c->cellName) + 2; dotCell = afs_osi_Alloc(dotLen); @@ -329,12 +415,26 @@ afs_RefreshDynroot() afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, dotCell, VNUM_FROM_CIDX_RW(cellidx, 1)); - if (!(c->states & CAlias)) linkCount += 2; + linkCount += 2; afs_osi_Free(dotCell, dotLen); afs_PutCell(c, READ_LOCK); } + for (aliasidx = 0; aliasidx < maxaliasidx; aliasidx++) { + ca = afs_GetCellAlias(aliasidx); + if (!ca) continue; + + dotCell = afs_osi_Alloc(strlen(ca->alias) + 2); + strcpy(dotCell, "."); + strcat(dotCell, ca->alias); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, + ca->alias, VNUM_FROM_CAIDX_RW(aliasidx, 0)); + afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, + dotCell, VNUM_FROM_CAIDX_RW(aliasidx, 1)); + afs_PutCellAlias(ca); + } + ts = afs_dynSymlinkBase; while (ts) { int vnum = VNUM_FROM_TYPEID(VN_TYPE_SYMLINK, ts->index); @@ -343,7 +443,6 @@ afs_RefreshDynroot() ts = ts->next; } - newCellCount = maxcellidx + afs_dynSymlinkIndex; ReleaseReadLock(&afs_dynSymlinkLock); ObtainWriteLock(&afs_dynrootDirLock, 549); @@ -351,51 +450,21 @@ afs_RefreshDynroot() afs_dynrootDir = newDir; afs_dynrootDirLen = dirSize; afs_dynrootDirLinkcnt = linkCount; - if (afs_dynrootCellCount != newCellCount) { - /* - * New cells/symlinks added -- bump data version, invalidate vcache. - */ - afs_dynrootCellCount = newCellCount; - afs_dynrootVersion++; - afs_dynrootVersionHigh = osi_Time(); - doFlush = 1; - } + afs_dynrootVersion = newVersion; ReleaseWriteLock(&afs_dynrootDirLock); - - if (doFlush) { - afs_int32 retry; - struct vcache *tvc; - struct VenusFid tfid; - - afs_GetDynrootFid(&tfid); - do { - retry = 0; - ObtainReadLock(&afs_xvcache); - tvc = afs_FindVCache(&tfid, 0, 0, &retry, 0); - ReleaseReadLock(&afs_xvcache); - } while (retry); - if (tvc) { - tvc->states &= ~(CStatd | CUnique); - osi_dnlc_purgedp(tvc); - afs_PutVCache(tvc); - } - } } /* * Returns a pointer to the base of the dynroot directory in memory, * length thereof, and a FetchStatus. */ -void -afs_GetDynroot(dynrootDir, dynrootLen, status) - char **dynrootDir; - int *dynrootLen; - struct AFSFetchStatus *status; +void afs_GetDynroot(char **dynrootDir, int *dynrootLen, + struct AFSFetchStatus *status) { ObtainReadLock(&afs_dynrootDirLock); - if (!afs_dynrootDir) { + if (!afs_dynrootDir || afs_dynrootDirVersion != afs_dynrootVersion) { ReleaseReadLock(&afs_dynrootDirLock); - afs_RefreshDynroot(); + afs_RebuildDynroot(); ObtainReadLock(&afs_dynrootDirLock); } @@ -447,10 +516,11 @@ afs_DynrootNewVnode(avc, status) /* * Check if this is an entry under /afs, e.g. /afs/cellname. */ - if (avc->fid.Cell == AFS_DYNROOT_CELL && + if (avc->fid.Cell == afs_dynrootCell && avc->fid.Fid.Volume == AFS_DYNROOT_VOLUME) { struct cell *c; + struct cell_alias *ca; int namelen, linklen, cellidx, rw; memset(status, 0, sizeof(struct AFSFetchStatus)); @@ -487,7 +557,8 @@ afs_DynrootNewVnode(avc, status) return ts ? 1 : 0; } - if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_CELL) { + if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_CELL && + VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) != VN_TYPE_ALIAS) { afs_warn("dynroot vnode inconsistency, unknown VNTYPE %d\n", VNUM_TO_VNTYPE(avc->fid.Fid.Vnode)); return 0; @@ -496,26 +567,26 @@ afs_DynrootNewVnode(avc, status) cellidx = VNUM_TO_CIDX(avc->fid.Fid.Vnode); rw = VNUM_TO_RW(avc->fid.Fid.Vnode); - c = afs_GetCellByIndex(cellidx, READ_LOCK, 1 /* refresh */); - if (!c) { - afs_warn("dynroot vnode inconsistency, can't find cell %d\n", - cellidx); - return 0; - } + if (VNUM_TO_VNTYPE(avc->fid.Fid.Vnode) == VN_TYPE_ALIAS) { + char *realName; + + ca = afs_GetCellAlias(cellidx); + if (!ca) { + afs_warn("dynroot vnode inconsistency, can't find alias %d\n", + cellidx); + return 0; + } - if (c->states & CAlias) { /* * linkData needs to contain the name of the cell * we're aliasing for. */ - char *realName = c->realName; - + realName = ca->cell; if (!realName) { afs_warn("dynroot: alias %s missing real cell name\n", - c->cellName); + ca->alias); + avc->linkData = afs_strdup("unknown"); linklen = 7; - avc->linkData = afs_osi_Alloc(linklen + 1); - strcpy(avc->linkData, "unknown"); } else { int namelen = strlen(realName); linklen = rw + namelen; @@ -525,7 +596,15 @@ afs_DynrootNewVnode(avc, status) } status->UnixModeBits = 0755; + afs_PutCellAlias(ca); } else { + c = afs_GetCellByIndex(cellidx, READ_LOCK); + if (!c) { + afs_warn("dynroot vnode inconsistency, can't find cell %d\n", + cellidx); + return 0; + } + /* * linkData needs to contain "#cell:root.cell" or "%cell:root.cell" */ @@ -537,10 +616,10 @@ afs_DynrootNewVnode(avc, status) strcat(avc->linkData, ":root.cell"); status->UnixModeBits = 0644; + afs_PutCell(c, READ_LOCK); } status->Length = linklen; - afs_PutCell(c, READ_LOCK); return 1; } @@ -555,7 +634,7 @@ afs_SetDynrootEnable(enable) int enable; { afs_dynrootEnable = enable; - return 0; + return afs_dynrootCellInit(); } /* @@ -571,14 +650,11 @@ afs_GetDynrootEnable() * Remove a temporary symlink entry from /afs. */ int -afs_DynrootVOPRemove(avc, acred, aname) - struct vcache *avc; - struct AFS_UCRED *acred; - char *aname; +afs_DynrootVOPRemove(struct vcache *avc, struct AFS_UCRED *acred, + char *aname) { struct afs_dynSymlink **tpps; struct afs_dynSymlink *tps; - struct cell *c; int found = 0; if (acred->cr_uid) @@ -601,18 +677,14 @@ afs_DynrootVOPRemove(avc, acred, aname) } ReleaseWriteLock(&afs_dynSymlinkLock); if (found) { - afs_RefreshDynroot(); + afs_DynrootInvalidate(); return 0; } - /* Check if this is an actual cell? */ - c = afs_GetCellByName2(aname, READ_LOCK, 0 /* no AFSDB */); - if (c) { - afs_PutCell(c, READ_LOCK); + if (afs_CellOrAliasExists(aname)) return EROFS; - } else { + else return ENOENT; - } } /* @@ -626,17 +698,12 @@ afs_DynrootVOPSymlink(avc, acred, aname, atargetName) char *atargetName; { struct afs_dynSymlink *tps; - struct cell *c; if (acred->cr_uid) return EPERM; - /* Check if it's already a cell */ - c = afs_GetCellByName2(aname, READ_LOCK, 0 /* no AFSDB */); - if (c) { - afs_PutCell(c, READ_LOCK); - return EEXIST; - } + if (afs_CellOrAliasExists(aname)) + return EEXIST; /* Check if it's already a symlink */ ObtainWriteLock(&afs_dynSymlinkLock, 91); @@ -660,6 +727,6 @@ afs_DynrootVOPSymlink(avc, acred, aname, atargetName) afs_dynSymlinkBase = tps; ReleaseWriteLock(&afs_dynSymlinkLock); - afs_RefreshDynroot(); + afs_DynrootInvalidate(); return 0; } diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index e5eebf188..aa4a3458e 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -16,7 +16,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_init.c,v 1.1.1.9 2002/12/11 02:35:59 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_init.c,v 1.1.1.10 2003/04/13 19:02:36 hartmans Exp $"); #include "../afs/stds.h" #include "../afs/sysincludes.h" /* Standard vendor system headers */ @@ -312,36 +312,50 @@ afs_ComputeCacheParms() * WARNING: Data will be written to this file over time by AFS. */ -afs_InitVolumeInfo(afile) - register char *afile; - -{ /*afs_InitVolumeInfo*/ - +static int LookupInodeByPath(char *filename, ino_t *inode) +{ afs_int32 code; - struct osi_file *tfile; - struct vnode *filevp; - struct fcache fce; - - AFS_STATCNT(afs_InitVolumeInfo); + #ifdef AFS_LINUX22_ENV - { - struct dentry *dp; - code = gop_lookupname(afile, AFS_UIOSYS, 0, (struct vnode **) 0, &dp); - if (code) return ENOENT; - fce.inode = volumeInode = dp->d_inode->i_ino; - dput(dp); - } + struct dentry *dp; + code = gop_lookupname(filename, AFS_UIOSYS, 0, NULL, &dp); + if (code) return code; + *inode = dp->d_inode->i_ino; + dput(dp); #else - code = gop_lookupname(afile, AFS_UIOSYS, 0, (struct vnode **) 0, &filevp); - if (code) return ENOENT; - fce.inode = volumeInode = afs_vnodeToInumber(filevp); + struct vnode *filevp; + code = gop_lookupname(filename, AFS_UIOSYS, 0, NULL, &filevp); + if (code) return code; + *inode = afs_vnodeToInumber(filevp); #ifdef AFS_DEC_ENV grele(filevp); #else AFS_RELE((struct vnode *)filevp); #endif #endif /* AFS_LINUX22_ENV */ - tfile = afs_CFileOpen(fce.inode); + + return 0; + } + +int afs_InitCellInfo(char *afile) +{ + ino_t inode; + int code; + + code = LookupInodeByPath(afile, &inode); + return afs_cellname_init(inode, code); +} + +int afs_InitVolumeInfo(char *afile) +{ + int code; + struct osi_file *tfile; + struct vnode *filevp; + + AFS_STATCNT(afs_InitVolumeInfo); + code = LookupInodeByPath(afile, &volumeInode); + if (code) return code; + tfile = afs_CFileOpen(volumeInode); afs_CFileTruncate(tfile, 0); afs_CFileClose(tfile); return 0; @@ -521,7 +535,6 @@ afs_ResourceInit(preallocs) AFS_STATCNT(afs_ResourceInit); RWLOCK_INIT(&afs_xuser, "afs_xuser"); RWLOCK_INIT(&afs_xvolume, "afs_xvolume"); - RWLOCK_INIT(&afs_xcell, "afs_xcell"); RWLOCK_INIT(&afs_xserver, "afs_xserver"); RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr"); RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock"); @@ -533,6 +546,7 @@ afs_ResourceInit(preallocs) LOCK_INIT(&osi_flplock, "osi_flplock"); RWLOCK_INIT(&afs_xconn, "afs_xconn"); + afs_CellInit(); afs_InitCBQueue(1); /* initialize callback queues */ if (afs_resourceinit_flag == 0) { @@ -544,7 +558,6 @@ afs_ResourceInit(preallocs) afs_sysname = afs_sysnamelist[0]; strcpy(afs_sysname, SYS_NAME); afs_sysnamecount = 1; - QInit(&CellLRU); #if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) { extern afs_int32 afs_preallocs; @@ -750,19 +763,6 @@ void shutdown_AFS() AFS_STATCNT(shutdown_AFS); if (afs_cold_shutdown) { afs_resourceinit_flag = 0; - /* - * Free Cells table allocations - */ - { - struct cell *tc; - register struct afs_q *cq, *tq; - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tc = QTOC(cq); tq = QNext(cq); - if (tc->cellName) - afs_osi_Free(tc->cellName, strlen(tc->cellName)+1); - afs_osi_Free(tc, sizeof(struct cell)); - } - } /* * Free Volumes table allocations */ @@ -859,19 +859,16 @@ void shutdown_AFS() afs_sysname = 0; afs_sysnamecount = 0; afs_marinerHost = 0; - QInit(&CellLRU); afs_setTimeHost = (struct server *)0; afs_volCounter = 1; afs_waitForever = afs_waitForeverCount = 0; - afs_cellindex = 0; - afs_nextCellNum = 0x100; afs_FVIndex = -1; afs_server = (struct rx_service *)0; RWLOCK_INIT(&afs_xconn, "afs_xconn"); memset((char *)&afs_rootFid, 0, sizeof(struct VenusFid)); RWLOCK_INIT(&afs_xuser, "afs_xuser"); RWLOCK_INIT(&afs_xvolume, "afs_xvolume"), RWLOCK_INIT(&afs_xcell, "afs_xcell"); - RWLOCK_INIT(&afs_xserver, "afs_xserver"), LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock"); + shutdown_cell(); } } /*shutdown_AFS*/ diff --git a/src/afs/afs_nfsdisp.c b/src/afs/afs_nfsdisp.c index c0c5c3706..5dcbee60c 100644 --- a/src/afs/afs_nfsdisp.c +++ b/src/afs/afs_nfsdisp.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_nfsdisp.c,v 1.1.1.5 2002/12/11 02:36:00 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_nfsdisp.c,v 1.1.1.6 2003/04/13 19:02:36 hartmans Exp $"); /* Ugly Ugly Ugly but precludes conflicting XDR macros; We want kernel xdr */ #define __XDR_INCLUDE__ @@ -677,7 +677,7 @@ nfs3_to_afs_call(int which, caddr_t *args, nfs_fh3 **fhpp, nfs_fh3 **fh2pp) case NFSPROC3_LOOKUP: { LOOKUP3args *arg = (LOOKUP3args *)args; -#ifdef AFS_SUN57_ENV +#ifdef AFS_SUN58_ENV fhp1 = (nfs_fh3 *) &arg->what.dirp; #else fhp1 = (nfs_fh3 *) &arg->what.dir; diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index f8babf1b2..f96ad25fd 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi.c,v 1.1.1.12 2002/09/26 18:57:53 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi.c,v 1.1.1.13 2003/04/13 19:02:36 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -289,9 +289,6 @@ void afs_osi_MaskSignals(){ /* unmask signals in rxk listener */ void afs_osi_UnmaskRxkSignals(){ -#ifdef AFS_LINUX22_ENV - osi_linux_unmask(); -#endif } /* register rxk listener proc info */ @@ -494,6 +491,10 @@ void afs_osi_Free(void *x, size_t asize) #endif } +void afs_osi_FreeStr(char *x) +{ + afs_osi_Free(x, strlen(x) + 1); +} /* ? is it moderately likely that there are dirty VM pages associated with * this vnode? @@ -807,11 +808,19 @@ void afs_osi_TraverseProcTable() #ifdef EXPORTED_TASKLIST_LOCK read_lock(&tasklist_lock); #endif +#ifdef DEFINED_FOR_EACH_PROCESS + for_each_process(p) if (p->pid) { + if (p->state & TASK_ZOMBIE) + continue; + afs_GCPAGs_perproc_func(p); + } +#else for_each_task(p) if (p->pid) { if (p->state & TASK_ZOMBIE) continue; afs_GCPAGs_perproc_func(p); } +#endif #ifdef EXPORTED_TASKLIST_LOCK read_unlock(&tasklist_lock); #endif diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c index dd4ce144a..ed80eef36 100644 --- a/src/afs/afs_osi_pag.c +++ b/src/afs/afs_osi_pag.c @@ -22,7 +22,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi_pag.c,v 1.1.1.6 2001/07/14 22:19:25 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi_pag.c,v 1.1.1.7 2003/04/13 19:02:37 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -441,7 +441,7 @@ afs_int32 PagInCred(const struct AFS_UCRED *cred) return NOPAG; } #else -#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DUX40_ENV) || defined(AFS_LINUX_ENV) || defined(AFS_FBSD_ENV) +#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DUX40_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV) if (cred->cr_ngroups < 2) return NOPAG; #endif #endif diff --git a/src/afs/afs_osi_vget.c b/src/afs/afs_osi_vget.c index 766a5bab3..d099028fa 100644 --- a/src/afs/afs_osi_vget.c +++ b/src/afs/afs_osi_vget.c @@ -14,7 +14,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi_vget.c,v 1.1.1.6 2002/01/22 19:47:59 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi_vget.c,v 1.1.1.7 2003/04/13 19:02:37 hartmans Exp $"); #include "../afs/sysincludes.h" /* Standard vendor system headers */ #include "../afs/afsincludes.h" /* Afs-based standard headers */ @@ -22,8 +22,6 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_osi_vget.c,v 1.1.1.6 2002/01/22 -extern int afs_NFSRootOnly; -int afs_rootCellIndex = 0; #if !defined(AFS_LINUX20_ENV) /* This is the common part of the vget VFS call. */ int afs_osi_vget(struct vcache **avcpp, struct fid *afidp, @@ -31,7 +29,6 @@ int afs_osi_vget(struct vcache **avcpp, struct fid *afidp, { struct VenusFid vfid; struct SmallFid Sfid; - extern struct cell *afs_GetCellByIndex(); register struct cell *tcell; struct vrequest treq; register afs_int32 code = 0, cellindex; @@ -41,31 +38,19 @@ int afs_osi_vget(struct vcache **avcpp, struct fid *afidp, #ifdef AFS_OSF_ENV Sfid.Vnode = afidp->fid_reserved; #endif - if (afs_NFSRootOnly && - Sfid.Volume == afs_rootFid.Fid.Volume && - Sfid.Vnode == afs_rootFid.Fid.Vnode && - (Sfid.CellAndUnique & 0xffffff) == - (afs_rootFid.Fid.Unique & 0xffffff) && - ((Sfid.CellAndUnique >> 24) & 0xff) == afs_rootCellIndex) { - vfid = afs_rootFid; - } - else { - /* Need to extract fid from SmallFid. Will need a wild card option for - * finding the right vcache entry. - */ - struct cell *tcell; - cellindex = (Sfid.CellAndUnique >> 24) & 0xff; - tcell = afs_GetCellByIndex(cellindex, READ_LOCK, 0 /* don't refresh */); - if (!tcell) { - return ENOENT; - } - vfid.Cell = tcell->cell; - afs_PutCell(tcell, WRITE_LOCK); - vfid.Fid.Volume = Sfid.Volume; - vfid.Fid.Vnode = Sfid.Vnode; - vfid.Fid.Unique = Sfid.CellAndUnique & 0xffffff; - } + /* Need to extract fid from SmallFid. Will need a wild card option for + * finding the right vcache entry. + */ + cellindex = (Sfid.CellAndUnique >> 24) & 0xff; + tcell = afs_GetCellByIndex(cellindex, READ_LOCK); + if (!tcell) + return ENOENT; + vfid.Cell = tcell->cellNum; + afs_PutCell(tcell, WRITE_LOCK); + vfid.Fid.Volume = Sfid.Volume; + vfid.Fid.Vnode = Sfid.Vnode; + vfid.Fid.Unique = Sfid.CellAndUnique & 0xffffff; /* First attempt to find in cache using wildcard. If that fails, * try the usual route to try to get the vcache from the server. diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 2bbfc9eb8..a10062325 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -18,9 +18,32 @@ extern int afs_Analyze(struct conn *aconn, afs_int32 acode, struct VenusFid *afi struct cell *cellp); /* afs_cell.c */ -extern struct cell *afs_GetRealCellByIndex(register afs_int32 cellindex, - afs_int32 locktype, - afs_int32 refresh); +extern afs_rwlock_t afs_xcell; +extern void afs_CellInit(void); +extern void shutdown_cell(void); +extern int afs_cellname_init(ino_t inode, int lookupcode); +extern int afs_cellname_write(); +extern afs_int32 afs_NewCell(char *acellName, afs_int32 *acellHosts, + int aflags, char *linkedcname, u_short fsport, + u_short vlport, int timeout); +extern afs_int32 afs_SetPrimaryCell(char *acellName); +extern struct cell *afs_GetCell(afs_int32 acell, afs_int32 locktype); +extern struct cell *afs_GetCellStale(afs_int32 acell, afs_int32 locktype); +extern struct cell *afs_GetCellByIndex(afs_int32 cellidx, afs_int32 locktype); +extern struct cell *afs_GetCellByName(char *acellName, afs_int32 locktype); +extern struct cell *afs_GetPrimaryCell(afs_int32 locktype); +extern int afs_IsPrimaryCellNum(afs_int32 cellnum); +extern int afs_IsPrimaryCell(struct cell *cell); +extern void *afs_TraverseCells(void *(*cb)(struct cell *, void *), void *arg); +extern int afs_CellOrAliasExists(char *aname); +extern int afs_CellNumValid(afs_int32 cellnum); +extern afs_int32 afs_NewCellAlias(char *alias, char *cell); +extern struct cell_alias *afs_GetCellAlias(int index); +extern int afs_AFSDBHandler(char *acellName, int acellNameLen, + afs_int32 *kernelMsg); +extern void afs_LookupAFSDB(char *acellName); +extern void afs_StopAFSDB(void); +extern void afs_RemoveCellEntry(struct server *srvp); /* afs_conn.c */ extern struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, @@ -28,6 +51,7 @@ extern struct conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, int force_if_down, afs_int32 create, afs_int32 locktype); /* afs_dcache.c */ +extern int cacheDiskType; extern void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags); @@ -84,7 +108,9 @@ extern void afs_GCPAGs_perproc_func(AFS_PROC *pproc); /* afs_util.c */ extern char *afs_cv2string(char *ttp, afs_uint32 aval); +extern int afs_strcasecmp(char *s1, char *s2); extern char *afs_strchr(char *s, int c); +extern char *afs_strdup(char *s); extern void print_internet_address(char *preamble, struct srvAddr *sa, char *postamble, int flag); extern afs_int32 afs_data_pointer_to_int32(const void *p); diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 65313c7c1..bab5973aa 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -32,7 +32,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_server.c,v 1.1.1.13 2002/09/26 18:57:56 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_server.c,v 1.1.1.14 2003/04/13 19:02:38 hartmans Exp $"); #include "../afs/stds.h" #include "../afs/sysincludes.h" /* Standard vendor system headers */ @@ -90,6 +90,26 @@ int afs_totalSrvAddrs = 0; +static struct afs_stats_SrvUpDownInfo * +GetUpDownStats(struct server *srv) +{ + struct afs_stats_SrvUpDownInfo *upDownP; + u_short fsport = AFS_FSPORT; + + if (srv->cell) + fsport = srv->cell->fsport; + + if (srv->addr->sa_portal == fsport) + upDownP = afs_stats_cmperf.fs_UpDown; + else + upDownP = afs_stats_cmperf.vl_UpDown; + + if (srv->cell && afs_IsPrimaryCell(srv->cell)) + return &upDownP[AFS_STATS_UPDOWN_IDX_SAME_CELL]; + else + return &upDownP[AFS_STATS_UPDOWN_IDX_DIFF_CELL]; +} + /*------------------------------------------------------------------------ * afs_MarkServerUpOrDown @@ -165,16 +185,7 @@ void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown) currTimeP = &currTime; osi_GetuTime(currTimeP); - if (sa->sa_portal == AFS_FSPORT) { - upDownP = (a_serverP->cell->cell == 1) ? - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*File Server record*/ - else { - upDownP = (a_serverP->cell->cell == 1) ? - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*VL Server record*/ + upDownP = GetUpDownStats(a_serverP); if (a_isDown) { /* @@ -295,7 +306,7 @@ static void CheckVLServer(sa, areq) return; /* can't do much */ tc = afs_ConnByHost(aserver, aserver->cell->vlport, - aserver->cell->cell, areq, 1, SHARED_LOCK); + aserver->cell->cellNum, areq, 1, SHARED_LOCK); if (!tc) return; rx_SetConnDeadTime(tc->id, 3); @@ -429,17 +440,7 @@ void afs_CountServers() * in the appropriate places. */ srvRecordAge = currTime.tv_sec - currSrvP->activationTime; - if (currSrvP->addr->sa_portal == AFS_FSPORT) { - upDownP = (currSrvP->cell->cell == 1) ? - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]): - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*File Server record*/ - else { - upDownP = (currSrvP->cell->cell == 1) ? - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]): - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*VL Server record*/ - + upDownP = GetUpDownStats(currSrvP); upDownP->sumOfRecordAges += srvRecordAge; if ((upDownP->ageOfYoungestRecord == 0) || (srvRecordAge < upDownP->ageOfYoungestRecord)) @@ -568,8 +569,8 @@ void afs_CheckServers(adown, acellp) continue; /* have just been added by setsprefs */ /* get a connection, even if host is down; bumps conn ref count */ - tu = afs_GetUser(treq.uid, ts->cell->cell, SHARED_LOCK); - tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cell, tu, + tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK); + tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu, 1/*force*/, 1/*create*/, SHARED_LOCK); afs_PutUser(tu, SHARED_LOCK); if (!tc) continue; @@ -602,12 +603,9 @@ void afs_CheckServers(adown, acellp) */ if (code == 0 && start == end && afs_setTime != 0 && (tc->srvr->server == afs_setTimeHost || - /* - * Sync only to a server in the local cell: cell(id)==1 - * or CPrimary. - */ + /* Sync only to a server in the local cell */ (afs_setTimeHost == (struct server *)0 && - (ts->cell->cell == 1 || (ts->cell->states&CPrimary))))) { + afs_IsPrimaryCell(ts->cell)))) { char msgbuf[90]; /* strlen("afs: setting clock...") + slop */ /* set the time */ @@ -1605,16 +1603,8 @@ struct server *afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, /* With the introduction of this new record, we need to adjust the * proper individual & global server up/down info. */ - if (aport == fsport) { /* File Server record */ - upDownP = (acell == 1) ? - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } else { /* VL Server record */ - upDownP = (acell == 1) ? - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } - (upDownP->numTtlRecords) += srvcount; + upDownP = GetUpDownStats(newts); + upDownP->numTtlRecords += srvcount; afs_stats_cmperf.srvRecords += srvcount; if (afs_stats_cmperf.srvRecords > afs_stats_cmperf.srvRecordsHWM) afs_stats_cmperf.srvRecordsHWM = afs_stats_cmperf.srvRecords; @@ -1642,21 +1632,12 @@ void afs_ActivateServer(sap) currTimeP = &currTime; osi_GetuTime(currTimeP); aserver->activationTime = currTime.tv_sec; - if (sap->sa_portal == AFS_FSPORT) { - upDownP = (aserver->cell->cell == 1) ? - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.fs_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*File Server record*/ - else { - upDownP = (aserver->cell->cell == 1) ? - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_SAME_CELL]) : - &(afs_stats_cmperf.vl_UpDown[AFS_STATS_UPDOWN_IDX_DIFF_CELL]); - } /*VL Server record*/ - if (aserver->flags & SRVR_ISDOWN) - (upDownP->numDownRecords)++; - else { - (upDownP->numUpRecords)++; - (upDownP->numRecordsNeverDown)++; + upDownP = GetUpDownStats(aserver); + if (aserver->flags & SRVR_ISDOWN) { + upDownP->numDownRecords++; + } else { + upDownP->numUpRecords++; + upDownP->numRecordsNeverDown++; } } } diff --git a/src/afs/afs_stats.h b/src/afs/afs_stats.h index d595c0c20..39dfcd0d0 100644 --- a/src/afs/afs_stats.h +++ b/src/afs/afs_stats.h @@ -637,6 +637,8 @@ struct afs_CMCallStats { afs_int32 C_SRXAFSCB_GetLocalCell; /* afs_callback.c*/ afs_int32 C_afs_MarshallCacheConfig; /* afs_callback.c*/ afs_int32 C_SRXAFSCB_GetCacheConfig; /* afs_callback.c*/ + afs_int32 C_SRXAFSCB_GetCE64; /* afs_callback.c*/ + afs_int32 C_SRXAFSCB_GetCellByNum; /* afs_callback.c*/ }; struct afs_CMMeanStats { diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index c3d807c0c..84b314509 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -15,7 +15,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_util.c,v 1.1.1.8 2002/12/11 02:36:03 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_util.c,v 1.1.1.9 2003/04/13 19:02:39 hartmans Exp $"); #include "../afs/stds.h" #include "../afs/sysincludes.h" /* Standard vendor system headers */ @@ -81,6 +81,35 @@ char *afs_strchr(char *s, int c) return NULL; } +int afs_strcasecmp(char *s1, char *s2) +{ + while (*s1 && *s2) { + char c1, c2; + + c1 = *s1++; + c2 = *s2++; + if (c1 >= 'A' && c1 <= 'Z') c1 += 0x20; + if (c2 >= 'A' && c2 <= 'Z') c2 += 0x20; + if (c1 != c2) + return c1-c2; + } + + return *s1 - *s2; +} + +char *afs_strdup(char *s) +{ + char *n; + int cc; + + cc = strlen(s) + 1; + n = (char *) afs_osi_Alloc(cc); + if (n) + memcpy(n, s, cc); + + return n; +} + void print_internet_address(char *preamble, struct srvAddr *sa, char *postamble, int flag) { diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index e1c270f78..48374871d 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -38,7 +38,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_vcache.c,v 1.1.1.15 2002/12/11 02:36:03 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_vcache.c,v 1.1.1.16 2003/04/13 19:02:39 hartmans Exp $"); #include "../afs/sysincludes.h" /*Standard vendor system headers*/ #include "../afs/afsincludes.h" /*AFS-based standard headers*/ @@ -374,7 +374,7 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) callBacks[0].CallBackType = CB_EXCLUSIVE; for (safety3 = 0; safety3 < MAXHOSTS*2; safety3++) { tc = afs_ConnByHost(tsp, tsp->cell->fsport, - tsp->cell->cell, &treq, 0, + tsp->cell->cellNum, &treq, 0, SHARED_LOCK); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); @@ -632,9 +632,7 @@ restart: * entries locked. */ -afs_RemoveVCB(afid) - register struct VenusFid *afid; - +afs_RemoveVCB(struct VenusFid *afid) { /*afs_RemoveVCB*/ register int i, j; @@ -648,7 +646,7 @@ afs_RemoveVCB(afid) for(i=0;inext) { /* if cell is known, and is wrong, then skip this server */ - if (tsp->cell && tsp->cell->cell != afid->Cell) continue; + if (tsp->cell && tsp->cell->cellNum != afid->Cell) continue; /* * Otherwise, iterate through file IDs we're sending to the @@ -2530,7 +2528,7 @@ struct vcache *afs_FindVCache(struct VenusFid *afid, afs_int32 lockit, if (flag & DO_STATS) { if (tvc) afs_stats_cmperf.vcacheHits++; else afs_stats_cmperf.vcacheMisses++; - if (afid->Cell == LOCALCELL) + if (afs_IsPrimaryCellNum(afid->Cell)) afs_stats_cmperf.vlocalAccesses++; else afs_stats_cmperf.vremoteAccesses++; @@ -2672,7 +2670,7 @@ afs_int32 afs_NFSFindVCache(avcp, afid, lockit) if (tvc) afs_stats_cmperf.vcacheHits++; else afs_stats_cmperf.vcacheMisses++; - if (afid->Cell == LOCALCELL) + if (afs_IsPrimaryCellNum(afid->Cell)) afs_stats_cmperf.vlocalAccesses++; else afs_stats_cmperf.vremoteAccesses++; diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index dbf9ca5bb..6bc8d910a 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -18,7 +18,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_volume.c,v 1.1.1.11 2002/09/26 18:57:58 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afs/afs_volume.c,v 1.1.1.12 2003/04/13 19:02:39 hartmans Exp $"); #include "../afs/stds.h" #include "../afs/sysincludes.h" /* Standard vendor system headers */ @@ -112,7 +112,7 @@ struct volume *afs_UFSGetVolSlot() { register struct volume *tv, **lv; - register char *tfile; + struct osi_file *tfile; register afs_int32 i, code; afs_int32 bestTime; struct volume *bestVp, **bestLp; @@ -461,7 +461,7 @@ static struct volume *afs_SetupVolume(volid, aname, ve, tcell, agood, type, areq ObtainWriteLock(&afs_xvolume,108); i = VHash(volid); for (tv = afs_volumes[i]; tv; tv=tv->next) { - if (tv->volume == volid && tv->cell == tcell->cell) { + if (tv->volume == volid && tv->cell == tcell->cellNum) { break; } } @@ -470,14 +470,14 @@ static struct volume *afs_SetupVolume(volid, aname, ve, tcell, agood, type, areq tv = afs_GetVolSlot(); memset((char *)tv, 0, sizeof(struct volume)); - tv->cell = tcell->cell; + tv->cell = tcell->cellNum; RWLOCK_INIT(&tv->lock, "volume lock"); tv->next = afs_volumes[i]; /* thread into list */ afs_volumes[i] = tv; tv->volume = volid; for (j=fvTable[FVHash(tv->cell,volid)]; j!=0; j=tf->next) { if (afs_FVIndex != j) { - char *tfile; + struct osi_file *tfile; tfile = osi_UFSOpen(volumeInode); err = afs_osi_Read(tfile, sizeof(struct fvolume) * j, &staticFVolume, sizeof(struct fvolume)); if (err != sizeof(struct fvolume)) @@ -506,12 +506,12 @@ static struct volume *afs_SetupVolume(volid, aname, ve, tcell, agood, type, areq ReleaseWriteLock(&afs_xvolume); ObtainWriteLock(&tv->lock,111); if (type == 2) { - InstallUVolumeEntry(tv, uve, tcell->cell, tcell, areq); + InstallUVolumeEntry(tv, uve, tcell->cellNum, tcell, areq); } else if (type == 1) - InstallNVolumeEntry(tv, nve, tcell->cell); + InstallNVolumeEntry(tv, nve, tcell->cellNum); else - InstallVolumeEntry(tv, ove, tcell->cell); + InstallVolumeEntry(tv, ove, tcell->cellNum); if (agood) { if (!tv->name) { tv->name = afs_osi_Alloc(strlen(aname) + 1); @@ -573,7 +573,7 @@ static struct volume *afs_NewDynrootVolume(struct VenusFid *fid) { tve.volumeId[ROVOL] = fid->Fid.Volume; tve.flags = VLF_ROEXISTS; - tv = afs_SetupVolume(0, bp, &tve, tcell, 0, 0, 0); + tv = afs_SetupVolume(0, bp, (char *) &tve, tcell, 0, 0, 0); afs_PutCell(tcell, READ_LOCK); return tv; } @@ -614,7 +614,7 @@ static struct volume *afs_NewVolumeByName(char *aname, afs_int32 acell, int agoo afs_InitReq(&treq, &afs_osi_cred); /* *must* be unauth for vldb */ do { tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cell, &treq, SHARED_LOCK); + tcell->cellNum, &treq, SHARED_LOCK); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -947,7 +947,7 @@ void InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, memset((char *)&addrs, 0, sizeof(addrs)); do { tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cell, areq, SHARED_LOCK); + tcell->cellNum, areq, SHARED_LOCK); if (tconn) { #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); diff --git a/src/afsd/Makefile.in b/src/afsd/Makefile.in index 67bf2fee0..9d4ab4542 100644 --- a/src/afsd/Makefile.in +++ b/src/afsd/Makefile.in @@ -99,13 +99,13 @@ dest: ${DEST}/root.client/usr/vice/etc/afsd ${DEST}/etc/vsys esac;; \ sun4_52 | sun4_53 | sun4c_52 | sun4c_53 | sun4m_52 | sun4m_53 | sun4m_54 | sun4_54 | sun4c_54 | sunx86_54) \ ${INSTALL} -f afs.rc.solaris ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\ - sun4x_57 ) \ + sun*_57 ) \ ${INSTALL} -f afs.rc.solaris.2.7 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\ - sun4x_58 ) \ + sun*_58 ) \ ${INSTALL} -f afs.rc.solaris.2.8 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\ - sun4x_59 ) \ + sun*_59 ) \ ${INSTALL} -f afs.rc.solaris.2.9 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\ - sun4x_5? ) \ + sun*_5? ) \ ${INSTALL} -f afs.rc.solaris.2_5 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\ alpha_osf* ) \ ${INSTALL} -f afs.rc.alpha ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\ diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index b14446b7d..2abe4a899 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -55,7 +55,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/afsd/afsd.c,v 1.1.1.16 2002/12/11 02:41:43 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/afsd/afsd.c,v 1.1.1.17 2003/04/13 19:05:54 hartmans Exp $"); #define VFS 1 @@ -170,6 +170,7 @@ void set_staticaddrs(void); #define AFSLOGFILE "AFSLog" #define DCACHEFILE "CacheItems" #define VOLINFOFILE "VolumeItems" +#define CELLINFOFILE "CellItems" #define MAXIPADDRS 1024 @@ -211,6 +212,7 @@ char cacheBaseDir[1024]; /*Where the workstation AFS cache lives*/ char confDir[1024]; /*Where the workstation AFS configuration lives*/ char fullpn_DCacheFile[1024]; /*Full pathname of DCACHEFILE*/ char fullpn_VolInfoFile[1024]; /*Full pathname of VOLINFOFILE*/ +char fullpn_CellInfoFile[1024]; /*Full pathanem of CELLINFOFILE*/ char fullpn_AFSLogFile[1024]; /*Full pathname of AFSLOGFILE*/ char fullpn_CacheInfo[1024]; /*Full pathname of CACHEINFO*/ char fullpn_VFile[1024]; /*Full pathname of data cache files*/ @@ -224,7 +226,6 @@ char cacheMountDir[1024]; /*Mount directory for AFS*/ char rootVolume[64] = "root.afs"; /*AFS root volume name*/ afs_int32 cacheSetTime = 1; /*Keep checking time to avoid drift?*/ afs_int32 isHomeCell; /*Is current cell info for the home cell?*/ -afs_int32 lookingForHomeCell; /*Are we still looking for the home cell?*/ int createAndTrunc = O_CREAT | O_TRUNC; /*Create & truncate on open*/ int ownerRWmode = 0600; /*Read/write OK by owner*/ static int filesSet = 0; /*True if number of files explicitly set*/ @@ -270,10 +271,11 @@ int *dir_for_V = NULL; /* Array: dir of each cache file. */ AFSD_INO_T *inode_for_V; /* Array of inodes for desired * cache files */ -int missing_DCacheFile = 1; /*Is the DCACHEFILE missing?*/ -int missing_VolInfoFile = 1; /*Is the VOLINFOFILE missing?*/ -int afsd_rmtsys = 0; /* Default: don't support rmtsys */ -struct afs_cacheParams cparams; /* params passed to cache manager */ +int missing_DCacheFile = 1; /*Is the DCACHEFILE missing?*/ +int missing_VolInfoFile = 1; /*Is the VOLINFOFILE missing?*/ +int missing_CellInfoFile = 1; /*Is the CELLINFOFILE missing?*/ +int afsd_rmtsys = 0; /* Default: don't support rmtsys */ +struct afs_cacheParams cparams; /* params passed to cache manager */ static int HandleMTab(); @@ -626,6 +628,16 @@ int CreateCacheFile(fname, statp) return(0); } +static void CreateFileIfMissing(char *fullpn, int missing) +{ + if (missing) { + if (afsd_verbose) + printf("CreateFileIfMissing: Creating '%s'\n", fullpn); + if (CreateCacheFile(fullpn, NULL)) + printf("CreateFileIfMissing: Can't create '%s'\n", fullpn); + } +} + /*----------------------------------------------------------------------------- * SweepAFSCache * @@ -802,6 +814,12 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) */ missing_VolInfoFile = 0; } + else if (dirNum < 0 && strcmp(currp->d_name, CELLINFOFILE) == 0) { + /* + * Found the file holding the cell info. + */ + missing_CellInfoFile = 0; + } else if ((strcmp(currp->d_name, ".") == 0) || (strcmp(currp->d_name, "..") == 0) || #ifdef AFS_DECOSF_ENV @@ -842,25 +860,12 @@ static int doSweepAFSCache(vFilesFound,directory,dirNum,maxDir) if (dirNum < 0) { - /* + /* * Create all the cache files that are missing. */ - if (missing_DCacheFile) { - if (afsd_verbose) - printf("%s: Creating '%s'\n", - rn, fullpn_DCacheFile); - if (CreateCacheFile(fullpn_DCacheFile, NULL)) - printf("%s: Can't create '%s'\n", - rn, fullpn_DCacheFile); - } - if (missing_VolInfoFile) { - if (afsd_verbose) - printf("%s: Creating '%s'\n", - rn, fullpn_VolInfoFile); - if (CreateCacheFile(fullpn_VolInfoFile, NULL)) - printf("%s: Can't create '%s'\n", - rn, fullpn_VolInfoFile); - } + CreateFileIfMissing(fullpn_DCacheFile, missing_DCacheFile); + CreateFileIfMissing(fullpn_VolInfoFile, missing_VolInfoFile); + CreateFileIfMissing(fullpn_CellInfoFile, missing_CellInfoFile); /* ADJUST CACHE FILES */ @@ -1035,19 +1040,14 @@ register struct afsconf_cell *aci; char *arock; struct afsconf_dir *adir; { register int isHomeCell; - register int i; - afs_int32 cellFlags; + register int i, code; + afs_int32 cellFlags = 0; afs_int32 hosts[MAXHOSTSPERCELL]; /* figure out if this is the home cell */ isHomeCell = (strcmp(aci->name, LclCellName) == 0); - if (isHomeCell) { - lookingForHomeCell = 0; - cellFlags = 1; /* home cell, suid is ok */ - } - else { + if (!isHomeCell) cellFlags = 2; /* not home, suid is forbidden */ - } /* build address list */ for(i=0;iname, /* cell name */ cellFlags, /* is this the home cell? */ aci->linkedCell); /* Linked cell, if any */ + if (code) + printf("Adding cell '%s': error %d\n", aci->name, code); return 0; } @@ -1472,8 +1474,9 @@ mainproc(as, arock) /* * Set up all the pathnames we'll need for later. */ - sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); - sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE); + sprintf(fullpn_DCacheFile, "%s/%s", cacheBaseDir, DCACHEFILE); + sprintf(fullpn_VolInfoFile, "%s/%s", cacheBaseDir, VOLINFOFILE); + sprintf(fullpn_CellInfoFile, "%s/%s", cacheBaseDir, CELLINFOFILE); sprintf(fullpn_VFile, "%s/", cacheBaseDir); vFilePtr = fullpn_VFile + strlen(fullpn_VFile); @@ -1572,6 +1575,83 @@ mainproc(as, arock) } #endif + code = call_syscall(AFSOP_BASIC_INIT, 1); + if (code) + printf("%s: Error %d in basic initialization.\n", rn, code); + + /* + * Tell the kernel some basic information about the workstation's cache. + */ + if (afsd_verbose) + printf("%s: Calling AFSOP_CACHEINIT: %d stat cache entries, %d optimum cache files, %d blocks in the cache, flags = 0x%x, dcache entries %d\n", + rn, cacheStatEntries, cacheFiles, cacheBlocks, cacheFlags, + dCacheSize); + memset(&cparams, '\0', sizeof(cparams)); + cparams.cacheScaches = cacheStatEntries; + cparams.cacheFiles = cacheFiles; + cparams.cacheBlocks = cacheBlocks; + cparams.cacheDcaches = dCacheSize; + cparams.cacheVolumes = vCacheSize; + cparams.chunkSize = chunkSize; + cparams.setTimeFlag = cacheSetTime; + cparams.memCacheFlag = cacheFlags; +#ifdef notdef + cparams.inodes = inodes; +#endif + call_syscall(AFSOP_CACHEINIT, &cparams); + if (afsd_CloseSynch) + call_syscall(AFSOP_CLOSEWAIT); + + /* + * Sweep the workstation AFS cache directory, remembering the inodes of + * valid files and deleting extraneous files. Keep sweeping until we + * have the right number of data cache files or we've swept too many + * times. + * + * This also creates files in the cache directory like VolumeItems and + * CellItems, and thus must be ran before those are sent to the kernel. + */ + if (afsd_verbose) + printf("%s: Sweeping workstation's AFS cache directory.\n", + rn); + cacheIteration = 0; + /* Memory-cache based system doesn't need any of this */ + if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) { + do { + cacheIteration++; + if (SweepAFSCache(&vFilesFound)) { + printf("%s: Error on sweep %d of workstation AFS cache \ + directory.\n", rn, cacheIteration); + exit(1); + } + if (afsd_verbose) + printf("%s: %d out of %d data cache files found in sweep %d.\n", + rn, vFilesFound, cacheFiles, cacheIteration); + } while ((vFilesFound < cacheFiles) && + (cacheIteration < MAX_CACHE_LOOPS)); + } else if(afsd_verbose) + printf("%s: Using memory cache, not swept\n", rn); + + /* + * Pass the kernel the name of the workstation cache file holding the + * dcache entries. + */ + if (afsd_debug) + printf("%s: Calling AFSOP_CACHEINFO: dcache file is '%s'\n", + rn, fullpn_DCacheFile); + /* once again, meaningless for a memory-based cache. */ + if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) + call_syscall(AFSOP_CACHEINFO, fullpn_DCacheFile); + + /* + * Pass the kernel the name of the workstation cache file holding the + * cell information. + */ + if (afsd_debug) + printf("%s: Calling AFSOP_CELLINFO: cell info file is '%s'\n", + rn, fullpn_CellInfoFile); + call_syscall(AFSOP_CELLINFO, fullpn_CellInfoFile); + if (enable_dynroot) { if (afsd_verbose) printf("%s: Enabling dynroot support in kernel.\n", rn); @@ -1588,6 +1668,17 @@ mainproc(as, arock) printf("%s: Error enabling fakestat support.\n", rn); } + /* + * Tell the kernel about each cell in the configuration. + */ + afsconf_CellApply(cdir, ConfigCell, NULL); + afsconf_CellAliasApply(cdir, ConfigCellAlias, NULL); + + /* + * Set the primary cell name. + */ + call_syscall(AFSOP_SET_THISCELL, LclCellName); + /* Initialize AFS daemon threads. */ if (afsd_verbose) printf("%s: Forking AFS daemon.\n", rn); @@ -1643,23 +1734,6 @@ mainproc(as, arock) } #endif - /* - * Tell the kernel about each cell in the configuration. - */ - lookingForHomeCell = 1; - - afsconf_CellApply(cdir, ConfigCell, (char *) 0); - afsconf_CellAliasApply(cdir, ConfigCellAlias, (char *) 0); - - /* - * If we're still looking for the home cell after the whole cell configuration database - * has been parsed, there's something wrong. - */ - if (lookingForHomeCell) { - printf("%s: Can't find information for home cell '%s' in cell database!\n", - rn, LclCellName); - } - /* * If the root volume has been explicitly set, tell the kernel. */ @@ -1670,67 +1744,6 @@ mainproc(as, arock) call_syscall(AFSOP_ROOTVOLUME, rootVolume); } - /* - * Tell the kernel some basic information about the workstation's cache. - */ - if (afsd_verbose) - printf("%s: Calling AFSOP_CACHEINIT: %d stat cache entries, %d optimum cache files, %d blocks in the cache, flags = 0x%x, dcache entries %d\n", - rn, cacheStatEntries, cacheFiles, cacheBlocks, cacheFlags, - dCacheSize); - memset(&cparams, '\0', sizeof(cparams)); - cparams.cacheScaches = cacheStatEntries; - cparams.cacheFiles = cacheFiles; - cparams.cacheBlocks = cacheBlocks; - cparams.cacheDcaches = dCacheSize; - cparams.cacheVolumes = vCacheSize; - cparams.chunkSize = chunkSize; - cparams.setTimeFlag = cacheSetTime; - cparams.memCacheFlag = cacheFlags; -#ifdef notdef - cparams.inodes = inodes; -#endif - call_syscall(AFSOP_CACHEINIT, &cparams); - if (afsd_CloseSynch) - call_syscall(AFSOP_CLOSEWAIT); - - /* - * Sweep the workstation AFS cache directory, remembering the inodes of - * valid files and deleting extraneous files. Keep sweeping until we - * have the right number of data cache files or we've swept too many - * times. - */ - if (afsd_verbose) - printf("%s: Sweeping workstation's AFS cache directory.\n", - rn); - cacheIteration = 0; - /* Memory-cache based system doesn't need any of this */ - if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) { - do { - cacheIteration++; - if (SweepAFSCache(&vFilesFound)) { - printf("%s: Error on sweep %d of workstation AFS cache \ - directory.\n", rn, cacheIteration); - exit(1); - } - if (afsd_verbose) - printf("%s: %d out of %d data cache files found in sweep %d.\n", - rn, vFilesFound, cacheFiles, cacheIteration); - } while ((vFilesFound < cacheFiles) && - (cacheIteration < MAX_CACHE_LOOPS)); - } else if(afsd_verbose) - printf("%s: Using memory cache, not swept\n", rn); - - /* - * Pass the kernel the name of the workstation cache file holding the - * dcache entries. - */ - if (afsd_debug) - printf("%s: Calling AFSOP_CACHEINFO: dcache file is '%s'\n", - rn, fullpn_DCacheFile); - /* once again, meaningless for a memory-based cache. */ - if(!(cacheFlags & AFSCALL_INIT_MEMCACHE)) - call_syscall(AFSOP_CACHEINFO, fullpn_DCacheFile); - /* * Pass the kernel the name of the workstation cache file holding the * volume information. diff --git a/src/butc/Makefile.in b/src/butc/Makefile.in index 536ed1912..67afda267 100644 --- a/src/butc/Makefile.in +++ b/src/butc/Makefile.in @@ -28,7 +28,7 @@ SHELL = /bin/sh include ../config/Makefile.${SYS_NAME} -CFLAGS=-g -w ${INCDIRS} ${XCFLAGS} +CFLAGS=-g -w ${INCDIRS} ${XCFLAGS} @XBSA_CFLAGS@ INCDIRS=-I${TOP_SRCDIR}/config -I${TOP_INCDIR}/afs \ -I${TOP_INCDIR}/rx -I${TOP_INCDIR} @@ -107,7 +107,7 @@ clean: install: @case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix4*|*linux*|hp_ux*) \ + alpha_dux*|sgi_*|sun*|rs_aix4*|*linux*|hp_ux*) \ echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \ *) \ echo ${INSTALL} butc ${DESTDIR}${sbindir}/butc ; \ @@ -118,7 +118,7 @@ install: include ../config/Makefile.version dest: @case ${SYS_NAME} in \ - alpha_dux*|sgi_*|sun4x_*|rs_aix4*|*linux*|hp_ux*) \ + alpha_dux*|sgi_*|sun*|rs_aix4*|*linux*|hp_ux*) \ echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \ *) \ echo ${INSTALL} butc ${DEST}/etc/butc ; \ diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index ee2b143af..6b4386b18 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -1,35 +1,57 @@ -AC_DEFUN(LINUX_EXPORTS_TASKLIST_LOCK, [ -AC_MSG_CHECKING(for exported tasklist_lock) +AC_DEFUN(LINUX_COMPLETION_H_EXISTS, [ +AC_MSG_CHECKING(for linux/completion.h existance) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_exports_tasklist_lock, +AC_CACHE_VAL(ac_cv_linux_completion_h_exists, [ AC_TRY_COMPILE( -[#include ], -[#ifndef __ver_tasklist_lock -#error tasklist_lock not exported +[#include +#include ], +[struct completion _c; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,8) +lose +#endif +], +ac_cv_linux_completion_h_exists=yes, +ac_cv_linux_completion_h_exists=no)]) +AC_MSG_RESULT($ac_cv_linux_completion_h_exists) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_DEFINES_FOR_EACH_PROCESS, [ +AC_MSG_CHECKING(for defined for_each_process) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_defines_for_each_process, +[ +AC_TRY_COMPILE( +[#include ], +[#ifndef for_each_process(p) +#error for_each_process not defined #endif], -ac_cv_linux_exports_tasklist_lock=yes, -ac_cv_linux_exports_tasklist_lock=no)]) -AC_MSG_RESULT($ac_cv_linux_exports_tasklist_lock) +ac_cv_linux_defines_for_each_process=yes, +ac_cv_linux_defines_for_each_process=no)]) +AC_MSG_RESULT($ac_cv_linux_defines_for_each_process) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_EXPORTS_SYS_CALL_TABLE, [ -AC_MSG_CHECKING(for exported sys_call_table) + +AC_DEFUN(LINUX_DEFINES_PREV_TASK, [ +AC_MSG_CHECKING(for defined prev_task) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_exports_sys_call_table, +AC_CACHE_VAL(ac_cv_linux_defines_prev_task, [ AC_TRY_COMPILE( -[#include ], -[#ifndef __ver_sys_call_table -#error sys_call_table not exported +[#include ], +[#ifndef prev_task(p) +#error prev_task not defined #endif], -ac_cv_linux_exports_sys_call_table=yes, -ac_cv_linux_exports_sys_call_table=no)]) -AC_MSG_RESULT($ac_cv_linux_exports_sys_call_table) +ac_cv_linux_defines_prev_task=yes, +ac_cv_linux_defines_prev_task=no)]) +AC_MSG_RESULT($ac_cv_linux_defines_prev_task) CPPFLAGS="$save_CPPFLAGS"]) + AC_DEFUN(LINUX_EXPORTS_INIT_MM, [ AC_MSG_CHECKING(for exported init_mm) save_CPPFLAGS="$CPPFLAGS" @@ -46,6 +68,24 @@ ac_cv_linux_exports_init_mm=no)]) AC_MSG_RESULT($ac_cv_linux_exports_init_mm) CPPFLAGS="$save_CPPFLAGS"]) + +AC_DEFUN(LINUX_EXPORTS_KALLSYMS_ADDRESS, [ +AC_MSG_CHECKING(for exported kallsyms_address_to_symbol) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_exports_kallsyms_address, +[ +AC_TRY_COMPILE( +[#include ], +[#ifndef __ver_kallsyms_address_to_symbol +#error kallsyms_address_to_symbol not exported +#endif], +ac_cv_linux_exports_kallsyms_address=yes, +ac_cv_linux_exports_kallsyms_address=no)]) +AC_MSG_RESULT($ac_cv_linux_exports_kallsyms_address) +CPPFLAGS="$save_CPPFLAGS"]) + + AC_DEFUN(LINUX_EXPORTS_KALLSYMS_SYMBOL, [ AC_MSG_CHECKING(for exported kallsyms_symbol_to_address) save_CPPFLAGS="$CPPFLAGS" @@ -62,56 +102,107 @@ ac_cv_linux_exports_kallsyms_symbol=no)]) AC_MSG_RESULT($ac_cv_linux_exports_kallsyms_symbol) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_EXPORTS_KALLSYMS_ADDRESS, [ -AC_MSG_CHECKING(for exported kallsyms_address_to_symbol) + +AC_DEFUN(LINUX_EXPORTS_SYS_CALL_TABLE, [ +AC_MSG_CHECKING(for exported sys_call_table) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_exports_kallsyms_address, +AC_CACHE_VAL(ac_cv_linux_exports_sys_call_table, [ AC_TRY_COMPILE( [#include ], -[#ifndef __ver_kallsyms_address_to_symbol -#error kallsyms_address_to_symbol not exported +[#ifndef __ver_sys_call_table +#error sys_call_table not exported #endif], -ac_cv_linux_exports_kallsyms_address=yes, -ac_cv_linux_exports_kallsyms_address=no)]) -AC_MSG_RESULT($ac_cv_linux_exports_kallsyms_address) +ac_cv_linux_exports_sys_call_table=yes, +ac_cv_linux_exports_sys_call_table=no)]) +AC_MSG_RESULT($ac_cv_linux_exports_sys_call_table) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_COMPLETION_H_EXISTS, [ -AC_MSG_CHECKING(for linux/completion.h existance) + +AC_DEFUN(LINUX_EXPORTS_SYS_CHDIR, [ +AC_MSG_CHECKING(for exported sys_chdir) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_completion_h_exists, +AC_CACHE_VAL(ac_cv_linux_exports_sys_chdir, [ AC_TRY_COMPILE( -[#include -#include ], -[struct completion _c; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,8) -lose -#endif -], -ac_cv_linux_completion_h_exists=yes, -ac_cv_linux_completion_h_exists=no)]) -AC_MSG_RESULT($ac_cv_linux_completion_h_exists) +[#include ], +[#ifndef __ver_sys_chdir +#error sys_chdir not exported +#endif], +ac_cv_linux_exports_sys_chdir=yes, +ac_cv_linux_exports_sys_chdir=no)]) +AC_MSG_RESULT($ac_cv_linux_exports_sys_chdir) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_MMAP_SHARED, [ -AC_MSG_CHECKING(for i_mmap_shared in struct inode) + +AC_DEFUN(LINUX_EXPORTS_SYS_CLOSE, [ +AC_MSG_CHECKING(for exported sys_close) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_mmap_shared, +AC_CACHE_VAL(ac_cv_linux_exports_sys_close, +[ +AC_TRY_COMPILE( +[#include ], +[#ifndef __ver_sys_close +#error sys_close not exported +#endif], +ac_cv_linux_exports_sys_close=yes, +ac_cv_linux_exports_sys_close=no)]) +AC_MSG_RESULT($ac_cv_linux_exports_sys_close) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_EXPORTS_TASKLIST_LOCK, [ +AC_MSG_CHECKING(for exported tasklist_lock) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_exports_tasklist_lock, +[ +AC_TRY_COMPILE( +[#include ], +[#ifndef __ver_tasklist_lock +#error tasklist_lock not exported +#endif], +ac_cv_linux_exports_tasklist_lock=yes, +ac_cv_linux_exports_tasklist_lock=no)]) +AC_MSG_RESULT($ac_cv_linux_exports_tasklist_lock) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_CDEV, [ +AC_MSG_CHECKING(for i_cdev in struct inode) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_cdev, [ AC_TRY_COMPILE( [#include ], [struct inode _inode; -printf("%d\n", _inode.i_mmap_shared);], -ac_cv_linux_fs_struct_inode_has_i_mmap_shared=yes, -ac_cv_linux_fs_struct_inode_has_i_mmap_shared=no)]) -AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_mmap_shared) +printf("%d\n", _inode.i_cdev);], +ac_cv_linux_fs_struct_inode_has_i_cdev=yes, +ac_cv_linux_fs_struct_inode_has_i_cdev=no)]) +AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_cdev) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_DEVICES, [ +AC_MSG_CHECKING(for i_devices in struct inode) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_cdev, +[ +AC_TRY_COMPILE( +[#include ], +[struct inode _inode; +printf("%d\n", _inode.i_devices);], +ac_cv_linux_fs_struct_inode_has_i_devices=yes, +ac_cv_linux_fs_struct_inode_has_i_devices=no)]) +AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_devices) CPPFLAGS="$save_CPPFLAGS"]) + AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS, [ AC_MSG_CHECKING(for i_dirty_data_buffers in struct inode) save_CPPFLAGS="$CPPFLAGS" @@ -127,6 +218,7 @@ ac_cv_linux_fs_struct_inode_has_i_dirty_data_buffers=no)]) AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_dirty_data_buffers) CPPFLAGS="$save_CPPFLAGS"]) + AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_MAPPING_OVERLOAD, [ AC_MSG_CHECKING(for i_mapping_overload in struct inode) save_CPPFLAGS="$CPPFLAGS" @@ -142,33 +234,111 @@ ac_cv_linux_fs_struct_inode_has_i_mapping_overload=no)]) AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_mapping_overload) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_CDEV, [ -AC_MSG_CHECKING(for i_cdev in struct inode) + +AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_MMAP_SHARED, [ +AC_MSG_CHECKING(for i_mmap_shared in struct inode) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_cdev, +AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_mmap_shared, [ AC_TRY_COMPILE( [#include ], [struct inode _inode; -printf("%d\n", _inode.i_cdev);], -ac_cv_linux_fs_struct_inode_has_i_cdev=yes, -ac_cv_linux_fs_struct_inode_has_i_cdev=no)]) -AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_cdev) +printf("%d\n", _inode.i_mmap_shared);], +ac_cv_linux_fs_struct_inode_has_i_mmap_shared=yes, +ac_cv_linux_fs_struct_inode_has_i_mmap_shared=no)]) +AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_mmap_shared) CPPFLAGS="$save_CPPFLAGS"]) -AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_DEVICES, [ -AC_MSG_CHECKING(for i_devices in struct inode) + +AC_DEFUN(LINUX_RECALC_SIGPENDING_ARG_TYPE,[ +AC_MSG_CHECKING(for recalc_sigpending arg type) save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" -AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_cdev, +AC_CACHE_VAL(ac_cv_linux_func_recalc_sigpending_takes_void, [ AC_TRY_COMPILE( -[#include ], -[struct inode _inode; -printf("%d\n", _inode.i_devices);], -ac_cv_linux_fs_struct_inode_has_i_devices=yes, -ac_cv_linux_fs_struct_inode_has_i_devices=no)]) -AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_devices) +[#include ], +[recalc_sigpending();], +ac_cv_linux_func_recalc_sigpending_takes_void=yes, +ac_cv_linux_func_recalc_sigpending_takes_void=no)]) +AC_MSG_RESULT($ac_cv_linux_func_recalc_sigpending_takes_void) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_PARENT, [ +AC_MSG_CHECKING(for parent in struct task_struct) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_parent, +[ +AC_TRY_COMPILE( +[#include ], +[struct task_struct _tsk; +printf("%d\n", _tsk.parent);], +ac_cv_linux_sched_struct_task_struct_has_parent=yes, +ac_cv_linux_sched_struct_task_struct_has_parent=no)]) +AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_parent) CPPFLAGS="$save_CPPFLAGS"]) + +AC_DEFUN(LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_REAL_PARENT, [ +AC_MSG_CHECKING(for real_parent in struct task_struct) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_real_parent, +[ +AC_TRY_COMPILE( +[#include ], +[struct task_struct _tsk; +printf("%d\n", _tsk.real_parent);], +ac_cv_linux_sched_struct_task_struct_has_real_parent=yes, +ac_cv_linux_sched_struct_task_struct_has_real_parent=no)]) +AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_real_parent) +CPPFLAGS="$save_CPPFLAGS"]) + + +AC_DEFUN(LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIG, [ +AC_MSG_CHECKING(for sig in struct task_struct) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_sig, +[ +AC_TRY_COMPILE( +[#include ], +[struct task_struct _tsk; +printf("%d\n", _tsk.sig);], +ac_cv_linux_sched_struct_task_struct_has_sig=yes, +ac_cv_linux_sched_struct_task_struct_has_sig=no)]) +AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_sig) +CPPFLAGS="$save_CPPFLAGS"]) + +AC_DEFUN(LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGMASK_LOCK, [ +AC_MSG_CHECKING(for sigmask_lock in struct task_struct) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_sigmask_lock, +[ +AC_TRY_COMPILE( +[#include ], +[struct task_struct _tsk; +printf("%d\n", _tsk.sigmask_lock);], +ac_cv_linux_sched_struct_task_struct_has_sigmask_lock=yes, +ac_cv_linux_sched_struct_task_struct_has_sigmask_lock=no)]) +AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_sigmask_lock) +CPPFLAGS="$save_CPPFLAGS"]) + +AC_DEFUN(LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGHAND, [ +AC_MSG_CHECKING(for sighand in struct task_struct) +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS" +AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_sighand, +[ +AC_TRY_COMPILE( +[#include ], +[struct task_struct _tsk; +printf("%d\n", _tsk.sighand);], +ac_cv_linux_sched_struct_task_struct_has_sighand=yes, +ac_cv_linux_sched_struct_task_struct_has_sighand=no)]) +AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_sighand) +CPPFLAGS="$save_CPPFLAGS"]) diff --git a/src/cmd/cmd.c b/src/cmd/cmd.c index bb40f4afb..07c4a75b7 100644 --- a/src/cmd/cmd.c +++ b/src/cmd/cmd.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/cmd/cmd.c,v 1.1.1.8 2001/10/14 18:04:23 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/cmd/cmd.c,v 1.1.1.9 2003/04/13 19:06:20 hartmans Exp $"); #include #include @@ -784,6 +784,9 @@ char **argv; otherwise it is a real nuisance */ if (ts->parms[CMD_HELPPARM].items) { PrintSyntax(ts); + /* Display full help syntax if we don't have subcommands */ + if (noOpcodes) + PrintFlagHelp(ts); ResetSyntax(ts); return 0; } diff --git a/src/config/afs_args.h b/src/config/afs_args.h index ab8d095ee..688fa68d6 100644 --- a/src/config/afs_args.h +++ b/src/config/afs_args.h @@ -42,6 +42,9 @@ #define AFSOP_SET_DYNROOT 31 /* enable/disable dynroot support */ #define AFSOP_ADDCELLALIAS 32 /* create alias for existing cell */ #define AFSOP_SET_FAKESTAT 33 /* enable/disable fakestat support */ +#define AFSOP_CELLINFO 34 /* set the cellinfo file name */ +#define AFSOP_SET_THISCELL 35 /* set the primary cell */ +#define AFSOP_BASIC_INIT 36 /* used to be part of START_AFS */ /* The range 20-30 is reserved for AFS system offsets in the afs_syscall */ #define AFSCALL_PIOCTL 20 diff --git a/src/config/afs_sysnames.h b/src/config/afs_sysnames.h index e55a01efb..576c8de48 100644 --- a/src/config/afs_sysnames.h +++ b/src/config/afs_sysnames.h @@ -88,6 +88,7 @@ they won't allocate sunx86 IDs at all. So leave a gap and pray. */ #define SYS_NAME_ID_sunx86_57 950 #define SYS_NAME_ID_sunx86_58 951 +#define SYS_NAME_ID_sunx86_59 952 #define SYS_NAME_ID_vax_ul4 1003 #define SYS_NAME_ID_vax_ul40 1004 @@ -110,6 +111,7 @@ #define SYS_NAME_ID_alpha_osf32c 1204 #define SYS_NAME_ID_alpha_dux40 1205 #define SYS_NAME_ID_alpha_dux50 1206 +#define SYS_NAME_ID_alpha_dux51 1206 #define SYS_NAME_ID_ncrx86_20 1300 #define SYS_NAME_ID_ncrx86_30 1301 diff --git a/src/config/param.s390_linux22.h b/src/config/param.s390_linux22.h index 1dcb8fed4..4d44dc777 100644 --- a/src/config/param.s390_linux22.h +++ b/src/config/param.s390_linux22.h @@ -33,7 +33,7 @@ #ifdef AFS_SMP #define CONFIG_SMP 1 #ifndef CONFIG_S390_LOCAL_APIC -#define CONFIG_S390_LOCAL_APIC +#define CONFIG_S390_LOCAL_APIC 1 #endif #ifndef __SMP__ #define __SMP__ diff --git a/src/config/param.sunx86_57_usr.h b/src/config/param.sunx86_57_usr.h index a15bb9004..ed4cc182e 100644 --- a/src/config/param.sunx86_57_usr.h +++ b/src/config/param.sunx86_57_usr.h @@ -21,6 +21,7 @@ #define AFS_ENV 1 #define AFS_USR_SUN5_ENV 1 #define AFS_USR_SUN6_ENV 1 +#define AFS_USR_SUN7_ENV 1 #include @@ -33,9 +34,9 @@ #define AFS_MOUNT_AFS 1 /* Machine / Operating system information */ -#define sys_sun4x_55 1 -#define SYS_NAME "sun4x_55" -#define SYS_NAME_ID SYS_NAME_ID_sun4x_55 +#define sys_sunx86_57 1 +#define SYS_NAME "sunx86_57" +#define SYS_NAME_ID SYS_NAME_ID_sunx86_57 #define AFSLITTLE_ENDIAN 1 #define AFS_HAVE_FFS 1 /* Use system's ffs. */ #define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ diff --git a/src/config/param.sunx86_58_usr.h b/src/config/param.sunx86_58_usr.h index bc9657c8d..543a7389c 100644 --- a/src/config/param.sunx86_58_usr.h +++ b/src/config/param.sunx86_58_usr.h @@ -21,6 +21,8 @@ #define AFS_ENV 1 #define AFS_USR_SUN5_ENV 1 #define AFS_USR_SUN6_ENV 1 +#define AFS_USR_SUN7_ENV 1 +#define AFS_USR_SUN8_ENV 1 #include @@ -33,9 +35,9 @@ #define AFS_MOUNT_AFS 1 /* Machine / Operating system information */ -#define sys_sun4x_55 1 -#define SYS_NAME "sun4x_55" -#define SYS_NAME_ID SYS_NAME_ID_sun4x_55 +#define sys_sunx86_58 1 +#define SYS_NAME "sunx86_58" +#define SYS_NAME_ID SYS_NAME_ID_sunx86_58 #define AFSLITTLE_ENDIAN 1 #define AFS_HAVE_FFS 1 /* Use system's ffs. */ #define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ diff --git a/src/fsint/afscbint.xg b/src/fsint/afscbint.xg index a8ce0c153..c1bae1c50 100644 --- a/src/fsint/afscbint.xg +++ b/src/fsint/afscbint.xg @@ -96,3 +96,9 @@ proc GetCacheConfig( OUT cacheConfig *config ) = 218; +proc GetCellByNum( + IN afs_int32 cellNumber, + OUT string cellName, + OUT serverList *cellHosts +) = 65537; + diff --git a/src/fsprobe/fsprobe_callback.c b/src/fsprobe/fsprobe_callback.c index 4230c3b81..e4a2582b1 100644 --- a/src/fsprobe/fsprobe_callback.c +++ b/src/fsprobe/fsprobe_callback.c @@ -24,7 +24,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/fsprobe/fsprobe_callback.c,v 1.1.1.5 2002/05/10 23:58:47 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/fsprobe/fsprobe_callback.c,v 1.1.1.6 2003/04/13 19:06:39 hartmans Exp $"); #include #include /*Standard I/O stuff*/ @@ -646,6 +646,15 @@ int SRXAFSCB_GetCellServDB( return RXGEN_OPCODE; } +afs_int32 SRXAFSCB_GetCellByNum( + struct rx_call *a_call, + afs_int32 a_cellnum, + char **a_name, + serverList *a_hosts) +{ + return RXGEN_OPCODE; +} + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetLocalCell * diff --git a/src/inetd/Makefile.in b/src/inetd/Makefile.in index b1d3f963f..438286a80 100644 --- a/src/inetd/Makefile.in +++ b/src/inetd/Makefile.in @@ -63,7 +63,7 @@ install: ${DESTDIR}${sbindir}/inetd dest: ${DEST}/etc/inetd set -x; \ case "${SYS_NAME}" in \ - sun4* ) \ + sun* ) \ ${INSTALL} -m 644 -f inetd.conf.solaris ${DEST}/etc/inetd.conf ;; \ sgi_* ) \ ${INSTALL} -m 644 -f inetd.conf.sgi ${DEST}/etc/inetd.conf ;; \ diff --git a/src/kauth/kaprocs.c b/src/kauth/kaprocs.c index ffd91a67a..646ebb1fd 100644 --- a/src/kauth/kaprocs.c +++ b/src/kauth/kaprocs.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/kaprocs.c,v 1.1.1.10 2002/05/10 23:59:04 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/kaprocs.c,v 1.1.1.11 2003/04/13 19:06:44 hartmans Exp $"); #include #include @@ -1707,6 +1707,11 @@ static afs_int32 GetTicket (version, call, kvno, authDomain, aticket, if (import && (celllen == 0)) {code = KABADTICKET; goto abort;} if (export && (celllen == 0)) strcpy (cell, lrealm); + if (!krb4_cross && celllen && strcmp(lrealm, cell) != 0) { + code = KABADUSER; + goto abort; + } + des_ecb_encrypt (atimes->SeqBody, ×, schedule, DECRYPT); times.start = ntohl(times.start); times.end = ntohl(times.end); diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c index 00b12a577..a6aeaecfd 100644 --- a/src/kauth/kaserver.c +++ b/src/kauth/kaserver.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/kaserver.c,v 1.1.1.10 2002/05/10 23:59:05 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/kaserver.c,v 1.1.1.11 2003/04/13 19:06:45 hartmans Exp $"); #include #include @@ -56,6 +56,8 @@ struct kadstats dynamic_statistics; struct ubik_dbase *KA_dbase; afs_int32 myHost = 0; afs_int32 verbose_track = 1; +afs_int32 krb4_cross = 0; + struct afsconf_dir *KA_conf; /* for getting cell info */ extern afs_int32 ubik_lastYesTime; @@ -194,6 +196,7 @@ main (argc, argv) usage: printf("Usage: kaserver [-noAuth] [-fastKeys] [-database ] " "[-localfiles ] [-minhours ] [-servers ] " + "[-crossrealm]" /*" [-enable_peer_stats] [-enable_process_stats] " */ "[-help]\n"); exit(1); @@ -251,6 +254,7 @@ main (argc, argv) else if (IsArg("-clear")) level = rxkad_clear; else if (IsArg("-sorry")) level = rxkad_clear; else if (IsArg("-debug")) verbose_track = 0; + else if (IsArg("-crossrealm")) krb4_cross = 1; else if (IsArg("-minhours")) { MinHours = atoi(argv[++a]); } diff --git a/src/kauth/kaserver.h b/src/kauth/kaserver.h index dfc0e3415..ef7580545 100644 --- a/src/kauth/kaserver.h +++ b/src/kauth/kaserver.h @@ -179,6 +179,7 @@ extern int kaux_islocked( u_int locktime ); +extern afs_int32 krb4_cross; #define LOCKPW diff --git a/src/kauth/krb_udp.c b/src/kauth/krb_udp.c index 43ddd1eac..472662e0e 100644 --- a/src/kauth/krb_udp.c +++ b/src/kauth/krb_udp.c @@ -15,7 +15,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/krb_udp.c,v 1.1.1.13 2002/09/26 19:06:20 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/kauth/krb_udp.c,v 1.1.1.14 2003/04/13 19:06:46 hartmans Exp $"); #include #include @@ -462,6 +462,11 @@ afs_int32 UDP_GetTicket (ksoc, pkt, kvno, authDomain, ticket, ticketLen, auth, a cell[MAXKTCREALMLEN-1] = 0; }; + if (!krb4_cross && strcmp(lrealm, cell) != 0) { + code = KERB_ERR_PRINCIPAL_UNKNOWN; + goto abort; + } + if (krb_udp_debug) { printf ("UGetTicket: got ticket from '%s'.'%s'@'%s'\n", name, inst, cell); diff --git a/src/libacl/aclprocs.c b/src/libacl/aclprocs.c index a84c4c7dd..70cc9789c 100644 --- a/src/libacl/aclprocs.c +++ b/src/libacl/aclprocs.c @@ -16,7 +16,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/aclprocs.c,v 1.1.1.8 2001/10/14 18:05:15 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/aclprocs.c,v 1.1.1.9 2003/04/13 19:06:48 hartmans Exp $"); #include #ifdef AFS_NT40_ENV @@ -29,7 +29,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/aclprocs.c,v 1.1.1.8 2001/10/14 #endif #include #include -#include +#include #include "acl.h" #ifdef AFS_PTHREAD_ENV diff --git a/src/libacl/netprocs.c b/src/libacl/netprocs.c index 223e18881..a0aeb38d9 100644 --- a/src/libacl/netprocs.c +++ b/src/libacl/netprocs.c @@ -16,7 +16,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/netprocs.c,v 1.1.1.4 2001/07/14 22:22:22 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/netprocs.c,v 1.1.1.5 2003/04/13 19:06:48 hartmans Exp $"); #include #ifdef AFS_NT40_ENV @@ -26,7 +26,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/libacl/netprocs.c,v 1.1.1.4 2001/07/14 #endif #include #include -#include +#include #include "acl.h" int acl_HtonACL(acl) diff --git a/src/libafs/MakefileProto.SOLARIS.in b/src/libafs/MakefileProto.SOLARIS.in index a5b7c574f..4d4657999 100644 --- a/src/libafs/MakefileProto.SOLARIS.in +++ b/src/libafs/MakefileProto.SOLARIS.in @@ -51,27 +51,30 @@ DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT KDEFS= -Dsun4c -DSUN4C_60 -DNFSCLIENT -DSYSACCT -DOLDSCSI -DVDDRV -D_KERNEL \ -DSYSV -dn ${ARCH_DEFS} - + KDEFS_32 = + KDEFS_64 = -xarch=v9 CFLAGS=-I. -I.. -I${TOP_SRCDIR}/config ${FSINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG} # Name of directory to hold object files and libraries. - + KOBJ = MODLOAD KOBJ = MODLOAD32 MODLOAD64 + +KOBJ = MODLOAD32 # This tells Makefile.common to use it's single directory build target. - + COMPDIRS = single_compdir INSTDIRS = single_instdir DESTDIRS = single_destdir - + COMPDIRS = solaris_compdirs INSTDIRS = solaris_instdirs DESTDIRS = solaris_destdirs @@ -103,7 +106,7 @@ setup: ## This is the target for a Solaris 7. Here we build both the 32 bit and ## the 64 bit libafs in MODLOAD32 and MODLOAD64 directories respectively - + ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: for t in ${KOBJ} ; do \ echo Building directory: $$t ; \ @@ -132,13 +135,26 @@ solaris_destdirs_libafs: dest_libafs LIBAFS = libafs.o LIBAFSNONFS = libafs.nonfs.o - + INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS} INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS} DEST_LIBAFS = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFS} DEST_LIBAFSNONFS = ${DEST}/root.client/usr/vice/etc/modload/${LIBAFSNONFS} + + +libafs: ${LIBAFSNONFS} ${LIBAFS} + +install_libafs: ${LIBAFSNONFS} ${LIBAFS} + ${INSTALL} -f ${LIBAFSNONFS} ${DESTDIR}${afskerneldir}/libafs${BITS}.nonfs.o + ${INSTALL} -f ${LIBAFS} ${DESTDIR}${afskerneldir}/libafs${BITS}.o + +dest_libafs: ${LIBAFSNONFS} ${LIBAFS} + ${INSTALL} -f ${LIBAFSNONFS} ${DEST}/root.client/usr/vice/etc/modload/libafs${BITS}.nonfs.o + ${INSTALL} -f ${LIBAFS} ${DEST}/root.client/usr/vice/etc/modload/libafs${BITS}.o + + # Without this line, gmake tries to build libafs.o .PHONY: libafs @@ -159,7 +175,6 @@ $(DEST_LIBAFS): $(LIBAFS) $(DEST_LIBAFSNONFS): $(LIBAFSNONFS) ${INSTALL} -f $? $@ - ${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS) $(RM) -f $@ $(LD) -r -o $@ $(AFSAOBJS) ${AFSNFSOBJS} @@ -168,18 +183,6 @@ ${LIBAFSNONFS}: $(AFSAOBJS) $(AFSNONFSOBJS) $(RM) -f $@ $(LD) -r -o $@ $(AFSAOBJS) ${AFSNONFSOBJS} - - -libafs: ${LIBAFSNONFS} ${LIBAFS} - -install_libafs: ${LIBAFSNONFS} ${LIBAFS} - ${INSTALL} -f ${LIBAFSNONFS} ${DESTDIR}${afskerneldir}/libafs${BITS}.nonfs.o - ${INSTALL} -f ${LIBAFS} ${DESTDIR}${afskerneldir}/libafs${BITS}.o - -dest_libafs: ${LIBAFSNONFS} ${LIBAFS} - ${INSTALL} -f ${LIBAFSNONFS} ${DEST}/root.client/usr/vice/etc/modload/libafs${BITS}.nonfs.o - ${INSTALL} -f ${LIBAFS} ${DEST}/root.client/usr/vice/etc/modload/libafs${BITS}.o - # Solaris specific objects diff --git a/src/libafsrpc/afsrpc.def b/src/libafsrpc/afsrpc.def index 95ec3c992..3227b7c2b 100644 --- a/src/libafsrpc/afsrpc.def +++ b/src/libafsrpc/afsrpc.def @@ -198,3 +198,4 @@ EXPORTS rx_enable_hot_thread @203 DATA xdr_int64 @204 xdr_uint64 @205 + osi_AssertFailU @206 diff --git a/src/lwp/test/selclient.c b/src/lwp/test/selclient.c index a0d8f01c4..ec17d0bb8 100644 --- a/src/lwp/test/selclient.c +++ b/src/lwp/test/selclient.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -53,7 +53,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selclient.c,v 1.1.1.4 2001/07/14 22:22:58 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selclient.c,v 1.1.1.5 2003/04/13 19:07:03 hartmans Exp $"); #include "../lwp.h" @@ -184,6 +184,11 @@ main(int ac, char **av) Usage(); } + if (writeSize == 0 && doEnd ==0 && putOOB == 0) { + printf("%s: Missing action.\n", program); + Usage(); + } + if (!setFD) { setFD = 31; printf("%s: Using default socket of %d.\n", program, setFD); diff --git a/src/lwp/test/selserver.c b/src/lwp/test/selserver.c index ffaf2e935..9f1995479 100644 --- a/src/lwp/test/selserver.c +++ b/src/lwp/test/selserver.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selserver.c,v 1.1.1.4 2001/07/14 22:22:58 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selserver.c,v 1.1.1.5 2003/04/13 19:07:04 hartmans Exp $"); #include "../lwp.h" diff --git a/src/lwp/test/selsubs.c b/src/lwp/test/selsubs.c index b29f03884..7295e305f 100644 --- a/src/lwp/test/selsubs.c +++ b/src/lwp/test/selsubs.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -28,7 +28,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selsubs.c,v 1.1.1.5 2001/09/11 14:33:42 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/lwp/test/selsubs.c,v 1.1.1.6 2003/04/13 19:07:04 hartmans Exp $"); #include "../lwp.h" @@ -141,12 +141,13 @@ void Log(char *fmt, ...) { va_list args; struct timeval now; + struct timezone tz; struct tm *ltime; int code; PROCESS pid; extern char *program; - code = gettimeofday(&now); + code = gettimeofday(&now,&tz); assert (code == 0); ltime = localtime((time_t*)&now.tv_sec); diff --git a/src/rx/DARWIN/rx_knet.c b/src/rx/DARWIN/rx_knet.c index 92886b94b..3e747cd76 100644 --- a/src/rx/DARWIN/rx_knet.c +++ b/src/rx/DARWIN/rx_knet.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/DARWIN/rx_knet.c,v 1.1.1.4 2001/09/11 14:34:30 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/DARWIN/rx_knet.c,v 1.1.1.5 2003/04/13 19:07:28 hartmans Exp $"); #include "../rx/rx_kcommon.h" @@ -24,7 +24,7 @@ int osi_NetReceive(asocket, addr, dvec, nvecs, alength) struct uio u; int i; struct iovec iov[RX_MAXIOVECS]; - struct sockaddr *sa; + struct sockaddr *sa = NULL; int code; int haveGlock = ISAFS_GLOCK(); @@ -60,13 +60,16 @@ int osi_NetReceive(asocket, addr, dvec, nvecs, alength) if (haveGlock) { AFS_GLOCK(); } - *alength=*alength-u.uio_resid; + if (code) + return code; + *alength -= u.uio_resid; if (sa) { if (sa->sa_family == AF_INET) { if (addr) *addr=*(struct sockaddr_in *)sa; } else { printf("Unknown socket family %d in NetReceive\n"); } + FREE(sa, M_SONAME); } return code; } diff --git a/src/rx/FBSD/rx_knet.c b/src/rx/FBSD/rx_knet.c index 4ed5f43b8..21bb367a8 100644 --- a/src/rx/FBSD/rx_knet.c +++ b/src/rx/FBSD/rx_knet.c @@ -23,9 +23,10 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/FBSD/rx_knet.c,v 1.1.1.5 2002/09/26 19:07:44 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/FBSD/rx_knet.c,v 1.1.1.6 2003/04/13 19:07:28 hartmans Exp $"); #ifdef AFS_FBSD40_ENV +#include #include "../rx/rx_kcommon.h" @@ -37,7 +38,7 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, struct uio u; int i; struct iovec iov[RX_MAXIOVECS]; - struct sockaddr *sa; + struct sockaddr *sa = NULL; int code; int haveGlock = ISAFS_GLOCK(); @@ -75,13 +76,16 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, if (haveGlock) { AFS_GLOCK(); } - *alength=*alength-u.uio_resid; + if (code) + return code; + *alength -= u.uio_resid; if (sa) { if (sa->sa_family == AF_INET) { if (addr) *addr=*(struct sockaddr_in *)sa; } else { printf("Unknown socket family %d in NetReceive\n", sa->sa_family); } + FREE(sa, M_SONAME); } return code; } @@ -141,7 +145,8 @@ osi_NetSend(asocket, addr, dvec, nvecs, alength, istack) #if KNET_DEBUG printf("+"); #endif - code = sosend(asocket, addr, &u, NULL, NULL, 0, curproc); + code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0, + curproc); #if KNET_DEBUG if (code) { if (code == EINVAL) diff --git a/src/rx/LINUX/rx_kmutex.h b/src/rx/LINUX/rx_kmutex.h index 22d520865..85155ae86 100644 --- a/src/rx/LINUX/rx_kmutex.h +++ b/src/rx/LINUX/rx_kmutex.h @@ -17,6 +17,7 @@ #define RX_KMUTEX_H_ #include "../rx/rx_kernel.h" /* for osi_Panic() */ +#include "linux/sched.h" /* AFS_GLOBAL_RXLOCK_KERNEL is defined so that the busy tq code paths are * used. The thread can sleep when sending packets. @@ -32,7 +33,6 @@ struct coda_inode_info {}; #endif #include "linux/wait.h" -#include "linux/sched.h" typedef struct afs_kmutex { struct semaphore sem; @@ -125,19 +125,19 @@ static inline int CV_WAIT(afs_kcondvar_t *cv, afs_kmutex_t *l) if (isAFSGlocked) AFS_GUNLOCK(); MUTEX_EXIT(l); - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); saved_set = current->blocked; sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); schedule(); remove_wait_queue(cv, &wait); - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); current->blocked = saved_set; - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); if (isAFSGlocked) AFS_GLOCK(); MUTEX_ENTER(l); @@ -162,19 +162,19 @@ static inline int CV_TIMEDWAIT(afs_kcondvar_t *cv, afs_kmutex_t *l, int waittime if (isAFSGlocked) AFS_GUNLOCK(); MUTEX_EXIT(l); - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); saved_set = current->blocked; sigfillset(¤t->blocked); - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); t = schedule_timeout(t); remove_wait_queue(cv, &wait); - spin_lock_irq(¤t->sigmask_lock); + SIG_LOCK(current); current->blocked = saved_set; - recalc_sigpending(current); - spin_unlock_irq(¤t->sigmask_lock); + RECALC_SIGPENDING(current); + SIG_UNLOCK(current); if (isAFSGlocked) AFS_GLOCK(); MUTEX_ENTER(l); diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c index 535d811f6..db0c51a59 100644 --- a/src/rx/LINUX/rx_knet.c +++ b/src/rx/LINUX/rx_knet.c @@ -15,8 +15,9 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/LINUX/rx_knet.c,v 1.1.1.9 2002/05/18 19:47:41 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/LINUX/rx_knet.c,v 1.1.1.10 2003/04/13 19:07:29 hartmans Exp $"); +#include #ifdef AFS_LINUX22_ENV #include "../rx/rx_kcommon.h" #if defined(AFS_LINUX24_ENV) @@ -175,11 +176,18 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *from, void osi_StopListener(void) { - extern int (*sys_killp)(); + struct task_struct *listener; extern int rxk_ListenerPid; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_lock(&tasklist_lock); +#endif + listener = find_task_by_pid(rxk_ListenerPid); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) + read_unlock(&tasklist_lock); +#endif while (rxk_ListenerPid) { - (void) (*sys_killp)(rxk_ListenerPid, SIGKILL); + force_sig(SIGKILL, listener); afs_osi_Sleep(&rxk_ListenerPid); } sock_release(rx_socket); diff --git a/src/rx/SOLARIS/rx_knet.c b/src/rx/SOLARIS/rx_knet.c index 3c690af1e..bdaf06312 100644 --- a/src/rx/SOLARIS/rx_knet.c +++ b/src/rx/SOLARIS/rx_knet.c @@ -10,7 +10,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/SOLARIS/rx_knet.c,v 1.1.1.9 2002/05/11 00:01:39 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/SOLARIS/rx_knet.c,v 1.1.1.10 2003/04/13 19:07:29 hartmans Exp $"); #ifdef AFS_SUN5_ENV #include "../rx/rx_kcommon.h" @@ -292,11 +292,21 @@ int osi_FreeSocket(asocket) { extern int rxk_ListenerPid; struct sonode *so = (struct sonode *)asocket; - vnode_t *vp = SOTOV(so); + struct sockaddr_in taddr; + struct iovec dvec; + char c; AFS_STATCNT(osi_FreeSocket); + + taddr.sin_family = AF_INET; + taddr.sin_port = htons(rx_port); + taddr.sin_addr.s_addr = htonl(0x7f000001); + + dvec.iov_base = &c; + dvec.iov_len = 1; + while (rxk_ListenerPid) { - kill(rxk_ListenerPid, SIGUSR1); + osi_NetSend(rx_socket, &taddr, &dvec, 1, 1, 0); afs_osi_Sleep(&rxk_ListenerPid); } diff --git a/src/rx/rx_globals.h b/src/rx/rx_globals.h index bd467e37f..f8d758021 100644 --- a/src/rx/rx_globals.h +++ b/src/rx/rx_globals.h @@ -32,7 +32,6 @@ EXT struct rx_service *rx_services[RX_MAX_SERVICES+1]; #ifdef RX_ENABLE_LOCKS /* Protects nRequestsRunning as well as pool allocation variables. */ EXT afs_kmutex_t rx_serverPool_lock; -EXT afs_kcondvar_t rx_serverPool_cv; #endif /* RX_ENABLE_LOCKS */ /* Incoming calls wait on this queue when there are no available server processes */ @@ -374,7 +373,13 @@ EXT int rxi_callAbortDelay INIT(3000); */ #if defined(AFS_PTHREAD_ENV) +EXT int rxi_fcfs_thread_num INIT(0); EXT pthread_key_t rx_thread_id_key; +/* keep track of pthread numbers - protected by rx_stats_mutex, + except in rx_Init() before mutex exists! */ +EXT int rxi_pthread_hinum INIT(0); +#else +#define rxi_fcfs_thread_num (0) #endif #if defined(RX_ENABLE_LOCKS) diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index fbc32cb97..a3ff587d8 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -14,7 +14,7 @@ #include #include "../afs/param.h" -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_kcommon.c,v 1.1.1.14 2002/12/11 02:44:30 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_kcommon.c,v 1.1.1.15 2003/04/13 19:07:24 hartmans Exp $"); #include "../rx/rx_kcommon.h" @@ -1024,14 +1024,15 @@ int rxk_ListenerPid; /* Used to signal process to wakeup at shutdown */ #ifdef AFS_SUN5_ENV /* - * Run the listener as a kernel process. + * Run the listener as a kernel thread. */ void rxk_Listener(void) { extern id_t syscid; void rxk_ListenerProc(void); - if (newproc(rxk_ListenerProc, syscid, 59)) - osi_Panic("rxk_Listener: failed to fork listener process!\n"); + if (thread_create(NULL, DEFAULTSTKSZ, rxk_ListenerProc, + 0, 0, &p0, TS_RUN, minclsyspri) == NULL) + osi_Panic("rxk_Listener: failed to start listener thread!\n"); } void rxk_ListenerProc(void) @@ -1047,7 +1048,7 @@ void rxk_Listener(void) rxk_ListenerPid = current->pid; #endif #ifdef AFS_SUN5_ENV - rxk_ListenerPid = ttoproc(curthread)->p_pidp->pid_id; + rxk_ListenerPid = 1; /* No PID, just a flag that we're alive */ #endif /* AFS_SUN5_ENV */ #ifdef AFS_FBSD_ENV rxk_ListenerPid = curproc->p_pid; @@ -1091,11 +1092,6 @@ void rxk_Listener(void) #endif #ifdef AFS_SUN5_ENV AFS_GUNLOCK(); -#ifdef HAVE_P_COREFILE - if (!curproc->p_corefile) /* newproc doesn't set it, but exit frees it */ - curproc->p_corefile = refstr_alloc("core"); -#endif - exit(CLD_EXITED, 0); #endif /* AFS_SUN5_ENV */ } diff --git a/src/rx/rx_kcommon.h b/src/rx/rx_kcommon.h index 4ac04c2c4..0eacd8aae 100644 --- a/src/rx/rx_kcommon.h +++ b/src/rx/rx_kcommon.h @@ -30,6 +30,7 @@ typedef unsigned short etap_event_t; #include "../h/vfs.h" /* stops SUN56 socketvar.h warnings */ #include "../h/stropts.h" /* stops SUN56 socketvar.h warnings */ #include "../h/stream.h" /* stops SUN56 socketvar.h errors */ +#include "../h/disp.h" #endif #include "../h/socket.h" #ifndef AFS_LINUX22_ENV diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index c2709d2e2..e333ce296 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -18,7 +18,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_pthread.c,v 1.1.1.9 2002/08/02 04:36:23 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_pthread.c,v 1.1.1.10 2003/04/13 19:07:25 hartmans Exp $"); #include #include @@ -33,8 +33,8 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_pthread.c,v 1.1.1.9 2002/08/02 04 # include #endif #include -#include -#include +#include +#include #include #include @@ -53,7 +53,7 @@ static long rx_pthread_n_event_wakeups; */ static int rx_pthread_event_rescheduled = 0; -static void rx_ListenerProc(void *); +static void *rx_ListenerProc(void *); /* * We supply an event handling thread for Rx's event processing. @@ -204,7 +204,7 @@ int sock; int *tnop; struct rx_call **newcallp; { - u_long host; + unsigned int host; u_short port; register struct rx_packet *p = (struct rx_packet *)0; @@ -245,7 +245,7 @@ struct rx_call **newcallp; /* This is the listener process request loop. The listener process loop * becomes a server thread when rxi_ListenerProc returns, and stays * server thread until rxi_ServerProc returns. */ -static void rx_ListenerProc(void *argp) +static void *rx_ListenerProc(void *argp) { int threadID; int sock = (int) argp; @@ -279,7 +279,21 @@ void rx_ServerProc() rxi_dataQuota += rx_initSendWindow; /* Reserve some pkts for hard times */ /* threadID is used for making decisions in GetCall. Get it by bumping * number of threads handling incoming calls */ - threadID = rxi_availProcs++; + /* Unique thread ID: used for scheduling purposes *and* as index into + the host hold table (fileserver). + The previously used rxi_availProcs is unsuitable as it + will already go up and down as packets arrive while the server + threads are still initialising! The recently introduced + rxi_pthread_hinum does not necessarily lead to a server + thread with id 0, which is not allowed to hop through the + incoming call queue. + So either introduce yet another counter or flag the FCFS + thread... chose the latter. + */ + threadID = ++rxi_pthread_hinum; + if (rxi_fcfs_thread_num==0 && rxi_fcfs_thread_num!=threadID) + rxi_fcfs_thread_num=threadID; + ++rxi_availProcs; MUTEX_EXIT(&rx_stats_mutex); while(1) { @@ -330,6 +344,9 @@ void rxi_StartListener() { printf("Unable to create Rx event handling thread\n"); exit(1); } + MUTEX_ENTER(&rx_stats_mutex); + ++rxi_pthread_hinum; + MUTEX_EXIT(&rx_stats_mutex); AFS_SIGSET_RESTORE(); assert(pthread_mutex_lock(&listener_mutex)==0); @@ -371,6 +388,9 @@ rxi_Listen(sock) printf("Unable to create socket listener thread\n"); exit(1); } + MUTEX_ENTER(&rx_stats_mutex); + ++rxi_pthread_hinum; + MUTEX_EXIT(&rx_stats_mutex); AFS_SIGSET_RESTORE(); return 0; } diff --git a/src/rx/rx_rdwr.c b/src/rx/rx_rdwr.c index 9fc416aed..7030c8703 100644 --- a/src/rx/rx_rdwr.c +++ b/src/rx/rx_rdwr.c @@ -14,7 +14,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_rdwr.c,v 1.1.1.10 2001/10/14 18:06:23 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/rx_rdwr.c,v 1.1.1.11 2003/04/13 19:07:26 hartmans Exp $"); #ifdef KERNEL #ifndef UKERNEL diff --git a/src/rx/xdr_mem.c b/src/rx/xdr_mem.c index b65b0c38b..b36eca9c6 100644 --- a/src/rx/xdr_mem.c +++ b/src/rx/xdr_mem.c @@ -29,7 +29,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/rx/xdr_mem.c,v 1.1.1.4 2001/09/11 14:34:27 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rx/xdr_mem.c,v 1.1.1.5 2003/04/13 19:07:27 hartmans Exp $"); #ifndef NeXT @@ -84,7 +84,7 @@ xdrmem_create(xdrs, addr, size, op) xdrs->x_op = op; xdrs->x_ops = &xdrmem_ops; xdrs->x_private = xdrs->x_base = addr; - xdrs->x_handy = size; + xdrs->x_handy = (size > INT_MAX) ? INT_MAX : size; /* XXX */ } static void @@ -98,12 +98,14 @@ xdrmem_getint32(xdrs, lp) register XDR *xdrs; afs_int32 *lp; { - - if ((xdrs->x_handy -= sizeof(afs_int32)) < 0) - return (FALSE); - *lp = ntohl(*((afs_int32 *)(xdrs->x_private))); - xdrs->x_private += sizeof(afs_int32); - return (TRUE); + if (xdrs->x_handy -= sizeof(afs_int32)) + return (FALSE); + else + xdrs->x_handy -= sizeof(afs_int32); + + *lp = ntohl(*((afs_int32 *)(xdrs->x_private))); + xdrs->x_private += sizeof(afs_int32); + return (TRUE); } static bool_t @@ -111,12 +113,14 @@ xdrmem_putint32(xdrs, lp) register XDR *xdrs; afs_int32 *lp; { - - if ((xdrs->x_handy -= sizeof(afs_int32)) < 0) - return (FALSE); - *(afs_int32 *)xdrs->x_private = htonl(*lp); - xdrs->x_private += sizeof(afs_int32); - return (TRUE); + if (xdrs->x_handy -= sizeof(afs_int32)) + eturn (FALSE); + else + xdrs->x_handy -= sizeof(afs_int32); + + *(afs_int32 *)xdrs->x_private = htonl(*lp); + xdrs->x_private += sizeof(afs_int32); + return (TRUE); } static bool_t @@ -125,12 +129,14 @@ xdrmem_getbytes(xdrs, addr, len) caddr_t addr; register u_int len; { - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - memcpy(addr, xdrs->x_private, len); - xdrs->x_private += len; - return (TRUE); + if (xdrs->x_handy < len) + return (FALSE); + else + xdrs->x_handy -= len; + + memcpy(addr, xdrs->x_private, len); + xdrs->x_private += len; + return (TRUE); } static bool_t @@ -139,12 +145,14 @@ xdrmem_putbytes(xdrs, addr, len) caddr_t addr; register u_int len; { - - if ((xdrs->x_handy -= len) < 0) - return (FALSE); - memcpy(xdrs->x_private, addr, len); - xdrs->x_private += len; - return (TRUE); + if (xdrs->x_handy < len) + return (FALSE); + else + xdrs->x_handy -= len; + + memcpy(xdrs->x_private, addr, len); + xdrs->x_private += len; + return (TRUE); } static u_int @@ -177,7 +185,7 @@ xdrmem_inline(xdrs, len) { afs_int32 *buf = 0; - if (xdrs->x_handy >= len) { + if (len >= 0 && xdrs->x_handy >= len) { xdrs->x_handy -= len; buf = (afs_int32 *) xdrs->x_private; xdrs->x_private += len; diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index c30c8360f..c5b1481f9 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -14,7 +14,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_server.c,v 1.1.1.10 2002/12/11 02:44:47 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/rxkad_server.c,v 1.1.1.11 2003/04/13 19:07:35 hartmans Exp $"); #include #include @@ -314,7 +314,7 @@ rxs_return_t rxkad_CheckResponse (aobj, aconn, apacket) kvno, client.name, client.instance, client.cell, &sessionkey, &host, &start, &end); - if (code) return RXKADBADTICKET; + if (code) return code; } /* diff --git a/src/rxkad/ticket.c b/src/rxkad/ticket.c index 7988b948d..3f6027bd3 100644 --- a/src/rxkad/ticket.c +++ b/src/rxkad/ticket.c @@ -14,7 +14,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket.c,v 1.1.1.7 2001/10/14 18:06:36 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket.c,v 1.1.1.8 2003/04/13 19:07:35 hartmans Exp $"); #if defined(UKERNEL) #include "../afs/sysincludes.h" @@ -65,6 +65,22 @@ static int assemble_athena_ticket(); interpreting the ticket and the values of the output parameters are undefined. */ +/* This union is used to insure we allocate enough space for a key + * schedule even if we are linked against a library that uses OpenSSL's + * larger representation. This is necessary so we don't lose if an + * application uses both rxkad and openssl. + */ +union Key_schedule_safe { + Key_schedule schedule; + struct { + union { + char cblock[8]; + long deslong[2]; + } ks; + int weak_key; + } openssl_schedule[16]; +}; + int tkt_DecodeTicket (asecret, ticketLen, key, name, inst, cell, sessionKey, host, start, end) char *asecret; @@ -79,7 +95,7 @@ int tkt_DecodeTicket (asecret, ticketLen, key, afs_int32 *end; { char clear_ticket[MAXKTCTICKETLEN]; char *ticket; - Key_schedule schedule; + union Key_schedule_safe schedule; /* unsigned char flags; */ int code; @@ -88,10 +104,10 @@ int tkt_DecodeTicket (asecret, ticketLen, key, ((ticketLen) % 8 != 0)) /* enc. part must be (0 mod 8) bytes */ return RXKADBADTICKET; - if (key_sched (key, schedule)) return RXKADBADKEY; + if (key_sched (key, schedule.schedule)) return RXKADBADKEY; ticket = clear_ticket; - pcbc_encrypt (asecret, ticket, ticketLen, schedule, key, DECRYPT); + pcbc_encrypt (asecret, ticket, ticketLen, schedule.schedule, key, DECRYPT); /* flags = *ticket; */ /* get the first byte: the flags */ #if 0 @@ -141,7 +157,7 @@ int tkt_MakeTicket (ticket, ticketLen, key, name, inst, cell, char *sname; /* server */ char *sinst; { int code; - Key_schedule schedule; + union Key_schedule_safe schedule; *ticketLen = 0; /* in case we return early */ code = assemble_athena_ticket (ticket, ticketLen, name, inst, cell, @@ -150,11 +166,11 @@ int tkt_MakeTicket (ticket, ticketLen, key, name, inst, cell, if (code) return -1; /* encrypt ticket */ - if (code = key_sched (key, schedule)) { + if (code = key_sched (key, schedule.schedule)) { printf ("In tkt_MakeTicket: key_sched returned %d\n", code); return RXKADBADKEY; } - pcbc_encrypt (ticket, ticket, *ticketLen, schedule, key, ENCRYPT); + pcbc_encrypt (ticket, ticket, *ticketLen, schedule.schedule, key, ENCRYPT); return 0; } diff --git a/src/rxkad/ticket5.c b/src/rxkad/ticket5.c index 03d6711fa..931477fe8 100644 --- a/src/rxkad/ticket5.c +++ b/src/rxkad/ticket5.c @@ -61,7 +61,7 @@ #include #endif -RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket5.c,v 1.2 2002/12/18 04:00:10 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/rxkad/ticket5.c,v 1.1.1.2 2003/04/13 19:07:35 hartmans Exp $"); #if defined(UKERNEL) #include "../afs/sysincludes.h" @@ -172,6 +172,14 @@ static const struct krb_convert sconv_list[] = { R("mandarin-agent"), R("write"), R("palladium"), + R("imap"), + R("smtp"), + R("lmtp"), + R("ldap"), + R("acap"), + R("argus"), + R("mupdate"), + R("argus"), {0, 0, 0, 0}, #undef R #undef RC @@ -228,10 +236,13 @@ int tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len, goto cleanup; } - /* Find the real service key version number */ - if (t5.enc_part.kvno == NULL) - goto bad_ticket; - v5_serv_kvno = *t5.enc_part.kvno; + /* If kvno is null, it's probably not included because it was kvno==0 + in the ticket */ + if (t5.enc_part.kvno == NULL ) { + v5_serv_kvno = 0; + } else { + v5_serv_kvno = *t5.enc_part.kvno; + } code = (*get_key)(get_key_rock, v5_serv_kvno, &serv_key); diff --git a/src/rxkad/v5der.c b/src/rxkad/v5der.c index f149d3079..25448f230 100644 --- a/src/rxkad/v5der.c +++ b/src/rxkad/v5der.c @@ -1,3 +1,4 @@ +#include #include "asn1_err.h" #include /* diff --git a/src/shlibafsrpc/Makefile.in b/src/shlibafsrpc/Makefile.in index 626a82458..8de760e9c 100644 --- a/src/shlibafsrpc/Makefile.in +++ b/src/shlibafsrpc/Makefile.in @@ -276,7 +276,7 @@ xdr_afsuuid.o: ${RX}/xdr_afsuuid.c # # $ what /opt/langtools/bin/pxdb32 # /opt/langtools/bin/pxdb32: -# HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.1.1.2 $ +# HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.1.1.3 $ # # The problem occurs when -g and -O are both used when compiling des.c. # The simplest way to work around the problem is to leave out either -g or -O. @@ -351,7 +351,7 @@ base64.o: ${UTIL}/base64.c syscall.o: ${SYS}/syscall.s case "$(SYS_NAME)" in \ - sun4x_5* | sunx86_5*) \ + sun*_5* ) \ /usr/ccs/lib/cpp ${SFLAGS} ${SYS}/syscall.s syscall.ss; \ as -o syscall.o syscall.ss; \ $(RM) syscall.ss;; \ diff --git a/src/shlibafsrpc/mapfile b/src/shlibafsrpc/mapfile index 87efe93aa..b152edf0c 100644 --- a/src/shlibafsrpc/mapfile +++ b/src/shlibafsrpc/mapfile @@ -14,6 +14,9 @@ des_key_sched; des_random_key; des_string_to_key; + des_cbc_cksum; + des_ecb_encrypt; + des_pcbc_encrypt; ktohl; life_to_time; rx_DestroyConnection; diff --git a/src/tviced/Makefile.in b/src/tviced/Makefile.in index eb3035824..3b624ad50 100644 --- a/src/tviced/Makefile.in +++ b/src/tviced/Makefile.in @@ -50,7 +50,7 @@ LWPOBJS=lock.o fasttime.o threadname.o LIBACLOBJS=aclprocs.o netprocs.o -UTILOBJS=assert.o uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o +UTILOBJS=assert.o uuid.o serverLog.o fileutil.o netutils.o dirpath.o volparse.o flipbase64.o softsig.o DIROBJS=buffer.o dir.o salvage.o @@ -107,6 +107,9 @@ netutils.o: ${UTIL}/netutils.c dirpath.o: ${UTIL}/dirpath.c ${COMPILE} +softsig.o: ${UTIL}/softsig.c + ${COMPILE} + lock.o: ${LWP}/lock.c ${COMPILE} diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c index 740befa2f..6aacd4d6b 100644 --- a/src/ubik/beacon.c +++ b/src/ubik/beacon.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/ubik/beacon.c,v 1.1.1.10 2001/10/14 18:06:44 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/ubik/beacon.c,v 1.1.1.11 2003/04/13 19:07:58 hartmans Exp $"); #include #ifdef AFS_NT40_ENV @@ -455,7 +455,8 @@ static verifyInterfaceAddress(ame, info, aservers) afs_uint32 aservers[]; /* list of all possible server addresses */ { afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr; - int count, found, i, j, totalServers, start, end; + afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR]; + int count, found, i, j, totalServers, start, end, usednetfiles = 0; if (info) totalServers = info->numServers; @@ -484,6 +485,7 @@ static verifyInterfaceAddress(ame, info, aservers) ubik_print("Aborting..\n"); return UBADHOST; } + usednetfiles++; } else { /* get all my interface addresses in net byte order */ @@ -511,7 +513,32 @@ static verifyInterfaceAddress(ame, info, aservers) { ubik_print("ubik: primary address %s does not exist\n", afs_inet_ntoa(*ame)); - return UBADHOST; + /* if we had the result of rx_getAllAddr already, avoid subverting + the "is gethostbyname(gethostname()) us" check. If we're + using NetInfo/NetRestrict, we assume they have enough clue + to avoid that big hole in their foot from the loaded gun. */ + if (usednetfiles) { + /* take the address we did get, then see if ame was masked */ + *ame=myAddr[0]; + count = rx_getAllAddr(myAddr2, UBIK_MAX_INTERFACE_ADDR); + if ( count <= 0 ) /* no address found */ + { + ubik_print("ubik: No network addresses found, aborting.."); + return UBADHOST; + } + + /* verify that the My-address passed in by ubik is correct */ + for ( j=0, found = 0; j < count; j++) + { + if ( *ame == myAddr2[j] ) /* both in net byte order */ + { + found = 1; + break; + } + } + } + if ( !found ) + return UBADHOST; } /* if any of my addresses are there in serverList, then diff --git a/src/util/assert.h b/src/util/assert.h index ec0933d5f..a8c2555a2 100644 --- a/src/util/assert.h +++ b/src/util/assert.h @@ -12,4 +12,4 @@ void AssertionFailed(char *file, int line); -# define assert(ex) {if (!(ex)) AssertionFailed(__FILE__, __LINE__);} +#define assert(ex) do{if (!(ex)) AssertionFailed(__FILE__, __LINE__);}while(0) diff --git a/src/util/pthread_nosigs.h b/src/util/pthread_nosigs.h index 8f84fc2cb..fe7477257 100644 --- a/src/util/pthread_nosigs.h +++ b/src/util/pthread_nosigs.h @@ -27,9 +27,45 @@ #else #define AFS_SET_SIGMASK pthread_sigmask #endif +#ifdef SIGSEGV +#define _SETSEGV sigdelset(&i_tset, SIGSEGV); +#else +#define _SETSEGV ; +#endif +#ifdef SIGBUS +#define _SETBUS sigdelset(&i_tset, SIGBUS); +#else +#define _SETBUS ; +#endif +#ifdef SIGILL +#define _SETILL sigdelset(&i_tset, SIGILL); +#else +#define _SETILL ; +#endif +#ifdef SIGTRAP +#define _SETTRAP sigdelset(&i_tset, SIGTRAP); +#else +#define _SETTRAP ; +#endif +#ifdef SIGABRT +#define _SETABRT sigdelset(&i_tset, SIGABRT); +#else +#define _SETABRT ; +#endif +#ifdef SIGFPE +#define _SETFPE sigdelset(&i_tset, SIGFPE); +#else +#define _SETFPE ; +#endif #define AFS_SIGSET_CLEAR() \ do { \ sigfillset(&i_tset); \ + _SETSEGV \ + _SETBUS \ + _SETILL \ + _SETTRAP \ + _SETABRT \ + _SETFPE \ assert(AFS_SET_SIGMASK(SIG_BLOCK, &i_tset, &i_oset) == 0); \ } while (0) diff --git a/src/util/secutil_nt.c b/src/util/secutil_nt.c index 7ce868aba..f512bcbd3 100644 --- a/src/util/secutil_nt.c +++ b/src/util/secutil_nt.c @@ -9,12 +9,12 @@ /* Security related utilities for the Windows platform */ -#include +#include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/util/secutil_nt.c,v 1.1.1.3 2001/07/11 03:11:48 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/util/secutil_nt.c,v 1.1.1.4 2003/04/13 19:08:06 hartmans Exp $"); -#include +#include #include #include diff --git a/src/venus/cmdebug.c b/src/venus/cmdebug.c index ccca38df7..8e07d8c4b 100644 --- a/src/venus/cmdebug.c +++ b/src/venus/cmdebug.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/venus/cmdebug.c,v 1.1.1.5 2001/09/11 14:35:22 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/venus/cmdebug.c,v 1.1.1.6 2003/04/13 19:08:08 hartmans Exp $"); #include @@ -89,12 +89,55 @@ register struct rx_connection *aconn; { return 0; } -static PrintCacheEntries(aconn, aint32) -int aint32; -register struct rx_connection *aconn; { +struct cell_cache { + afs_int32 cellnum; + char *cellname; + struct cell_cache *next; +}; + +static char *GetCellName(struct rx_connection *aconn, afs_int32 cellnum) +{ + static int no_getcellbynum; + static struct cell_cache *cache; + struct cell_cache *tcp; + int code; + char *cellname; + serverList sl; + + if (no_getcellbynum) + return NULL; + + for (tcp = cache; tcp; tcp = tcp->next) + if (tcp->cellnum == cellnum) + return tcp->cellname; + + cellname = NULL; + sl.serverList_len = 0; + sl.serverList_val = NULL; + code = RXAFSCB_GetCellByNum(aconn, cellnum, &cellname, &sl); + if (code) { + if (code == RXGEN_OPCODE) + no_getcellbynum = 1; + return NULL; + } + + if (sl.serverList_val) + free (sl.serverList_val); + tcp = malloc(sizeof(struct cell_cache)); + tcp->next = cache; + tcp->cellnum = cellnum; + tcp->cellname = cellname; + cache = tcp; + + return cellname; +} + +static PrintCacheEntries(struct rx_connection *aconn, int aint32) +{ register int i; register afs_int32 code; struct AFSDBCacheEntry centry; + char *cellname; for(i=0;i<10000;i++) { code = RXAFSCB_GetCE(aconn, i, ¢ry); @@ -115,8 +158,16 @@ register struct rx_connection *aconn; { if (!aint32 && !IsLocked(¢ry.lock)) continue; /* otherwise print this entry */ - printf("** Cache entry @ 0x%08x for %d.%d.%d.%d\n", centry.addr, centry.cell, - centry.netFid.Volume, centry.netFid.Vnode, centry.netFid.Unique); + printf("** Cache entry @ 0x%08x for %d.%d.%d.%d", centry.addr, + centry.cell, centry.netFid.Volume, centry.netFid.Vnode, + centry.netFid.Unique); + + cellname = GetCellName(aconn, centry.cell); + if (cellname) + printf(" [%s]\n", cellname); + else + printf("\n"); + if (IsLocked(¢ry.lock)) { printf(" locks: "); PrintLock(¢ry.lock); diff --git a/src/venus/test/owntest.c b/src/venus/test/owntest.c index 1a642eff5..ceb2486e8 100644 --- a/src/venus/test/owntest.c +++ b/src/venus/test/owntest.c @@ -10,12 +10,13 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/venus/test/owntest.c,v 1.1.1.4 2001/07/14 22:24:39 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/venus/test/owntest.c,v 1.1.1.5 2003/04/13 19:08:10 hartmans Exp $"); #include #include #include #include +#include extern int errno; @@ -35,11 +36,15 @@ char **argv; { pn = argv[1]; printf("Starting tests on %s.\n", pn); code = chmod(pn, 0444); - if (code<0) - return perror("chmod to RO"); + if (code<0) { + perror("chmod to RO"); + return 1; + } code = chmod(pn, 0666); - if (code<0) - return perror("chmod back to RW"); + if (code<0) { + perror("chmod back to RW"); + return 1; + } gettimeofday(&tv[0], (char *) 0); gettimeofday(&tv[1], (char *) 0); tv[0].tv_sec -= 10000; @@ -47,11 +52,15 @@ char **argv; { tv[1].tv_sec -= 20000; tv[1].tv_usec = 0; code = utimes(pn, tv); - if (code<0) - return perror("utimes"); + if (code<0) { + perror("utimes"); + return 1; + } code = stat(pn, &tstat); - if (code<0) - return perror("stat"); + if (code<0) { + perror("stat"); + return 1; + } if (tstat.st_mtime != tv[1].tv_sec) { printf("modtime didn't stick\n"); exit(1); diff --git a/src/vfsck/setup.c b/src/vfsck/setup.c index 890ab890f..7087665d5 100644 --- a/src/vfsck/setup.c +++ b/src/vfsck/setup.c @@ -18,7 +18,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vfsck/setup.c,v 1.1.1.6 2001/10/14 18:07:11 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vfsck/setup.c,v 1.1.1.7 2003/04/13 19:08:11 hartmans Exp $"); #include #define VICE @@ -673,7 +673,11 @@ readsb(listerr) return (1); } altsblock.fs_link = sblock.fs_link; +#ifdef STRUCT_FS_HAS_FS_ROLLED + altsblock.fs_rolled = sblock.fs_rolled; +#else altsblock.fs_rlink = sblock.fs_rlink; +#endif altsblock.fs_time = sblock.fs_time; altsblock.fs_cstotal = sblock.fs_cstotal; altsblock.fs_cgrotor = sblock.fs_cgrotor; diff --git a/src/viced/Makefile.in b/src/viced/Makefile.in index 287d9f2d1..b14a84256 100644 --- a/src/viced/Makefile.in +++ b/src/viced/Makefile.in @@ -107,7 +107,7 @@ cbd: cbd.o ${DEST}/root.server/usr/afs/bin/fileserver: fileserver @case ${SYS_NAME} in \ - alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun4x*) \ + alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun*) \ echo "Don't install fileserver for ${SYS_NAME}" ;; \ *) \ echo ${INSTALL} -ns $? $@ ; \ @@ -125,7 +125,7 @@ clean: include ../config/Makefile.version ${DESTDIR}${afssrvlibexecdir}/fileserver: fileserver @case ${SYS_NAME} in \ - alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun4x*) \ + alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun*) \ echo "Don't install fileserver for ${SYS_NAME}" ;; \ *) \ echo ${INSTALL} -ns $? $@ ; \ diff --git a/src/viced/callback.c b/src/viced/callback.c index 679166315..2bc8b5f4a 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -82,7 +82,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/viced/callback.c,v 1.1.1.10 2002/12/11 02:46:08 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/viced/callback.c,v 1.1.1.11 2003/04/13 19:08:13 hartmans Exp $"); #include #include /* for malloc() */ @@ -819,7 +819,7 @@ static void MultiBreakCallBack_r(cba, ncbas, afidp, xhost) ViceLog(7, ("BCB: Failed on file %u.%d.%d, host %x.%d is down\n", afidp->AFSCBFids_val->Volume, afidp->AFSCBFids_val->Vnode, - afidp->AFSCBFids_val->Unique, hp->host, hp->port)); + afidp->AFSCBFids_val->Unique, hp->host, ntohs(hp->port))); } H_LOCK @@ -872,7 +872,7 @@ BreakCallBack(xhost, fid, flag) int hostindex; ViceLog(7,("BCB: BreakCallBack(all but %x.%d, (%u,%d,%d))\n", - xhost->host, xhost->port, fid->Volume, fid->Vnode, + xhost->host, ntohs(xhost->port), fid->Volume, fid->Vnode, fid->Unique)); H_LOCK @@ -903,7 +903,7 @@ BreakCallBack(xhost, fid, flag) } else if (thishost->hostFlags & VENUSDOWN) { ViceLog(7,("BCB: %x.%d is down; delaying break call back\n", - thishost->host, thishost->port)); + thishost->host, ntohs(thishost->port))); cb->status = CB_DELAYED; } else { @@ -964,7 +964,7 @@ DeleteCallBack(host, fid) pcb = FindCBPtr(fe, host); if (!*pcb) { ViceLog(8,("DCB: No call back for host %x.%d, (%u, %d, %d)\n", - host->host, host->port, fid->Volume, fid->Vnode, fid->Unique)); + host->host, ntohs(host->port), fid->Volume, fid->Vnode, fid->Unique)); h_Unlock_r(host); H_UNLOCK return; @@ -1094,7 +1094,7 @@ int BreakDelayedCallBacks_r(host) if (ShowProblems) { ViceLog(0, ("CB: Call back connect back failed (in break delayed) for %x.%d\n", - host->host, host->port)); + host->host, ntohs(host->port))); } host->hostFlags |= VENUSDOWN; } @@ -1139,13 +1139,13 @@ int BreakDelayedCallBacks_r(host) if (ShowProblems) { ViceLog(0, ("CB: XCallBackBulk failed, host=%x.%d; callback list follows:\n", - host->host, host->port)); + host->host, ntohs(host->port))); } for (i = 0; ihost, host->port, + host->host, ntohs(host->port), fids[i].Volume, fids[i].Vnode, fids[i].Unique)); } /* used to do this: @@ -1196,10 +1196,10 @@ static int MultiBreakVolumeCallBack_r (host, isheld, parms) return 0; /* Release hold */ } ViceLog(8,("BVCB: volume call back for host %x.%d failed\n", - host->host,host->port)); + host->host,ntohs(host->port))); if (ShowProblems) { ViceLog(0, ("CB: volume callback for host %x.%d failed\n", - host->host, host->port)); + host->host, ntohs(host->port))); } DeleteAllCallBacks_r(host); /* Delete all callback state rather than attempting to selectively remember to @@ -1689,7 +1689,7 @@ main(argc, argv) } if (err || argc != 1) { fprintf(stderr, - "Usage: cbd [-host cbid] [-fid volume vnode] [-stats] callbackdumpfile\n"); + "Usage: cbd [-host cbid] [-fid volume vnode] [-stats] [-all] callbackdumpfile\n"); fprintf(stderr, "[cbid is shown for each host in the hosts.dump file]\n"); exit(1); } @@ -1812,7 +1812,9 @@ struct AFSCBFids* afidp; i = host->interface->numberOfInterfaces; addr = malloc(i * sizeof(afs_int32)); + if (!addr) return 1; conns = malloc(i * sizeof(struct rx_connection *)); + if (!conns) { free(addr); return 1; } /* initialize alternate rx connections */ for ( i=0,j=0; i < host->interface->numberOfInterfaces; i++) @@ -1897,7 +1899,9 @@ struct host* host; i = host->interface->numberOfInterfaces; addr = malloc(i * sizeof(afs_int32)); + if (!addr) return 1; conns = malloc(i * sizeof(struct rx_connection *)); + if (!conns) { free(addr); return 1; } /* initialize alternate rx connections */ for ( i=0,j=0; i < host->interface->numberOfInterfaces; i++) diff --git a/src/viced/host.c b/src/viced/host.c index 7f0babb25..cd64a6814 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/viced/host.c,v 1.1.1.12 2002/12/11 02:46:09 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/viced/host.c,v 1.1.1.13 2003/04/13 19:08:13 hartmans Exp $"); #include #include @@ -534,15 +534,15 @@ void h_flushhostcps(hostaddr, hport) register afs_uint32 hostaddr, hport; /* net byte order */ { register struct host *host; - int held; + int held = 0; H_LOCK host = h_Lookup_r(hostaddr, hport, &held); if (host) { - host->hcpsfailed = 1; + host->hcpsfailed = 1; + if (!held) + h_Release_r(host); } - if (!held) - h_Release_r(host); H_UNLOCK return; @@ -600,7 +600,7 @@ struct host *h_Alloc_r(r_con) if (serverentry) consolePort = serverentry->s_port; else - consolePort = DEF_ROPCONS; /* Use a default */ + consolePort = htons(DEF_ROPCONS); /* Use a default */ } if (host->port == consolePort) host->Console = 1; /* Make a callback channel even for the console, on the off chance that it @@ -622,6 +622,8 @@ struct host *h_Alloc_r(r_con) /*host->hcpsfailed = 0; /* save cycles */ /* h_gethostcps(host); do this under host lock */ host->FirstClient = 0; + h_Hold_r(host); + h_Lock_r(host); h_InsertList_r(host); /* update global host List */ #if FS_STATS_DETAILED /* @@ -966,8 +968,8 @@ struct host *h_GetHost_r(tcon) hport = rxr_PortOf(tcon); retry: code = 0; - identP = (struct Identity *)rx_GetSpecific(tcon, rxcon_ident_key); host = h_Lookup_r(haddr, hport, &held); + identP = (struct Identity *)rx_GetSpecific(tcon, rxcon_ident_key); if (host && !identP && !(host->Console&1)) { /* This is a new connection, and we already have a host * structure for this address. Verify that the identity @@ -980,7 +982,7 @@ retry: h_Unlock_r(host); if ( !held) h_Release_r(host); ViceLog(125, ("Host %s:%d starting h_Lookup again\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); goto retry; } host->hostFlags &= ~ALTADDR; @@ -998,7 +1000,7 @@ retry: if (host->interface) { ViceLog(0, ("Host %s:%d used to support WhoAreYou, deleting.\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); host->hostFlags |= HOSTDELETED; h_Unlock_r(host); if (!held) h_Release_r(host); @@ -1038,12 +1040,12 @@ retry: { /* another thread is doing the initialisation */ ViceLog(125, ("Host %s:%d waiting for host-init to complete\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); h_Lock_r(host); h_Unlock_r(host); if ( !held) h_Release_r(host); ViceLog(125, ("Host %s:%d starting h_Lookup again\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); goto retry; } /* We need to check whether the identity in the host structure @@ -1053,42 +1055,59 @@ retry: && ( ( !identP->valid && host->interface ) || ( identP->valid && !host->interface ) || ( identP->valid - && !afs_uuid_equal(&identP->uuid, &host->interface->uuid) ) ) ) { - /* The host in the cache is not the host for this connection */ - host->hostFlags |= HOSTDELETED; - h_Unlock_r(host); - if (!held) h_Release_r(host); - ViceLog(0, ("CB: new identity for host %s:%d, deleting\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); - goto retry; + && !afs_uuid_equal(&identP->uuid, &host->interface->uuid) ) ) ) + { + char uuid1[128], uuid2[128]; + if (identP->valid) + afsUUID_to_string(identP->uuid, uuid1, 127); + if (host->interface) + afsUUID_to_string(host->interface->uuid, uuid2, 127); + ViceLog(0, + ("CB: new identity for host %s:%d, deleting(%x %x %s %s)\n", + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), + identP->valid, host->interface, identP->valid ? uuid1 : + "", host->interface ? uuid2 : "")); + + /* The host in the cache is not the host for this connection */ + host->hostFlags |= HOSTDELETED; + h_Unlock_r(host); + if (!held) h_Release_r(host); + goto retry; } } else { host = h_Alloc_r(tcon); - h_Hold_r(host); - h_Lock_r(host); h_gethostcps_r(host,FT_ApproxTime()); if (!(host->Console&1)) { - if (!identP || !interfValid) { - H_UNLOCK - code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); - H_LOCK - if ( code == RXGEN_OPCODE ) { - identP = (struct Identity *)malloc(sizeof(struct Identity)); - identP->valid = 0; + int pident = 0; + H_UNLOCK + code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf); + H_LOCK + if ( code == RXGEN_OPCODE ) { + if (!identP) + identP = (struct Identity *)malloc(sizeof(struct Identity)); + else + pident = 1; + identP->valid = 0; + if (!pident) rx_SetSpecific(tcon, rxcon_ident_key, identP); - ViceLog(25, - ("Host %s:%d does not support WhoAreYou.\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); - code = 0; - } else if (code == 0) { - interfValid = 1; + ViceLog(25, + ("Host %s:%d does not support WhoAreYou.\n", + afs_inet_ntoa_r(host->host, hoststr), + ntohs(host->port))); + code = 0; + } else if (code == 0) { + if (!identP) identP = (struct Identity *)malloc(sizeof(struct Identity)); - identP->valid = 1; - identP->uuid = interf.uuid; + else + pident = 1; + identP->valid = 1; + interfValid = 1; + identP->uuid = interf.uuid; + if (!pident) rx_SetSpecific(tcon, rxcon_ident_key, identP); - ViceLog(25, ("WhoAreYou success on %s:%d\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); - } + ViceLog(25, ("WhoAreYou success on %s:%d\n", + afs_inet_ntoa_r(host->host, hoststr), + ntohs(host->port))); } if (code == 0 && !identP->valid) { H_UNLOCK @@ -1104,8 +1123,8 @@ retry: h_Hold_r(oldHost); h_Lock_r(oldHost); ViceLog(25, ("CB: new addr %s:%d for old host %s:%d\n", - afs_inet_ntoa_r(host->host, hoststr), host->port, - afs_inet_ntoa_r(oldHost->host, hoststr2), oldHost->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), + afs_inet_ntoa_r(oldHost->host, hoststr2), ntohs(oldHost->port))); host->hostFlags |= HOSTDELETED; h_Unlock_r(host); h_Release_r(host); @@ -1120,7 +1139,7 @@ retry: H_LOCK if (code == 0) { ViceLog(25, ("InitCallBackState3 success on %s:%d\n", - afs_inet_ntoa_r(host->host, hoststr), host->port)); + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); assert(interfValid == 1); initInterfaceAddr_r(host, &interf); } @@ -1413,7 +1432,7 @@ ticket name length != 64 ViceLog(0, ("pr_GetCPS failed(%d) for user %d, host %s:%d\n", code, viceid, afs_inet_ntoa_r(client->host->host, hoststr), - client->host->port)); + ntohs(client->host->port))); /* Although ubik_Call (called by pr_GetCPS) traverses thru * all protection servers and reevaluates things if no @@ -1482,15 +1501,35 @@ int GetClient(tcon, cp) H_LOCK *cp = client = (struct client *) rx_GetSpecific(tcon, rxcon_client_key); - /* XXXX debug */ - assert(client && client->tcon && rxr_CidOf(client->tcon) == client->sid); + if (client == NULL || client->tcon == NULL) { + ViceLog(0, ("GetClient: no client in conn %x (host %x), VBUSYING\n", + tcon, rx_HostOf(rx_PeerOf(tcon)))); + H_UNLOCK + return VBUSY; + } + if (rxr_CidOf(client->tcon) != client->sid) { + ViceLog(0, ("GetClient: tcon %x tcon sid %d client sid %d\n", + client->tcon, rxr_CidOf(client->tcon), + client->sid)); + H_UNLOCK + return VBUSY; + } + if (!(client && client->tcon && rxr_CidOf(client->tcon) == client->sid)) { + if (!client) + ViceLog(0, ("GetClient: no client in conn %x\n", tcon)); + else + ViceLog(0, ("GetClient: tcon %x tcon sid %d client sid %d\n", + client->tcon, client->tcon ? rxr_CidOf(client->tcon) + : -1, client->sid)); + assert(0); + } if (client && client->LastCall > client->expTime && client->expTime) { char hoststr[16]; ViceLog(1, ("Token for %s at %s:%d expired %d\n", h_UserName(client), afs_inet_ntoa_r(client->host->host, hoststr), - client->host->port, client->expTime)); + ntohs(client->host->port), client->expTime)); H_UNLOCK return VICETOKENDEAD; } @@ -1555,7 +1594,7 @@ static int h_PrintClient(host, held, file) return held; } sprintf(tmpStr,"Host %s:%d down = %d, LastCall %s", - afs_inet_ntoa_r(host->host, hoststr), host->port, + afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port), (host->hostFlags & VENUSDOWN), afs_ctime((time_t *)&host->LastCall, tbuffer, sizeof(tbuffer))); STREAM_WRITE(tmpStr, strlen(tmpStr), 1, file); @@ -1634,7 +1673,7 @@ static int h_DumpHost(host, held, file) H_LOCK sprintf(tmpStr, "ip:%x port:%d hidx:%d cbid:%d lock:%x last:%u active:%u down:%d del:%d cons:%d cldel:%d\n\t hpfailed:%d hcpsCall:%u hcps [", - host->host, host->port, host->index, host->cblist, + host->host, ntohs(host->port), host->index, host->cblist, CheckLock(&host->lock), host->LastCall, host->ActiveCall, (host->hostFlags & VENUSDOWN), host->hostFlags&HOSTDELETED, host->Console, host->hostFlags & CLIENTDELETED, @@ -2057,7 +2096,7 @@ struct interfaceAddr *interf; { int i, j; int number, count; - afs_int32 myPort, myHost; + afs_int32 myHost; int found; struct Interface *interface; @@ -2068,7 +2107,6 @@ struct interfaceAddr *interf; host->host, interf->numberOfInterfaces)); number = interf->numberOfInterfaces; - myPort = host->port; myHost = host->host; /* current interface address */ /* validation checks */ diff --git a/src/viced/viced.c b/src/viced/viced.c index 6fe2ad434..f34308035 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -19,7 +19,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/viced/viced.c,v 1.1.1.9 2002/09/26 19:09:16 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/viced/viced.c,v 1.1.1.10 2003/04/13 19:08:14 hartmans Exp $"); #include #include @@ -76,6 +76,11 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/viced/viced.c,v 1.1.1.9 2002/09/26 19:0 #endif #include "viced.h" #include "host.h" +#ifndef AFS_NT40_ENV +#ifdef AFS_PTHREAD_ENV +#include "softsig.h" +#endif +#endif #if defined(AFS_SGI_ENV) #include "sys/schedctl.h" #include "sys/lock.h" @@ -128,6 +133,7 @@ struct afs_PerfStats afs_perfstats; extern int LogLevel; extern int Statistics; +int busyonrst = 1; int timeout = 30; int SawSpare; int SawPctSpare; @@ -219,22 +225,32 @@ int fs_rxstat_userok(call) static void ResetCheckSignal(void) { -#ifdef AFS_HPUX_ENV - signal(SIGPOLL, CheckSignal_Signal); -#else -#ifdef AFS_NT40_ENV - signal(SIGUSR2, CheckSignal_Signal); + int signo; + +#if defined(AFS_HPUX_ENV) + signo = SIGPOLL; +#elif defined(AFS_NT40_ENV) + signo = SIGUSR2; #else - signal(SIGXCPU, CheckSignal_Signal); + signo = SIGXCPU; #endif + +#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV) + softsig_signal(signo, CheckSignal_Signal); +#else + signal(signo, CheckSignal_Signal); #endif } static void ResetCheckDescriptors(void) { #ifndef AFS_NT40_ENV +#if defined(AFS_PTHREAD_ENV) + softsig_signal(SIGTERM, CheckDescriptors_Signal); +#else signal(SIGTERM, CheckDescriptors_Signal); #endif +#endif } @@ -299,7 +315,6 @@ main(argc, argv) #ifdef AFS_PTHREAD_ENV pthread_t parentPid, serverPid; pthread_attr_t tattr; - AFS_SIGSET_DECL; #else /* AFS_PTHREAD_ENV */ PROCESS parentPid, serverPid; #endif /* AFS_PTHREAD_ENV */ @@ -372,6 +387,11 @@ main(argc, argv) ViceLog(0, ("File server starting\n")); #endif +#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV) + /* initialize the pthread soft signal handler thread */ + softsig_init(); +#endif + /* install signal handlers for controlling the fileserver process */ ResetCheckSignal(); /* set CheckSignal_Signal() sig handler */ ResetCheckDescriptors(); /* set CheckDescriptors_Signal() sig handler */ @@ -571,11 +591,9 @@ main(argc, argv) #ifdef AFS_PTHREAD_ENV assert(pthread_attr_init(&tattr) == 0); assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); - /* Block signals in the threads */ - AFS_SIGSET_CLEAR(); + assert(pthread_create(&serverPid, &tattr, (void *)FiveMinuteCheckLWP, &fiveminutes) == 0); assert(pthread_create(&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0); - AFS_SIGSET_RESTORE(); #else /* AFS_PTHREAD_ENV */ assert(LWP_CreateProcess(FiveMinuteCheckLWP, stack*1024, LWP_MAX_PRIORITY - 2, &fiveminutes, "FiveMinuteChecks", &serverPid) == LWP_SUCCESS); @@ -617,8 +635,14 @@ main(argc, argv) FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO)); } - /* Install handler to catch the shutdown signal */ - signal(SIGQUIT, ShutDown_Signal); /* bosserver assumes SIGQUIT shutdown */ + /* Install handler to catch the shutdown signal; + * bosserver assumes SIGQUIT shutdown + */ +#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV) + softsig_signal(SIGQUIT, ShutDown_Signal); +#else + signal(SIGQUIT, ShutDown_Signal); +#endif ViceLog(0,("File Server started %s", afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer)))); @@ -635,6 +659,18 @@ main(argc, argv) } +static void setThreadId(char *s) +{ +#ifdef AFS_PTHREAD_ENV + /* set our 'thread-id' so that the host hold table works */ + MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */ + ++rxi_pthread_hinum; + pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum); + MUTEX_EXIT(&rx_stats_mutex); + ViceLog(0,("Set thread id %d for '%s'\n", pthread_getspecific(rx_thread_id_key), s)); +#endif +} + /* This LWP does things roughly every 5 minutes */ static FiveMinuteCheckLWP() @@ -643,6 +679,7 @@ static FiveMinuteCheckLWP() char tbuffer[32]; ViceLog(1, ("Starting five minute check process\n")); + setThreadId("FiveMinuteCheckLWP"); while (1) { #ifdef AFS_PTHREAD_ENV sleep(fiveminutes); @@ -681,6 +718,7 @@ static HostCheckLWP() { ViceLog(1, ("Starting Host check process\n")); + setThreadId("HostCheckLWP"); while(1) { #ifdef AFS_PTHREAD_ENV sleep(fiveminutes); @@ -923,6 +961,7 @@ static FlagMsg() strcat(buffer, "[-implicit ] "); strcat(buffer, "[-hr ] "); strcat(buffer, "[-busyat n>] "); + strcat(buffer, "[-nobusy ] "); strcat(buffer, "[-rxpck ] "); strcat(buffer, "[-rxdbg (enable rx debugging)] "); strcat(buffer, "[-rxdbge (enable rxevent debugging)] "); @@ -1152,7 +1191,10 @@ static ParseArgs(argc, argv) busy_threshold); Sawbusy = 0; } - } + } + else + if (!strcmp(argv[i], "-nobusy")) + busyonrst=0; #ifdef AFS_AIX32_ENV else if (!strcmp(argv[i], "-m")) { diff --git a/src/viced/viced.h b/src/viced/viced.h index 4109c8147..8a5b51af0 100644 --- a/src/viced/viced.h +++ b/src/viced/viced.h @@ -189,6 +189,8 @@ struct AFSStatistics struct AFSDisk Disks[AFS_MSTATDISKS]; }; +extern int busyonrst; + #define RESTART_ORDINARY 1 #define RESTART_FAST 2 #define RESTART_SAFE 3 diff --git a/src/vol/clone.c b/src/vol/clone.c index 68155fd72..17bc7551b 100644 --- a/src/vol/clone.c +++ b/src/vol/clone.c @@ -18,7 +18,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/clone.c,v 1.1.1.7 2001/10/14 18:07:21 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/clone.c,v 1.1.1.8 2003/04/13 19:08:16 hartmans Exp $"); #include #include @@ -230,8 +230,13 @@ afs_int32 DoCloneIndex(rwvp, clvp, class, reclone) if (clinode && (clinode == rwinode)) { clinode = 0; /* already cloned - don't delete later */ } else if (rwinode) { - assert(IH_INC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) != -1); - inodeinced = 1; + if (IH_INC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) == -1) { + Log("IH_INC failed: %x, %s, %d errno %d\n", + V_linkHandle(rwvp), PrintInode(NULL, rwinode), + V_parentId(rwvp), errno); + assert(0); + } + inodeinced = 1; } /* If a directory, mark vnode in old volume as cloned */ @@ -273,7 +278,12 @@ afs_int32 DoCloneIndex(rwvp, clvp, class, reclone) clonefailed: /* Couldn't clone, go back and decrement the inode's link count */ if (inodeinced) { - assert(IH_DEC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) != -1); + if (IH_DEC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) == -1) { + Log("IH_DEC failed: %x, %s, %d errno %d\n", + V_linkHandle(rwvp), PrintInode(NULL, rwinode), + V_parentId(rwvp), errno); + assert(0); + } } /* And if the directory was marked clone, unmark it */ if (dircloned) { diff --git a/src/vol/fssync.c b/src/vol/fssync.c index 6d8b422ca..76d8b1e4b 100644 --- a/src/vol/fssync.c +++ b/src/vol/fssync.c @@ -38,7 +38,7 @@ static int newVLDB = 1; #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/fssync.c,v 1.1.1.8 2002/12/11 02:46:15 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/fssync.c,v 1.1.1.9 2003/04/13 19:08:17 hartmans Exp $"); #include #include @@ -252,10 +252,23 @@ static void FSYNC_sync() { extern VInit; int code; int numTries; +#ifdef AFS_PTHREAD_ENV + int tid; +#endif #ifndef AFS_NT40_ENV signal(SIGPIPE, SIG_IGN); #endif + +#ifdef AFS_PTHREAD_ENV + /* set our 'thread-id' so that the host hold table works */ + MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */ + tid=++rxi_pthread_hinum; + MUTEX_EXIT(&rx_stats_mutex); + pthread_setspecific(rx_thread_id_key, (void *)tid); + Log("Set thread id %d for FSYNC_sync\n", tid); +#endif /* AFS_PTHREAD_ENV */ + while (!VInit) { /* Let somebody else run until level > 0. That doesn't mean that * all volumes have been attached. */ diff --git a/src/vol/nuke.c b/src/vol/nuke.c index 15454c993..3a417d3a7 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/nuke.c,v 1.1.1.5 2001/09/11 14:35:44 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/nuke.c,v 1.1.1.6 2003/04/13 19:08:18 hartmans Exp $"); #include #include @@ -204,11 +204,11 @@ afs_int32 avolid; { * volume's ID in its inode, and has to be removed explicitly. */ /* reuse devName buffer now */ -#ifdef AFS_NAMEI_ENV +#ifdef AFS_NT40_ENV sprintf(devName, "%c:\\%s", *lastDevComp , VolumeExternalName(avolid)); #else sprintf(devName, "%s/%s", aname, VolumeExternalName(avolid)); -#endif /* AFS_NAMEI_ENV */ +#endif /* AFS_NT40_ENV */ code = unlink(devName); if (code) code = errno; } diff --git a/src/vol/vnode.c b/src/vol/vnode.c index bc1913bba..79af3f990 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -16,7 +16,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/vnode.c,v 1.1.1.7 2001/10/14 18:07:24 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/vnode.c,v 1.1.1.8 2003/04/13 19:08:18 hartmans Exp $"); #include #include @@ -55,7 +55,7 @@ RCSID("$Header: /tmp/cvstemp/openafs/src/vol/vnode.c,v 1.1.1.7 2001/10/14 18:07: #include #endif /* AFS_NT40_ENV */ #include - +#include struct VnodeClassInfo VnodeClassInfo[nVNODECLASSES]; @@ -634,7 +634,7 @@ Vnode *VGetVnode_r(ec,vp,vnodeNumber,locktype) /* Check that the vnode hasn't been removed while we were obtaining the lock */ VNLog(102, 2, vnodeNumber, (afs_int32) vnp); - if (vnp->disk.type == vNull) { + if ((vnp->disk.type == vNull) || (vnp->cacheCheck == 0)){ if (vnp->nUsers-- == 1) StickOnLruChain_r(vnp,vcp); if (locktype == READ_LOCK) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index a8e24f1c2..d679720a4 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -91,7 +91,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted. #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/vol-salvage.c,v 1.1.1.11 2002/09/26 19:09:26 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/vol-salvage.c,v 1.1.1.12 2003/04/13 19:08:19 hartmans Exp $"); #include #include @@ -1114,7 +1114,7 @@ char *wpath, *pbuffer; void SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber) { char *name, *tdir; - char inodeListPath[50]; + char inodeListPath[256]; static char tmpDevName[100]; static char wpath[100]; struct VolumeSummary *vsp, *esp; @@ -1180,9 +1180,9 @@ void SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber) tdir = (tmpdir ? tmpdir : fileSysPath); #ifdef AFS_NT40_ENV (void) _putenv("TMP="); /* If "TMP" is set, then that overrides tdir. */ - (void) strcpy(inodeListPath, _tempnam(tdir, "salvage.inodes.")); + (void) strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255); #else - sprintf(inodeListPath, "%s/salvage.inodes.%s.%d", tdir, name, getpid()); + snprintf(inodeListPath, 255, "%s/salvage.inodes.%s.%d", tdir, name, getpid()); #endif if (GetInodeSummary(inodeListPath, singleVolumeNumber) < 0) { unlink(inodeListPath); @@ -1797,8 +1797,8 @@ void DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols) allInodes = inodes - isp->index; /* this would the base of all the inodes for the partition, if all the inodes had been read into memory */ - assert(lseek(inodeFd,isp->index*sizeof(struct ViceInodeInfo),SEEK_SET) != -1) - assert(read(inodeFd,inodes,size) == size) + assert(lseek(inodeFd,isp->index*sizeof(struct ViceInodeInfo),SEEK_SET) != -1); + assert(read(inodeFd,inodes,size) == size); /* Don't try to salvage a read write volume if there isn't one on this partition */ @@ -2074,7 +2074,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp, isp->volumeId, (Testing?"it would have been ":""), fileSysPathName, name); headerFd = open(name, O_RDWR|O_CREAT|O_TRUNC, 0644); - assert(headerFd != -1) + assert(headerFd != -1); isp->volSummary = (struct VolumeSummary *) malloc(sizeof(struct VolumeSummary)); isp->volSummary->fileName = ToString(name); @@ -2100,7 +2100,7 @@ int SalvageVolumeHeaderFile(register struct InodeSummary *isp, return -1; headerFd = open(name, O_RDWR|O_TRUNC, 0644); - assert(headerFd != -1) + assert(headerFd != -1); } } if (headerFd) { @@ -2307,14 +2307,14 @@ int SalvageIndex(Inode ino, VnodeClass class, int RW, fdP = IH_OPEN(handle); assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); - assert(file != NULL) + assert(file != NULL); vcp = &VnodeClassInfo[class]; size = OS_SIZE(fdP->fd_fd); assert(size != -1); nVnodes = (size / vcp->diskSize) - 1; if (nVnodes > 0) { - assert((nVnodes+1) * vcp->diskSize == size) - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0) + assert((nVnodes+1) * vcp->diskSize == size); + assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); } else { nVnodes = 0; @@ -2699,12 +2699,13 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber, } if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0) + assert(Delete(&dir->dirHandle, name) == 0); } return; } #ifdef AFS_AIX_ENV +#ifndef AFS_NAMEI_ENV /* On AIX machines, don't allow entries to point to inode 0. That is a special * mount inode for the partition. If this inode were deleted, it would crash * the machine. @@ -2720,6 +2721,7 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber, } return; } +#endif #endif if (!(vnodeNumber & 1) && !Showmode && @@ -2765,9 +2767,9 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber, fid.Vnode = vnodeNumber; fid.Unique = vnodeEssence->unique; CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0) + assert(Delete(&dir->dirHandle, name) == 0); if (!todelete) - assert(Create(&dir->dirHandle, name, &fid) == 0) + assert(Create(&dir->dirHandle, name, &fid) == 0); } if (todelete) return; /* no need to continue */ } @@ -2779,10 +2781,10 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber, dir->vnodeNumber, dir->unique, vnodeNumber, unique); if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, ".") == 0) + assert(Delete(&dir->dirHandle, ".") == 0); fid.Vnode = dir->vnodeNumber; fid.Unique = dir->unique; - assert(Create(&dir->dirHandle, ".", &fid) == 0) + assert(Create(&dir->dirHandle, ".", &fid) == 0); } vnodeNumber = fid.Vnode; /* Get the new Essence */ @@ -2825,7 +2827,7 @@ void JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber, } if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0) + assert(Delete(&dir->dirHandle, name) == 0); } vnodeEssence->claimed = 0; /* Not claimed: Orphaned */ vnodeEssence->todelete = 1; /* Will later delete vnode and decr inode */ @@ -2931,20 +2933,20 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino, IH_INIT(vip->handle, fileSysDevice, rwVId, ino); fdP = IH_OPEN(vip->handle); - assert(fdP != NULL) + assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); assert(file != NULL); size = OS_SIZE(fdP->fd_fd); assert(size != -1); vip->nVnodes = (size / vcp->diskSize) - 1; if (vip->nVnodes > 0) { - assert((vip->nVnodes+1)*vcp->diskSize == size) - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0) + assert((vip->nVnodes+1)*vcp->diskSize == size); + assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); assert((vip->vnodes = (struct VnodeEssence *) - calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL) + calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL); if (class == vLarge) { assert((vip->inodes = (Inode *) - calloc(vip->nVnodes, sizeof (Inode))) != NULL) + calloc(vip->nVnodes, sizeof (Inode))) != NULL); } else { vip->inodes = NULL; @@ -2976,7 +2978,7 @@ void DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino, vep->owner = vnode->owner; vep->group = vnode->group; if (vnode->type == vDirectory) { - assert(class == vLarge) + assert(class == vLarge); vip->inodes[vnodeIndex] = VNDISK_GET_INO(vnode); } } @@ -3380,7 +3382,7 @@ void ClearROInUseBit(struct VolumeSummary *summary) nBytes = IH_IREAD(h, 0, (char*)&volHeader, sizeof(volHeader)); assert(nBytes == sizeof(volHeader)); - assert(volHeader.stamp.magic == VOLUMEINFOMAGIC) + assert(volHeader.stamp.magic == VOLUMEINFOMAGIC); volHeader.inUse = 0; volHeader.needsSalvaged = 0; volHeader.inService = 1; @@ -3514,7 +3516,7 @@ int Fork(void) { assert(0); /* Fork is never executed in the NT code path */ #else f = fork(); - assert(f >= 0) + assert(f >= 0); #endif return f; } @@ -3538,7 +3540,7 @@ int Wait(char *prog) int status; int pid; pid = wait(&status); - assert(pid != -1) + assert(pid != -1); if (WCOREDUMP(status)) Log("\"%s\" core dumped!\n", prog); if (WIFSIGNALED(status) != 0 || WEXITSTATUS(status) != 0) @@ -3655,7 +3657,7 @@ char * ToString(char *s) { register char *p; p = (char *) malloc(strlen(s)+1); - assert(p != NULL) + assert(p != NULL); strcpy(p,s); return p; diff --git a/src/vol/volume.c b/src/vol/volume.c index bde41248e..d4520dd69 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -19,7 +19,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/vol/volume.c,v 1.1.1.13 2002/12/11 02:46:19 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/vol/volume.c,v 1.1.1.14 2003/04/13 19:08:20 hartmans Exp $"); #include #include @@ -699,6 +699,9 @@ private Volume *attach2(ec, path, header, partp, isbusy) IH_INIT(vp->linkHandle, partp->device, header->parent, header->linkTable); vp->cacheCheck = ++VolumeCacheCheck; + /* just in case this ever rolls over */ + if (!vp->cacheCheck) + vp->cacheCheck = ++VolumeCacheCheck; vp->shuttingDown = 0; vp->goingOffline = 0; vp->nUsers = 1; diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 3cbab6026..e691852c3 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -10,7 +10,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/volser/dumpstuff.c,v 1.1.1.8 2001/10/14 18:07:28 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/volser/dumpstuff.c,v 1.1.1.9 2003/04/13 19:08:21 hartmans Exp $"); #include #include @@ -75,7 +75,7 @@ static int DumpPartial(register struct iod *iodp, register Volume *vp, static int DumpVnodeIndex(register struct iod *iodp, Volume *vp, VnodeClass class, afs_int32 fromtime, int forcedump); static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, - int vnodeNumber, int dumpEverything); + int volid, int vnodeNumber, int dumpEverything); static int ReadDumpHeader(register struct iod *iodp, struct DumpHeader *hp); static int ReadVnodes(register struct iod *iodp, Volume *vp, int incremental, afs_int32 *Lbuf, afs_int32 s1, @@ -649,8 +649,8 @@ static int DumpVnodeIndex(register struct iod *iodp, Volume *vp, assert(size != -1); nVnodes = (size / vcp->diskSize) - 1; if (nVnodes > 0) { - assert((nVnodes+1)*vcp->diskSize == size) - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0) + assert((nVnodes+1)*vcp->diskSize == size); + assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); } else nVnodes = 0; for (vnodeIndex = 0; nVnodes && STREAM_READ(vnode, vcp->diskSize, 1, file) == 1 && !code; @@ -659,7 +659,7 @@ static int DumpVnodeIndex(register struct iod *iodp, Volume *vp, /* Note: the >= test is very important since some old volumes may not have a serverModifyTime. For an epoch dump, this results in 0>=0 test, which does dump the file! */ - if (!code) code = DumpVnode(iodp, vnode, bitNumberToVnodeNumber(vnodeIndex, class), flag); + if (!code) code = DumpVnode(iodp, vnode, V_id(vp), bitNumberToVnodeNumber(vnodeIndex, class), flag); if (!flag) IOMGR_Poll(); /* if we dont' xfr data, but scan instead, could lose conn */ } STREAM_CLOSE(file); @@ -686,7 +686,7 @@ static int DumpDumpHeader(register struct iod *iodp, register Volume *vp, } static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, - int vnodeNumber, int dumpEverything) + int volid, int vnodeNumber, int dumpEverything) { int code = 0; IHandle_t *ihP; @@ -715,8 +715,8 @@ static int DumpVnode(register struct iod *iodp, struct VnodeDiskObject *v, IH_INIT(ihP, iodp->device, iodp->parentId, VNDISK_GET_INO(v)); fdP = IH_OPEN(ihP); if (fdP == NULL) { - Log("1 Volser: DumpVnode: dump: Unable to open inode %d for vnode %d; not dumped, error %d\n", - VNDISK_GET_INO(v), vnodeNumber, errno); + Log("1 Volser: DumpVnode: dump: Unable to open inode %d for vnode %d (volume %d); not dumped, error %d\n", + VNDISK_GET_INO(v), vnodeNumber, volid, errno); IH_RELEASE(ihP); return VOLSERREAD_DUMPERROR; } @@ -780,7 +780,7 @@ int ProcessIndex(Volume *vp, VnodeClass class, afs_int32 **Bufp, int *sizep, OS_SYNC(afile->str_fd); } else { size = OS_SIZE(fdP->fd_fd); - assert(size != -1) + assert(size != -1); nVnodes = (size <= vcp->diskSize ? 0 : size-vcp->diskSize) >> vcp->logSize; if (nVnodes > 0) { diff --git a/src/xstat/xstat_fs_callback.c b/src/xstat/xstat_fs_callback.c index 76ab9fde9..117168314 100644 --- a/src/xstat/xstat_fs_callback.c +++ b/src/xstat/xstat_fs_callback.c @@ -25,7 +25,7 @@ #include #include -RCSID("$Header: /tmp/cvstemp/openafs/src/xstat/xstat_fs_callback.c,v 1.1.1.5 2002/05/11 00:04:10 hartmans Exp $"); +RCSID("$Header: /tmp/cvstemp/openafs/src/xstat/xstat_fs_callback.c,v 1.1.1.6 2003/04/13 19:08:27 hartmans Exp $"); #include #include /*Standard I/O stuff*/ @@ -652,6 +652,16 @@ int SRXAFSCB_GetCellServDB( } +afs_int32 SRXAFSCB_GetCellByNum( + struct rx_call *a_call, + afs_int32 a_cellnum, + char **a_name, + serverList *a_hosts) +{ + return RXGEN_OPCODE; +} + + /*------------------------------------------------------------------------ * EXPORTED SRXAFSCB_GetLocalCell *