From 785121754056aa5acf4d71f4c0718e6d49a91dd3 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 26 Sep 2006 22:47:36 +0000 Subject: [PATCH] Merge with upstream 1.4.2fc4 release. --- acinclude.m4 | 10 +- configure | 25 ++-- configure-libafs | 25 ++-- configure-libafs.in | 2 +- configure.in | 2 +- debian/changelog | 6 + debian/rules | 4 +- doc/txt/winnotes/afs-changes-since-1.2.txt | 17 +++ regen.sh | 4 + src/afs/LINUX/osi_groups.c | 70 ++++++++-- src/afs/LINUX/osi_machdep.h | 62 +++++++++ src/afs/LINUX/osi_module.c | 4 +- src/afs/afs_osi.h | 2 +- src/afs/sysincludes.h | 3 + src/auth/cellconfig.c | 144 ++++++++++++++++++--- src/cf/linux-test4.m4 | 6 +- src/config/NTMakefile.amd64_w2k | 2 +- src/config/NTMakefile.i386_nt40 | 2 +- src/config/NTMakefile.i386_w2k | 2 +- src/config/afsconfig.h.in | 6 + src/kauth/authclient.c | 3 +- src/libafs/afs.ppc_darwin_70.plist.in | 4 +- src/libafs/afs.ppc_darwin_80.plist.in | 4 +- src/libafs/afs.ppc_darwin_90.plist.in | 4 +- src/libafs/afs.x86_darwin_80.plist.in | 4 +- src/libafs/afs.x86_darwin_90.plist.in | 4 +- src/ptserver/ptuser.c | 14 +- src/rx/DARWIN/rx_knet.c | 4 +- src/rx/rx_kcommon.c | 12 +- src/rx/rx_prototypes.h | 10 +- src/ubik/uinit.c | 4 +- src/viced/afsfileprocs.c | 17 ++- src/viced/host.c | 29 ++--- src/viced/viced.c | 5 +- src/vol/listinodes.c | 4 +- src/vol/namei_ops.c | 114 ++++++++++------ src/vol/namei_ops.h | 1 + src/vol/ntops.c | 53 ++++++-- src/vol/ntops.h | 2 + src/vol/nuke.c | 16 +-- src/vol/vol-salvage.c | 22 +++- src/volser/volmain.c | 3 +- 42 files changed, 551 insertions(+), 180 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 3eaeee37a..5485607a9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -113,7 +113,10 @@ case $system in if test "x$with_linux_kernel_headers" != "x"; then LINUX_KERNEL_PATH="$with_linux_kernel_headers" else - LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/source" + if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + fi if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then LINUX_KERNEL_PATH="/usr/src/linux-2.4" fi @@ -702,6 +705,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) if test "x$ac_cv_linux_fs_struct_inode_has_i_alloc_sem" = "xyes"; then AC_DEFINE(STRUCT_INODE_HAS_I_ALLOC_SEM, 1, [define if your struct inode has alloc_sem]) fi + if test "x$ac_cv_linux_fs_struct_inode_has_i_blksize" = "xyes"; then + AC_DEFINE(STRUCT_INODE_HAS_I_BLKSIZE, 1, [define if your struct inode has i_blksize]) + fi if test "x$ac_cv_linux_fs_struct_inode_has_i_devices" = "xyes"; then AC_DEFINE(STRUCT_INODE_HAS_I_DEVICES, 1, [define if you struct inode has i_devices]) fi @@ -1044,7 +1050,7 @@ else fi AC_SUBST(BUILD_LOGIN) -AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec) +AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec flock) AC_CHECK_FUNCS(setprogname getprogname sigaction mkstemp vsnprintf strerror strcasestr) AC_CHECK_FUNCS(setvbuf) AC_FUNC_SETVBUF_REVERSED diff --git a/configure b/configure index 73ee35f0d..e40394697 100755 --- a/configure +++ b/configure @@ -2168,7 +2168,7 @@ fi # Define the identity of the package. PACKAGE=openafs - VERSION=1.4.2fc2 + VERSION=1.4.2fc4 cat >>confdefs.h <<_ACEOF @@ -5903,7 +5903,10 @@ _ACEOF if test "x$with_linux_kernel_headers" != "x"; then LINUX_KERNEL_PATH="$with_linux_kernel_headers" else - LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/source" + if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + fi if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then LINUX_KERNEL_PATH="/usr/src/linux-2.4" fi @@ -11393,14 +11396,10 @@ _ACEOF #include #include #include -#include -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2); void conftest(void) { #ifdef CONFIG_KEYS -keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL); request_key(NULL, NULL, NULL); #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH" @@ -11438,14 +11437,10 @@ cat >>conftest.$ac_ext <<_ACEOF #include #include #include -#include -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2); int main () { #ifdef CONFIG_KEYS -keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL); request_key(NULL, NULL, NULL); #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH" @@ -12909,6 +12904,13 @@ _ACEOF cat >>confdefs.h <<\_ACEOF #define STRUCT_INODE_HAS_I_ALLOC_SEM 1 +_ACEOF + + fi + if test "x$ac_cv_linux_fs_struct_inode_has_i_blksize" = "xyes"; then + +cat >>confdefs.h <<\_ACEOF +#define STRUCT_INODE_HAS_I_BLKSIZE 1 _ACEOF fi @@ -16333,7 +16335,8 @@ fi -for ac_func in utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec + +for ac_func in utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec flock do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure-libafs b/configure-libafs index eaca57248..de338b190 100755 --- a/configure-libafs +++ b/configure-libafs @@ -2168,7 +2168,7 @@ fi # Define the identity of the package. PACKAGE=openafs-libafs - VERSION=1.4.2fc2 + VERSION=1.4.2fc4 cat >>confdefs.h <<_ACEOF @@ -5904,7 +5904,10 @@ _ACEOF if test "x$with_linux_kernel_headers" != "x"; then LINUX_KERNEL_PATH="$with_linux_kernel_headers" else - LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/source" + if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then + LINUX_KERNEL_PATH="/lib/modules/`uname -r`/build" + fi if test ! -f "$LINUX_KERNEL_PATH/include/linux/version.h"; then LINUX_KERNEL_PATH="/usr/src/linux-2.4" fi @@ -11393,14 +11396,10 @@ _ACEOF #include #include #include -#include -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2); void conftest(void) { #ifdef CONFIG_KEYS -keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL); request_key(NULL, NULL, NULL); #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH" @@ -11438,14 +11437,10 @@ cat >>conftest.$ac_ext <<_ACEOF #include #include #include -#include -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2); int main () { #ifdef CONFIG_KEYS -keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL); request_key(NULL, NULL, NULL); #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH" @@ -12909,6 +12904,13 @@ _ACEOF cat >>confdefs.h <<\_ACEOF #define STRUCT_INODE_HAS_I_ALLOC_SEM 1 +_ACEOF + + fi + if test "x$ac_cv_linux_fs_struct_inode_has_i_blksize" = "xyes"; then + +cat >>confdefs.h <<\_ACEOF +#define STRUCT_INODE_HAS_I_BLKSIZE 1 _ACEOF fi @@ -16333,7 +16335,8 @@ fi -for ac_func in utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec + +for ac_func in utimes random srandom getdtablesize snprintf strlcat strlcpy re_comp re_exec flock do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure-libafs.in b/configure-libafs.in index 9a5ecc4e8..a99a2ea1d 100644 --- a/configure-libafs.in +++ b/configure-libafs.in @@ -1,5 +1,5 @@ AC_INIT(src/libafs/Makefile.common.in) -AM_INIT_AUTOMAKE(openafs-libafs,1.4.2fc2) +AM_INIT_AUTOMAKE(openafs-libafs,1.4.2fc4) AC_CONFIG_HEADER(src/config/afsconfig.h) define(OPENAFS_CONFIGURE_LIBAFS) diff --git a/configure.in b/configure.in index 342f4a980..8884f1adf 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(src/config/stds.h) -AM_INIT_AUTOMAKE(openafs,1.4.2fc2) +AM_INIT_AUTOMAKE(openafs,1.4.2fc4) AC_CONFIG_HEADER(src/config/afsconfig.h) AC_PROG_CC diff --git a/debian/changelog b/debian/changelog index 876dc465e..464f19b15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +openafs (1.4.2~fc4-1) unstable; urgency=low + + * New upstream release candidate. + + -- Russ Allbery Tue, 26 Sep 2006 15:47:02 -0700 + openafs (1.4.2~fc2-1) unstable; urgency=low * New upstream release candidate. diff --git a/debian/rules b/debian/rules index 13dfcade2..5fb503201 100755 --- a/debian/rules +++ b/debian/rules @@ -61,8 +61,8 @@ DOC_PACKAGES = libpam-openafs-kaserver openafs-dbserver openafs-fileserver \ # These variable is used only by get-orig-source, which will normally only be # run by maintainers. -VERSION = 1.4.2fc2 -DEBVERS = 1.4.2~fc2 +VERSION = 1.4.2fc4 +DEBVERS = 1.4.2~fc4 UPSTREAM = /afs/grand.central.org/software/openafs/candidate/$(VERSION) # Download the upstream source, merge in the doc tarball, and do the diff --git a/doc/txt/winnotes/afs-changes-since-1.2.txt b/doc/txt/winnotes/afs-changes-since-1.2.txt index 50d4a2e56..010b3d228 100644 --- a/doc/txt/winnotes/afs-changes-since-1.2.txt +++ b/doc/txt/winnotes/afs-changes-since-1.2.txt @@ -1,3 +1,20 @@ +Since 1.4.2-rc3: (1.4.2-rc4 released 16 Sep 2006) + + * No changes + +Since 1.4.2-rc2: (1.4.2-rc3 released 6 Sep 2006) + + * better handling of dot directory + + * fs sq adn fs mkm now behave as on UNIX + + * another backconnections hostnames fix + + * add license to installers + + * Return Invalid Parameter error for unknown InfoLevels in + SMB Tran2 Search Directory. + Since 1.4.2-rc1: (1.4.2-rc2 released 30 Aug 2006) * Fix rx usage of WSAStartup/WSACleanup diff --git a/regen.sh b/regen.sh index bc059256c..dc9f489b1 100755 --- a/regen.sh +++ b/regen.sh @@ -1,3 +1,4 @@ +#!/bin/sh echo "Updating configuration..." echo "Running aclocal" aclocal -I src/cf @@ -11,6 +12,9 @@ autoheader #echo "Running automake" #automake +echo "Deleting autom4te.cache directory" +rm -r autom4te.cache + # Rebuild the man pages, to not require those building from source to have # pod2man available. echo "Building man pages" diff --git a/src/afs/LINUX/osi_groups.c b/src/afs/LINUX/osi_groups.c index caaa918ac..ec6c21a2b 100644 --- a/src/afs/LINUX/osi_groups.c +++ b/src/afs/LINUX/osi_groups.c @@ -20,7 +20,7 @@ #endif RCSID - ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.5 2006/08/17 13:56:29 shadow Exp $"); + ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.6 2006/09/06 20:57:17 shadow Exp $"); #include "afs/sysincludes.h" #include "afsincludes.h" @@ -189,16 +189,60 @@ __setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, } #ifdef LINUX_KEYRING_SUPPORT -#include -#include +static struct key_type *__key_type_keyring; -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2); - -static long -__join_session_keyring(char *name) +static int +install_session_keyring(struct task_struct *task, struct key *keyring) { - return keyctl(KEYCTL_JOIN_SESSION_KEYRING, name); + struct key *old; + char desc[20]; + unsigned long not_in_quota; + int code = -EINVAL; + + if (!__key_type_keyring) + return code; + + if (!keyring) { + + /* create an empty session keyring */ + not_in_quota = KEY_ALLOC_IN_QUOTA; + sprintf(desc, "_ses.%u", task->tgid); + +#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK + keyring = key_alloc(__key_type_keyring, desc, + task->uid, task->gid, task, + (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, + not_in_quota); +#else + keyring = key_alloc(__key_type_keyring, desc, + task->uid, task->gid, + (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, + not_in_quota); +#endif + if (IS_ERR(keyring)) { + code = PTR_ERR(keyring); + goto out; + } + } + + code = key_instantiate_and_link(keyring, NULL, 0, NULL, NULL); + if (code < 0) { + key_put(keyring); + goto out; + } + + /* install the keyring */ + spin_lock_irq(&task->sighand->siglock); + old = task->signal->session_keyring; + smp_wmb(); + task->signal->session_keyring = keyring; + spin_unlock_irq(&task->sighand->siglock); + + if (old) + key_put(old); + +out: + return code; } #endif /* LINUX_KEYRING_SUPPORT */ @@ -255,7 +299,7 @@ setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, #ifdef LINUX_KEYRING_SUPPORT if (code == 0) { - (void) __join_session_keyring(NULL); + (void) install_session_keyring(current, NULL); if (current->signal->session_keyring) { struct key *key; @@ -520,6 +564,12 @@ struct key_type key_type_afs_pag = void osi_keyring_init(void) { + struct task_struct *p; + + p = find_task_by_pid(1); + if (p && p->user->session_keyring) + __key_type_keyring = p->user->session_keyring->type; + register_key_type(&key_type_afs_pag); } diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h index 8faca6063..23d5b95f2 100644 --- a/src/afs/LINUX/osi_machdep.h +++ b/src/afs/LINUX/osi_machdep.h @@ -227,4 +227,66 @@ do { \ #define AFS_ASSERT_GLOCK() #endif +#ifdef AFS_AMD64_LINUX20_ENV +/* RHEL5 beta's kernel doesn't define these. They aren't gonna change, so... */ + +#ifndef __NR_ia32_afs_syscall +#define __NR_ia32_afs_syscall 137 +#endif +#ifndef __NR_ia32_setgroups +#define __NR_ia32_setgroups 81 +#endif +#ifndef __NR_ia32_setgroups32 +#define __NR_ia32_setgroups32 206 +#endif +#ifndef __NR_ia32_close +#define __NR_ia32_close 6 +#endif +#ifndef __NR_ia32_chdir +#define __NR_ia32_chdir 12 +#endif +#ifndef __NR_ia32_break +#define __NR_ia32_break 17 +#endif +#ifndef __NR_ia32_stty +#define __NR_ia32_stty 31 +#endif +#ifndef __NR_ia32_gtty +#define __NR_ia32_gtty 32 +#endif +#ifndef __NR_ia32_ftime +#define __NR_ia32_ftime 35 +#endif +#ifndef __NR_ia32_prof +#define __NR_ia32_prof 44 +#endif +#ifndef __NR_ia32_lock +#define __NR_ia32_lock 53 +#endif +#ifndef __NR_ia32_mpx +#define __NR_ia32_mpx 56 +#endif +#ifndef __NR_ia32_exit +#define __NR_ia32_exit 1 +#endif +#ifndef __NR_ia32_mount +#define __NR_ia32_mount 21 +#endif +#ifndef __NR_ia32_read +#define __NR_ia32_read 3 +#endif +#ifndef __NR_ia32_write +#define __NR_ia32_write 4 +#endif +#ifndef __NR_ia32_open +#define __NR_ia32_open 5 +#endif +#ifndef __NR_ia32_close +#define __NR_ia32_close 6 +#endif +#ifndef __NR_ia32_unlink +#define __NR_ia32_unlink 10 +#endif +#endif + #endif /* OSI_MACHDEP_H_ */ diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index 8dba7a087..fd94921c4 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -15,7 +15,7 @@ #include "afs/param.h" RCSID - ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.24 2006/08/14 22:09:33 shadow Exp $"); + ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.25 2006/09/16 19:19:36 shadow Exp $"); #include /* early to avoid printf->printk mapping */ #include "afs/sysincludes.h" @@ -366,11 +366,9 @@ init_module(void) osi_Init(); -#ifndef LINUX_KEYRING_SUPPORT err = osi_syscall_init(); if (err) return err; -#endif err = afs_init_inodecache(); if (err) return err; diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h index 771c12214..36b4c579c 100644 --- a/src/afs/afs_osi.h +++ b/src/afs/afs_osi.h @@ -220,7 +220,7 @@ typedef struct timeval osi_timeval_t; #ifdef AFS_GLOBAL_SUNLOCK #define AFS_ASSERT_GLOCK() \ - (ISAFS_GLOCK() || (osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__), 0)) + do { if (!ISAFS_GLOCK()) osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__); } while (0) #endif /* AFS_GLOBAL_SUNLOCK */ #ifdef RX_ENABLE_LOCKS diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index 22fe7a684..df31f0f53 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -73,6 +73,9 @@ #if defined(LINUX_KEYRING_SUPPORT) #include #include +#ifndef KEY_ALLOC_IN_QUOTA +#define KEY_ALLOC_IN_QUOTA 1 +#endif #endif #endif /* Avoid conflicts with coda overloading AFS type namespace. Must precede diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index 006813826..0d6d97bdc 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -11,7 +11,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40.2.6 2006/03/28 18:42:57 shadow Exp $"); + ("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.40.2.8 2006/09/17 05:01:56 shadow Exp $"); #include #include @@ -114,6 +114,113 @@ static int SaveKeys(struct afsconf_dir *adir); * CellServDB changes. */ +#if defined(AFS_SUN5_ENV) && !defined(__sparcv9) +/* Solaris through 10 in 32 bit mode will return EMFILE if fopen can't + get an fd <= 255. We allow the fileserver to claim more fds than that. + This has always been a problem since pr_Initialize would have the same + issue, but hpr_Initialize makes it more likely that we would see this. + Work around it. This is not generic. It's coded with the needs of + afsconf_* in mind only. + + http://www.opensolaris.org/os/community/onnv/flag-days/pages/2006042001/ +*/ + +#define BUFFER 4096 + +struct afsconf_iobuffer { + int _file; + char *buffer; + char *ptr; + char *endptr; +}; + +typedef struct afsconf_iobuffer afsconf_FILE; + +static afsconf_FILE * +afsconf_fopen(const char *fname, const char *fmode) +{ + int fd; + afsconf_FILE *iop; + + if ((fd = open(fname, O_RDONLY)) == -1) { + return NULL; + } + + iop = malloc(sizeof(struct afsconf_iobuffer)); + if (iop == NULL) { + (void) close(fd); + errno = ENOMEM; + return NULL; + } + iop->_file = fd; + iop->buffer = malloc(BUFFER); + if (iop->buffer == NULL) { + (void) close(fd); + free((void *) iop); + errno = ENOMEM; + return NULL; + } + iop->ptr = iop->buffer; + iop->endptr = iop->buffer; + return iop; +} + +static int +afsconf_fclose(afsconf_FILE *iop) +{ + if (iop == NULL) { + return 0; + } + close(iop->_file); + free((void *)iop->buffer); + free((void *)iop); + return 0; +} + +static char * +afsconf_fgets(char *s, int n, afsconf_FILE *iop) +{ + char *p; + + p = s; + for (;;) { + char c; + + if (iop->ptr == iop->endptr) { + ssize_t len; + + if ((len = read(iop->_file, (void *)iop->buffer, BUFFER)) == -1) { + return NULL; + } + if (len == 0) { + *p = 0; + if (s == p) { + return NULL; + } + return s; + } + iop->ptr = iop->buffer; + iop->endptr = iop->buffer + len; + } + c = *iop->ptr++; + *p++ = c; + if ((p - s) == (n - 1)) { + *p = 0; + return s; + } + if (c == '\n') { + *p = 0; + return s; + } + } +} +#define fopen afsconf_fopen +#define fclose afsconf_fclose +#define fgets afsconf_fgets +#else +#define afsconf_FILE FILE +#endif /* AFS_SUN5_ENV && ! __sparcv9 */ + /* return port number in network byte order in the low 16 bits of a long; return -1 if not found */ static afs_int32 afsconf_FindService(register const char *aname) @@ -311,7 +418,7 @@ afsconf_Open(register const char *adir) if (!(afsconf_path = getenv("AFSCONF"))) { /* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs//common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */ char *home_dir; - FILE *fp; + afsconf_FILE *fp; size_t len; if (!(home_dir = getenv("HOME"))) { @@ -366,26 +473,31 @@ afsconf_Open(register const char *adir) return tdir; } - static int GetCellUnix(struct afsconf_dir *adir) { int rc; char tbuffer[256]; - FILE *tf; - + int fd; + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE, NULL); - tf = fopen(tbuffer, "r"); - if (tf) { - /* FIXME: buffer overflow waiting to happen */ - rc = fscanf(tf, "%s", tbuffer); - if (rc == 1) { - adir->cellName = (char *)malloc(strlen(tbuffer) + 1); - strcpy(adir->cellName, tbuffer); - } - fclose(tf); + fd = open(tbuffer, O_RDONLY, 0); + if (fd < 0) { + return -1; } else { - return -1; + int sz; + + memset(tbuffer, 0, 256); + sz = read(fd, tbuffer, 255); + close(fd); + if (sz > 0) { + char *p = strchr(tbuffer, '\n'); + if (p) + *p = '\0'; + + adir->cellName = (char *)malloc(sz + 1); + strncpy(adir->cellName, tbuffer, sz); + } } return 0; } @@ -410,7 +522,7 @@ static int afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell, char clones[]) { - FILE *tf; + afsconf_FILE *tf; register char *tp, *bp; register struct afsconf_entry *curEntry; struct afsconf_aliasentry *curAlias; diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 9c2e0dfb8..5485b2f23 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -614,12 +614,8 @@ AC_DEFUN([LINUX_LINUX_KEYRING_SUPPORT], [ AC_TRY_KBUILD( [#include #include -#include -#include -static int errno; -static inline _syscall2(long, keyctl, int, option, void*, arg2);], +#include ], [#ifdef CONFIG_KEYS -keyctl(KEYCTL_JOIN_SESSION_KEYRING, NULL); request_key(NULL, NULL, NULL); #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH" diff --git a/src/config/NTMakefile.amd64_w2k b/src/config/NTMakefile.amd64_w2k index 171d88724..a0c0bcfe2 100644 --- a/src/config/NTMakefile.amd64_w2k +++ b/src/config/NTMakefile.amd64_w2k @@ -80,7 +80,7 @@ LIB = $(AFSDEV_LIB) #define used in WinNT/2000 installation and program version display AFSPRODUCT_VER_MAJOR=1 AFSPRODUCT_VER_MINOR=4 -AFSPRODUCT_VER_PATCH=0201 +AFSPRODUCT_VER_PATCH=0203 AFSPRODUCT_VER_BUILD=0 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH) diff --git a/src/config/NTMakefile.i386_nt40 b/src/config/NTMakefile.i386_nt40 index c7abe7909..9cab67a10 100644 --- a/src/config/NTMakefile.i386_nt40 +++ b/src/config/NTMakefile.i386_nt40 @@ -80,7 +80,7 @@ LIB = $(AFSDEV_LIB) #define used in WinNT/2000 installation and program version display AFSPRODUCT_VER_MAJOR=1 AFSPRODUCT_VER_MINOR=4 -AFSPRODUCT_VER_PATCH=0201 +AFSPRODUCT_VER_PATCH=0203 AFSPRODUCT_VER_BUILD=0 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH) diff --git a/src/config/NTMakefile.i386_w2k b/src/config/NTMakefile.i386_w2k index a188ef087..78e3101de 100644 --- a/src/config/NTMakefile.i386_w2k +++ b/src/config/NTMakefile.i386_w2k @@ -80,7 +80,7 @@ LIB = $(AFSDEV_LIB) #define used in WinNT/2000 installation and program version display AFSPRODUCT_VER_MAJOR=1 AFSPRODUCT_VER_MINOR=4 -AFSPRODUCT_VER_PATCH=0201 +AFSPRODUCT_VER_PATCH=0203 AFSPRODUCT_VER_BUILD=0 AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH) diff --git a/src/config/afsconfig.h.in b/src/config/afsconfig.h.in index 874f11fcb..19492a4ab 100644 --- a/src/config/afsconfig.h.in +++ b/src/config/afsconfig.h.in @@ -86,6 +86,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `flock' function. */ +#undef HAVE_FLOCK + /* define if compiler has __FUNCTION__ */ #undef HAVE_FUNCTION_MACRO @@ -414,6 +417,9 @@ /* define if your struct inode has alloc_sem */ #undef STRUCT_INODE_HAS_I_ALLOC_SEM +/* define if your struct inode has i_blksize */ +#undef STRUCT_INODE_HAS_I_BLKSIZE + /* define if you struct inode has i_devices */ #undef STRUCT_INODE_HAS_I_DEVICES diff --git a/src/kauth/authclient.c b/src/kauth/authclient.c index 9a5918193..e507396ad 100644 --- a/src/kauth/authclient.c +++ b/src/kauth/authclient.c @@ -17,7 +17,7 @@ #endif RCSID - ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.4 2004/12/13 19:38:51 shadow Exp $"); + ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.5 2006/09/15 23:19:27 jaltman Exp $"); #if defined(UKERNEL) #include "afs/sysincludes.h" @@ -145,6 +145,7 @@ ka_GetServers(char *cell, struct afsconf_cell * cellinfo) } } code = myCellLookup(conf, cell, AFSCONF_KAUTHSERVICE, cellinfo); + afsconf_Close(conf); UNLOCK_GLOBAL_MUTEX; return code; } diff --git a/src/libafs/afs.ppc_darwin_70.plist.in b/src/libafs/afs.ppc_darwin_70.plist.in index c247885a8..bc7125d27 100644 --- a/src/libafs/afs.ppc_darwin_70.plist.in +++ b/src/libafs/afs.ppc_darwin_70.plist.in @@ -15,11 +15,11 @@ CFBundlePackageType KEXT CFBundleShortVersionString - 1.4.2fc2 + 1.4.2fc4 CFBundleSignature ???? CFBundleVersion - 1.4.2fc2 + 1.4.2fc4 OSBundleLibraries com.apple.kernel.bsd diff --git a/src/libafs/afs.ppc_darwin_80.plist.in b/src/libafs/afs.ppc_darwin_80.plist.in index 730e0afb6..efde73682 100644 --- a/src/libafs/afs.ppc_darwin_80.plist.in +++ b/src/libafs/afs.ppc_darwin_80.plist.in @@ -15,11 +15,11 @@ CFBundlePackageType KEXT CFBundleShortVersionString - 1.4.2fc2 + 1.4.2fc4 CFBundleSignature ???? CFBundleVersion - 1.4.2fc2 + 1.4.2fc4 OSBundleLibraries com.apple.kpi.bsd diff --git a/src/libafs/afs.ppc_darwin_90.plist.in b/src/libafs/afs.ppc_darwin_90.plist.in index 730e0afb6..efde73682 100644 --- a/src/libafs/afs.ppc_darwin_90.plist.in +++ b/src/libafs/afs.ppc_darwin_90.plist.in @@ -15,11 +15,11 @@ CFBundlePackageType KEXT CFBundleShortVersionString - 1.4.2fc2 + 1.4.2fc4 CFBundleSignature ???? CFBundleVersion - 1.4.2fc2 + 1.4.2fc4 OSBundleLibraries com.apple.kpi.bsd diff --git a/src/libafs/afs.x86_darwin_80.plist.in b/src/libafs/afs.x86_darwin_80.plist.in index 730e0afb6..efde73682 100644 --- a/src/libafs/afs.x86_darwin_80.plist.in +++ b/src/libafs/afs.x86_darwin_80.plist.in @@ -15,11 +15,11 @@ CFBundlePackageType KEXT CFBundleShortVersionString - 1.4.2fc2 + 1.4.2fc4 CFBundleSignature ???? CFBundleVersion - 1.4.2fc2 + 1.4.2fc4 OSBundleLibraries com.apple.kpi.bsd diff --git a/src/libafs/afs.x86_darwin_90.plist.in b/src/libafs/afs.x86_darwin_90.plist.in index 730e0afb6..efde73682 100644 --- a/src/libafs/afs.x86_darwin_90.plist.in +++ b/src/libafs/afs.x86_darwin_90.plist.in @@ -15,11 +15,11 @@ CFBundlePackageType KEXT CFBundleShortVersionString - 1.4.2fc2 + 1.4.2fc4 CFBundleSignature ???? CFBundleVersion - 1.4.2fc2 + 1.4.2fc4 OSBundleLibraries com.apple.kpi.bsd diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c index 6e35d2d4f..bbea98d4e 100644 --- a/src/ptserver/ptuser.c +++ b/src/ptserver/ptuser.c @@ -15,7 +15,7 @@ #endif RCSID - ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.8 2006/07/31 17:15:48 shadow Exp $"); + ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.10 2006/09/16 19:40:52 shadow Exp $"); #if defined(UKERNEL) #include "afs/sysincludes.h" @@ -71,7 +71,7 @@ pr_Initialize(IN afs_int32 secLevel, IN char *confDir, IN char *cell) afs_int32 code; struct rx_connection *serverconns[MAXSERVERS]; struct rx_securityClass *sc[3]; - static struct afsconf_dir *tdir = (struct afsconf_dir *)0; /* only do this once */ + static struct afsconf_dir *tdir = (struct afsconf_dir *)NULL; /* only do this once */ static char tconfDir[100] = ""; static char tcell[64] = ""; struct ktc_token ttoken; @@ -117,16 +117,16 @@ pr_Initialize(IN afs_int32 secLevel, IN char *confDir, IN char *cell) } #endif /* defined(UKERNEL) */ - if (tdir == 0 || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) { + if (tdir == NULL || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) { /* * force re-evaluation. we either don't have an afsconf_dir, * the directory has changed or the cell has changed. */ if (tdir && !gottdir) { afsconf_Close(tdir); - tdir = (struct afsconf_dir *)0; + tdir = (struct afsconf_dir *)NULL; } - pruclient = (struct ubik_client *)0; + pruclient = (struct ubik_client *)NULL; refresh = 1; } @@ -163,8 +163,9 @@ pr_Initialize(IN afs_int32 secLevel, IN char *confDir, IN char *cell) * want, don't get a new one. Unless the security level is 2 in * which case we will get one (and re-read the key file). */ - if (pruclient && (lastLevel == secLevel) && (secLevel != 2)) + if (pruclient && (lastLevel == secLevel) && (secLevel != 2)) { return 0; + } code = rx_Init(0); if (code) { @@ -216,6 +217,7 @@ pr_Initialize(IN afs_int32 secLevel, IN char *confDir, IN char *cell) ttoken.ticket); } } + if (scIndex == 1) return PRBADARG; if ((scIndex == 0) && (sc[0] == 0)) diff --git a/src/rx/DARWIN/rx_knet.c b/src/rx/DARWIN/rx_knet.c index 2b27f5747..beb4403d8 100644 --- a/src/rx/DARWIN/rx_knet.c +++ b/src/rx/DARWIN/rx_knet.c @@ -11,7 +11,7 @@ #include "afs/param.h" RCSID - ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10.2.2 2006/01/17 17:09:48 shadow Exp $"); + ("$Header: /cvs/openafs/src/rx/DARWIN/rx_knet.c,v 1.10.2.3 2006/09/16 00:11:24 shadow Exp $"); #include "rx/rx_kcommon.h" @@ -127,7 +127,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec, *addr = *(struct sockaddr_in *)sa; } else printf("Unknown socket family %d in NetReceive\n", sa->sa_family); +#ifndef AFS_DARWIN80_ENV FREE(sa, M_SONAME); +#endif } return code; } diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index 7d369b475..4843dd5f0 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -15,7 +15,7 @@ #include "afs/param.h" RCSID - ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.12 2006/07/31 15:08:20 shadow Exp $"); + ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.13 2006/08/31 04:54:55 shadow Exp $"); #include "rx/rx_kcommon.h" @@ -124,6 +124,7 @@ rxi_GetUDPSocket(u_short port) return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port); } +#if !defined(AFS_LINUX26_ENV) void osi_Panic(msg, a1, a2, a3) char *msg; @@ -132,7 +133,7 @@ osi_Panic(msg, a1, a2, a3) msg = "Unknown AFS panic"; printf(msg, a1, a2, a3); -#ifdef AFS_LINUX24_ENV +#ifdef AFS_LINUX20_ENV * ((char *) 0) = 0; #else panic(msg); @@ -261,6 +262,13 @@ osi_AssertFailK(const char *expr, const char *file, int line) osi_Panic(buf); } +#else +void +osi_AssertFailK(const char *expr, const char *file, int line) +{ + printk(KERN_CRIT "assertion failed: %s, file: %s, line: %d\n", expr, file, line); +} +#endif #ifndef UKERNEL /* This is the server process request loop. Kernel server diff --git a/src/rx/rx_prototypes.h b/src/rx/rx_prototypes.h index 2599a003b..c8b1a05ea 100644 --- a/src/rx/rx_prototypes.h +++ b/src/rx/rx_prototypes.h @@ -334,7 +334,14 @@ extern int rxk_DelPort(u_short aport); extern void rxk_shutdownPorts(void); extern osi_socket rxi_GetUDPSocket(u_short port); extern osi_socket rxi_GetHostUDPSocket(u_int host, u_short port); -extern void osi_Panic(); +#if defined(KERNEL) && defined(AFS_LINUX26_ENV) +#define osi_Panic(msg...) do { printk(KERN_CRIT "openafs: " msg); BUG(); } while (0) +#undef osi_Assert +#define osi_Assert(expr) \ + do { if (!(expr)) { osi_AssertFailK(#expr, __FILE__, __LINE__); BUG(); } } while (0) +#else +extern void osi_Panic(); /* leave without args till stdarg rewrite */ +#endif extern int osi_utoa(char *buf, size_t len, unsigned long val); extern void rxi_InitPeerParams(register struct rx_peer *pp); extern void shutdown_rxkernel(void); @@ -565,7 +572,6 @@ extern pthread_mutex_t rx_if_mutex; extern osi_socket rxi_GetUDPSocket(u_short port); extern void osi_AssertFailU(const char *expr, const char *file, int line); extern int rx_getAllAddr(afs_int32 * buffer, int maxSize); -extern void osi_Panic(); /* leave without args till stdarg rewrite */ extern void rxi_InitPeerParams(struct rx_peer *pp); #if defined(AFS_AIX32_ENV) && !defined(KERNEL) diff --git a/src/ubik/uinit.c b/src/ubik/uinit.c index 7e91bbb49..a03dcbb87 100644 --- a/src/ubik/uinit.c +++ b/src/ubik/uinit.c @@ -11,7 +11,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.2 2004/11/09 17:09:41 shadow Exp $"); + ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.3 2006/09/15 23:19:28 jaltman Exp $"); #include #ifdef AFS_NT40_ENV @@ -87,6 +87,7 @@ ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, } code = afsconf_ClientAuth(tdir, &sc, &scIndex); /* sets sc,scIndex */ if (code) { + afsconf_Close(tdir); fprintf(stderr, "%s: Could not get security object for -localAuth\n", funcName); @@ -96,6 +97,7 @@ ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, afsconf_GetCellInfo(tdir, tdir->cellName, serviceid, &info); if (code) { + afsconf_Close(tdir); fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n", funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH, diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index e90e9226a..92d127d14 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -29,7 +29,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.33 2006/08/01 22:33:47 shadow Exp $"); + ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.36 2006/09/14 23:59:36 shadow Exp $"); #include #include @@ -308,6 +308,8 @@ CallPreamble(register struct rx_call *acall, int activecall, char hoststr[16], hoststr2[16]; struct ubik_client *uclient; + *ahostp = NULL; + if (!tconn) { ViceLog(0, ("CallPreamble: unexpected null tconn!\n")); return -1; @@ -427,14 +429,19 @@ CallPostamble(register struct rx_connection *aconn, afs_int32 ret, held = h_Held_r(thost); if (held) h_Release_r(thost); - if (ahost != thost) { + if (ahost && ahost != thost) { char hoststr[16], hoststr2[16]; ViceLog(0, ("CallPostamble: ahost %s:%d (%x) != thost %s:%d (%x)\n", - afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), + afs_inet_ntoa_r(ahost->host, hoststr), ntohs(ahost->port), ahost, afs_inet_ntoa_r(thost->host, hoststr2), ntohs(thost->port), thost)); h_Release_r(ahost); + } else if (!ahost) { + char hoststr[16]; + ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%x)\n", + afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), + thost)); } H_UNLOCK; return (translate ? sys_error_to_et(ret) : ret); @@ -7388,9 +7395,13 @@ init_sys_error_to_et(void) sys2et[ENAMETOOLONG] = UAENAMETOOLONG; sys2et[ENOLCK] = UAENOLCK; sys2et[ENOSYS] = UAENOSYS; +#if (ENOTEMPTY != EEXIST) sys2et[ENOTEMPTY] = UAENOTEMPTY; +#endif sys2et[ELOOP] = UAELOOP; +#if (EWOULDBLOCK != EAGAIN) sys2et[EWOULDBLOCK] = UAEWOULDBLOCK; +#endif sys2et[ENOMSG] = UAENOMSG; sys2et[EIDRM] = UAEIDRM; sys2et[ECHRNG] = UAECHRNG; diff --git a/src/viced/host.c b/src/viced/host.c index 547e6aa18..99d10431c 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -11,7 +11,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.43 2006/08/24 04:33:02 shadow Exp $"); + ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.44 2006/09/05 22:09:00 shadow Exp $"); #include #include @@ -272,31 +272,27 @@ hpr_Initialize(struct ubik_client **uclient) tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); if (!tdir) { - fprintf(stderr, - "libprot: Could not open configuration directory: %s.\n", - AFSDIR_SERVER_ETC_DIRPATH); - return -1; + ViceLog(0, ("hpr_Initialize: Could not open configuration directory: %s", AFSDIR_SERVER_ETC_DIRPATH)); + return -1; } code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr)); if (code) { - fprintf(stderr, - "libprot: Could not get local cell. [%d]\n", code); + ViceLog(0, ("hpr_Initialize: Could not get local cell. [%d]", code)); afsconf_Close(tdir); return code; } code = afsconf_GetCellInfo(tdir, cellstr, "afsprot", &info); if (code) { - fprintf(stderr, "libprot: Could not locate cell %s in %s/%s\n", - cellstr, confDir, AFSDIR_CELLSERVDB_FILE); + ViceLog(0, ("hpr_Initialize: Could not locate cell %s in %s/%s", cellstr, confDir, AFSDIR_CELLSERVDB_FILE)); afsconf_Close(tdir); return code; } code = rx_Init(0); if (code) { - fprintf(stderr, "libprot: Could not initialize rx.\n"); + ViceLog(0, ("hpr_Initialize: Could not initialize rx.")); afsconf_Close(tdir); return code; } @@ -311,9 +307,7 @@ hpr_Initialize(struct ubik_client **uclient) if ((afsconf_GetLatestKey(tdir, 0, 0) == 0)) { code = afsconf_ClientAuthSecure(tdir, &sc[2], &scIndex); if (code) - fprintf(stderr, - "libprot: clientauthsecure returns %d %s" - " (so trying noauth)\n", code, error_message(code)); + ViceLog(0, ("hpr_Initialize: clientauthsecure returns %d %s (so trying noauth)", code, error_message(code))); if (code) scIndex = 0; /* use noauth */ if (scIndex != 2) @@ -332,9 +326,7 @@ hpr_Initialize(struct ubik_client **uclient) /* this is a kerberos ticket, set scIndex accordingly */ scIndex = 2; else { - fprintf(stderr, - "libprot: funny kvno (%d) in ticket, proceeding\n", - ttoken.kvno); + ViceLog(0, ("hpr_Initialize: funny kvno (%d) in ticket, proceeding", ttoken.kvno)); scIndex = 2; } sc[2] = @@ -346,8 +338,7 @@ hpr_Initialize(struct ubik_client **uclient) if ((scIndex == 0) && (sc[0] == 0)) sc[0] = rxnull_NewClientSecurityObject(); if ((scIndex == 0)) - com_err("fileserver", code, - "Could not get afs tokens, running unauthenticated."); + ViceLog(0, ("hpr_Initialize: Could not get afs tokens, running unauthenticated. [%d]", code)); memset(serverconns, 0, sizeof(serverconns)); /* terminate list!!! */ for (i = 0; i < info.numServers; i++) { @@ -359,7 +350,7 @@ hpr_Initialize(struct ubik_client **uclient) code = ubik_ClientInit(serverconns, uclient); if (code) { - com_err("fileserver", code, "ubik client init failed."); + ViceLog(0, ("hpr_Initialize: ubik client init failed. [%d]", code)); } afsconf_Close(tdir); code = rxs_Release(sc[scIndex]); diff --git a/src/viced/viced.c b/src/viced/viced.c index c50971081..1ec878646 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -20,7 +20,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.16 2006/08/24 02:35:59 shadow Exp $"); + ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.18 2006/09/15 23:19:28 jaltman Exp $"); #include #include @@ -150,8 +150,6 @@ struct afsconf_dir *confDir; /* Configuration dir object */ int restartMode = RESTART_ORDINARY; -int Testing = 0; /* for ListViceInodes */ - /* * Home for the performance statistics. */ @@ -1374,6 +1372,7 @@ vl_Initialize(char *confDir) info.hostAddr[i].sin_port, USER_SERVICE_ID, sc, scIndex); code = ubik_ClientInit(serverconns, &cstruct); + afsconf_Close(tdir); if (code) { ViceLog(0, ("vl_Initialize: ubik client init failed.\n")); return code; diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 192350297..c45a57026 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -21,7 +21,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.3 2005/11/01 16:45:44 shadow Exp $"); + ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.4 2006/09/03 05:51:42 shadow Exp $"); #ifndef AFS_NAMEI_ENV #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV) @@ -135,7 +135,7 @@ extern off_t afs_lseek(int FD, off_t O, int F); #define ROOTINODE 2 static char *partition; -extern int Testing; +int Testing=0; int pfd; #ifdef AFS_AIX32_ENV diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 53c3f6dd5..f4e3497d6 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -13,7 +13,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.6 2006/07/31 15:18:51 shadow Exp $"); + ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.10 2006/09/20 05:52:35 shadow Exp $"); #ifdef AFS_NAMEI_ENV #include @@ -27,9 +27,6 @@ RCSID #include #include #include -#ifdef AFS_AIX_ENV -#include -#endif #if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) #include #endif @@ -69,7 +66,41 @@ extern off_t afs_lseek(int FD, off_t O, int F); /*@printflike@*/ extern void Log(const char *format, ...); +#ifndef LOCK_SH +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* don't block when locking */ +#define LOCK_UN 8 /* unlock */ +#endif + +#ifndef HAVE_FLOCK +#include + +/* + * This function emulates a subset of flock() + */ +int +emul_flock(int fd, int cmd) +{ struct flock f; + + memset(&f, 0, sizeof (f)); + + if (cmd & LOCK_UN) + f.l_type = F_UNLCK; + if (cmd & LOCK_SH) + f.l_type = F_RDLCK; + if (cmd & LOCK_EX) + f.l_type = F_WRLCK; + + return fcntl(fd, (cmd & LOCK_NB) ? F_SETLK : F_SETLKW, &f); +} + +#define flock(f,c) emul_flock(f,c) +#endif + extern char *volutil_PartitionName_r(int volid, char *buf, int buflen); +int Testing=0; + afs_sfsize_t namei_iread(IHandle_t * h, afs_foff_t offset, char *buf, afs_fsize_t size) @@ -149,7 +180,8 @@ typedef struct { int ogm_mode; } namei_ogm_t; -int namei_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked); +static int namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup, int nowrite); + static int GetFreeTag(IHandle_t * ih, int vno); /* namei_HandleToInodeDir @@ -858,43 +890,65 @@ namei_GetLCOffsetAndIndexFromIno(Inode ino, afs_foff_t * offset, int *index) * If lockit is set, lock the file and leave it locked upon a successful * return. */ -int -namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) +static int +namei_GetLinkCount2(FdHandle_t * h, Inode ino, int lockit, int fixup, int nowrite) { unsigned short row = 0; afs_foff_t offset; + ssize_t rc; int index; + /* there's no linktable yet. the salvager will create one later */ + if (h->fd_fd == -1 && fixup) + return 1; namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index); if (lockit) { -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - if (lockf(h->fd_fd, F_LOCK, 0) < 0) -#else if (flock(h->fd_fd, LOCK_EX) < 0) -#endif return -1; } if (afs_lseek(h->fd_fd, offset, SEEK_SET) == -1) goto bad_getLinkByte; - if (read(h->fd_fd, (char *)&row, sizeof(row)) != sizeof(row)) { + rc = read(h->fd_fd, (char *)&row, sizeof(row)); + if ((rc == 0 || !((row >> index) & NAMEI_TAGMASK)) && fixup && nowrite) + return 1; + if (rc == 0 && fixup) { + struct stat st; + if (fstat(h->fd_fd, &st) || st.st_size >= offset+sizeof(row)) + goto bad_getLinkByte; + FDH_TRUNC(h, offset+sizeof(row)); + row = 1 << index; + rc = write(h->fd_fd, (char *)&row, sizeof(row)); + } + if (rc != sizeof(row)) { goto bad_getLinkByte; } + if (fixup && !((row >> index) & NAMEI_TAGMASK)) { + row |= 1<fd_fd, offset, SEEK_SET) == -1) + goto bad_getLinkByte; + rc = write(h->fd_fd, (char *)&row, sizeof(row)); + if (rc != sizeof(row)) + goto bad_getLinkByte; + } + return (int)((row >> index) & NAMEI_TAGMASK); bad_getLinkByte: if (lockit) -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - lockf(h->fd_fd, F_ULOCK, 0); -#else flock(h->fd_fd, LOCK_UN); -#endif return -1; } +int +namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) +{ + return namei_GetLinkCount2(h, ino, lockit, 0, 1); +} + /* Return a free column index for this vnode. */ static int GetFreeTag(IHandle_t * ih, int vno) @@ -912,11 +966,7 @@ GetFreeTag(IHandle_t * ih, int vno) return -1; /* Only one manipulates at a time. */ -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) { -#else if (flock(fdP->fd_fd, LOCK_EX) < 0) { -#endif FDH_REALLYCLOSE(fdP); return -1; } @@ -952,20 +1002,12 @@ GetFreeTag(IHandle_t * ih, int vno) goto badGetFreeTag; } FDH_SYNC(fdP); -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - lockf(fdP->fd_fd, F_ULOCK, 0); -#else flock(fdP->fd_fd, LOCK_UN); -#endif FDH_REALLYCLOSE(fdP); return col;; badGetFreeTag: -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - lockf(fdP->fd_fd, F_ULOCK, 0); -#else flock(fdP->fd_fd, LOCK_UN); -#endif FDH_REALLYCLOSE(fdP); return -1; } @@ -988,11 +1030,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked) namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index); if (!locked) { -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) { -#else if (flock(fdP->fd_fd, LOCK_EX) < 0) { -#endif return -1; } } @@ -1031,11 +1069,7 @@ namei_SetLinkCount(FdHandle_t * fdP, Inode ino, int count, int locked) bad_SetLinkCount: -#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) - lockf(fdP->fd_fd, F_ULOCK, 0); -#else flock(fdP->fd_fd, LOCK_UN); -#endif return code; } @@ -1289,9 +1323,9 @@ namei_ListAFSSubDirs(IHandle_t * dirIH, /* Open this handle */ (void)afs_snprintf(path2, sizeof path2, "%s/%s", path1, dp1->d_name); - linkHandle.fd_fd = afs_open(path2, O_RDONLY, 0666); + linkHandle.fd_fd = afs_open(path2, Testing ? O_RDONLY : O_RDWR, 0666); info.linkCount = - namei_GetLinkCount(&linkHandle, (Inode) 0, 0); + namei_GetLinkCount2(&linkHandle, (Inode) 0, 1, 1, Testing); } if (judgeFun && !(*judgeFun) (&info, singleVolumeNumber, rock)) continue; @@ -1342,8 +1376,8 @@ namei_ListAFSSubDirs(IHandle_t * dirIH, (path3, dp3->d_name, &info, myIH.ih_vid) < 0) continue; info.linkCount = - namei_GetLinkCount(&linkHandle, - info.inodeNumber, 0); + namei_GetLinkCount2(&linkHandle, + info.inodeNumber, 1, 1, Testing); if (info.linkCount == 0) { #ifdef DELETE_ZLC Log("Found 0 link count file %s/%s, deleting it.\n", path3, dp3->d_name); diff --git a/src/vol/namei_ops.h b/src/vol/namei_ops.h index 9f0df4a92..d32f8208c 100644 --- a/src/vol/namei_ops.h +++ b/src/vol/namei_ops.h @@ -42,6 +42,7 @@ afs_sfsize_t namei_iwrite(IHandle_t * h, afs_foff_t offset, char *buf, extern int namei_dec(IHandle_t * h, Inode ino, int p1); extern int namei_inc(IHandle_t * h, Inode ino, int p1); extern int namei_GetLinkCount(FdHandle_t * h, Inode ino, int lockit); +extern int namei_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked); extern int namei_ViceREADME(char *partition); #include "nfs.h" #include "viceinode.h" diff --git a/src/vol/ntops.c b/src/vol/ntops.c index f64644acc..2991fe0eb 100644 --- a/src/vol/ntops.c +++ b/src/vol/ntops.c @@ -13,7 +13,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/vol/ntops.c,v 1.7.2.1 2004/10/18 07:12:28 shadow Exp $"); + ("$Header: /cvs/openafs/src/vol/ntops.c,v 1.7.2.2 2006/09/05 14:50:57 shadow Exp $"); #ifdef AFS_NT40_ENV #include @@ -41,6 +41,8 @@ RCSID #define BASEFILEATTRIBUTE FILE_ATTRIBUTE_NORMAL +int Testing = 0; + static void AddToZLCDeleteList(char dir, char *name); /* nt_unlink - unlink a case sensitive name. @@ -837,13 +839,17 @@ nt_GetLCOffsetAndIndexFromIno(Inode ino, int *offset, int *index) * If lockit is set, lock the file and leave it locked upon a successful * return. */ -int -nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) +static int +nt_GetLinkCountInternal(FdHandle_t * h, Inode ino, int lockit, int fixup) { unsigned short row = 0; - int junk; + DWORD bytesRead, bytesWritten; int offset, index; + /* there's no linktable yet. the salvager will create one later */ + if (h->fd_fd == INVALID_HANDLE_VALUE && fixup) + return 1; + nt_GetLCOffsetAndIndexFromIno(ino, &offset, &index); if (lockit) { @@ -854,10 +860,25 @@ nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) if (!SetFilePointer(h->fd_fd, (LONG) offset, NULL, FILE_BEGIN)) goto bad_getLinkByte; - if (!ReadFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) { + if (!ReadFile(h->fd_fd, (void *)&row, 2, &bytesRead, NULL)) goto bad_getLinkByte; + + if (bytesRead == 0 && fixup) { + LARGE_INTEGER size; + + if (!GetFileSizeEx(h->fd_fd, &size) || size.QuadPart >= offset+sizeof(row)) + goto bad_getLinkByte; + FDH_TRUNC(h, offset+sizeof(row)); + row = 1 << index; + rewrite: + WriteFile(h->fd_fd, (char *)&row, sizeof(row), &bytesWritten, NULL); } + if (fixup && !((row >> index) & NT_TAGMASK)) { + row |= 1<> index) & NT_TAGMASK); bad_getLinkByte: @@ -866,7 +887,17 @@ nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) return -1; } +int +nt_GetLinkCount(FdHandle_t * h, Inode ino, int lockit) +{ + return nt_GetLinkCountInternal(h, ino, lockit, 0); +} +void +nt_SetNonZLC(FdHandle_t * h, Inode ino) +{ + (void)nt_GetLinkCountInternal(h, ino, 0, 1); +} /* nt_SetLinkCount @@ -878,7 +909,7 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked) { int offset, index; unsigned short row; - int junk; + DWORD bytesRead, bytesWritten; int code = -1; nt_GetLCOffsetAndIndexFromIno(ino, &offset, &index); @@ -896,16 +927,16 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked) } - if (!ReadFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) { + if (!ReadFile(h->fd_fd, (void *)&row, 2, &bytesRead, NULL)) { errno = nterr_nt2unix(GetLastError(), EBADF); goto bad_SetLinkCount; } - if (junk == 0) + if (bytesRead == 0) row = 0; - junk = 7 << index; + bytesRead = 7 << index; count <<= index; - row &= (unsigned short)~junk; + row &= (unsigned short)~bytesRead; row |= (unsigned short)count; if (!SetFilePointer(h->fd_fd, (LONG) offset, NULL, FILE_BEGIN)) { @@ -913,7 +944,7 @@ nt_SetLinkCount(FdHandle_t * h, Inode ino, int count, int locked) goto bad_SetLinkCount; } - if (!WriteFile(h->fd_fd, (void *)&row, 2, &junk, NULL)) { + if (!WriteFile(h->fd_fd, (void *)&row, 2, &bytesWritten, NULL)) { errno = nterr_nt2unix(GetLastError(), EBADF); goto bad_SetLinkCount; } diff --git a/src/vol/ntops.h b/src/vol/ntops.h index f1f1f36a4..572e5ee1d 100644 --- a/src/vol/ntops.h +++ b/src/vol/ntops.h @@ -60,4 +60,6 @@ int ListViceInodes(char *devname, char *mountedOn, char *resultFile, int nt_HandleToName(char *name, IHandle_t * h); char *nt_HandleToVolDir(char *name, IHandle_t * h); +extern int Testing; + #endif /* _NTOPS_H_ */ diff --git a/src/vol/nuke.c b/src/vol/nuke.c index d9172c48c..9bd9ef114 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -11,7 +11,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/vol/nuke.c,v 1.13.2.2 2004/10/18 17:44:06 shadow Exp $"); + ("$Header: /cvs/openafs/src/vol/nuke.c,v 1.13.2.3 2006/09/03 05:38:09 shadow Exp $"); #include #include @@ -72,7 +72,7 @@ struct ilist { * Note that ainfo->u.param[0] is always the volume ID, for any vice inode. */ static int -NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid, struct ilist *allInodes) +NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid, struct ilist **allInodes) { struct ilist *ti; register afs_int32 i; @@ -85,13 +85,13 @@ NukeProc(struct ViceInodeInfo *ainfo, afs_int32 avolid, struct ilist *allInodes) if (ainfo->u.param[0] != avolid) return 0; /* don't want this one */ /* record the info */ - if (!allInodes || allInodes->freePtr >= MAXATONCE) { + if (!*allInodes || (*allInodes)->freePtr >= MAXATONCE) { ti = (struct ilist *)malloc(sizeof(struct ilist)); memset(ti, 0, sizeof(*ti)); - ti->next = allInodes; - allInodes = ti; + ti->next = *allInodes; + *allInodes = ti; } else - ti = allInodes; /* use the one with space */ + ti = *allInodes; /* use the one with space */ i = ti->freePtr++; /* find our slot in this mess */ ti->inode[i] = ainfo->inodeNumber; ti->count[i] = ainfo->linkCount; @@ -170,11 +170,11 @@ nuke(char *aname, afs_int32 avolid) #ifdef AFS_NAMEI_ENV code = ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid, &forceSal, - 0, wpath, allInodes); + 0, wpath, &allInodes); #else code = ListViceInodes(lastDevComp, aname, "/tmp/vNukeXX", NukeProc, avolid, - &forceSal, 0, wpath, allInodes); + &forceSal, 0, wpath, &allInodes); unlink("/tmp/vNukeXX"); /* clean it up now */ #endif if (code == 0) { diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index db9983b75..215c72e85 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -92,7 +92,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted. #include RCSID - ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.8 2006/06/30 13:59:10 shadow Exp $"); + ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.12 2006/09/05 23:48:50 jaltman Exp $"); #include #include @@ -227,7 +227,7 @@ static char *TimeStamp(time_t clock, int precision); int debug; /* -d flag */ -int Testing = 0; /* -n flag */ +extern int Testing; /* -n flag */ int ListInodeOption; /* -i flag */ int ShowRootFiles; /* -r flag */ int RebuildDirs; /* -sal flag */ @@ -1849,7 +1849,7 @@ CreateLinkTable(register struct InodeSummary *isp, Inode ino) Abort("Can't open link table for volume %u (error = %d)\n", isp->RWvolumeId, errno); - if (FDH_TRUNC(fdP, 0) < 0) + if (FDH_TRUNC(fdP, sizeof(version) + sizeof(short)) < 0) Abort("Can't truncate link table for volume %u (error = %d)\n", isp->RWvolumeId, errno); @@ -1971,7 +1971,23 @@ DoSalvageVolumeGroup(register struct InodeSummary *isp, int nVols) if (Testing) { IH_INIT(VGLinkH, fileSysDevice, -1, -1); } else { + int i, j; + struct ViceInodeInfo *ip; CreateLinkTable(isp, ino); + fdP = IH_OPEN(VGLinkH); + /* Sync fake 1 link counts to the link table, now that it exists */ + if (fdP) { + for (i = 0; i < nVols; i++) { + ip = allInodes + isp[i].index; + for (j = isp[i].nSpecialInodes; j < isp[i].nInodes; j++) { +#ifdef AFS_NT40_ENV + nt_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1); +#else + namei_SetLinkCount(fdP, ip[j].inodeNumber, 1, 1); +#endif + } + } + } } } if (fdP) diff --git a/src/volser/volmain.c b/src/volser/volmain.c index 08de5699c..58c41d5f7 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -11,7 +11,7 @@ #include RCSID - ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.7 2006/08/24 20:21:52 shadow Exp $"); + ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.8 2006/09/03 05:51:42 shadow Exp $"); #include #ifdef AFS_NT40_ENV @@ -95,7 +95,6 @@ int DoLogging = 0; int lwps = 9; int udpBufSize = 0; /* UDP buffer size for receive */ -int Testing = 0; /* for ListViceInodes */ int rxBind = 0; #define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */ -- 2.39.5