diff options
Diffstat (limited to 'sys/xfs')
30 files changed, 951 insertions, 433 deletions
diff --git a/sys/xfs/nxfs.h b/sys/xfs/nxfs.h index 1083484d7c8..6c1052b0926 100644 --- a/sys/xfs/nxfs.h +++ b/sys/xfs/nxfs.h @@ -1 +1 @@ -#define NXFS 2 +#define NXFS 2 /* maximum number of filesystems on a single device */ diff --git a/sys/xfs/xfs_attr.h b/sys/xfs/xfs_attr.h index 71c79bd5014..f3f70efc377 100644 --- a/sys/xfs/xfs_attr.h +++ b/sys/xfs/xfs_attr.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_attr.h,v 1.4 2000/09/11 14:26:51 art Exp $ */ +/* $Id: xfs_attr.h,v 1.5 2002/06/07 04:10:32 hin Exp $ */ #ifndef _XFS_ATTR_H #define _XFS_ATTR_H diff --git a/sys/xfs/xfs_common-bsd.c b/sys/xfs/xfs_common-bsd.c index b5501d1f57a..486127625cc 100644 --- a/sys/xfs/xfs_common-bsd.c +++ b/sys/xfs/xfs_common-bsd.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <xfs/xfs_common.h> #include <xfs/xfs_deb.h> -RCSID("$Id: xfs_common-bsd.c,v 1.3 2000/09/11 14:26:51 art Exp $"); +RCSID("$Id: xfs_common-bsd.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); #ifdef MALLOC_DEFINE MALLOC_DEFINE(M_XFS, "xfs", "xfs buffer"); @@ -82,15 +77,6 @@ xfs_suser(struct proc *p) #endif } -#ifndef HAVE_KERNEL_MEMCPY -void * -memcpy (void *s1, const void *s2, size_t n) -{ - bcopy (s2, s1, n); - return s1; -} -#endif - /* * Print a `dev_t' in some readable format */ diff --git a/sys/xfs/xfs_common.h b/sys/xfs/xfs_common.h index bf6cbd31830..738ebe42b3f 100644 --- a/sys/xfs/xfs_common.h +++ b/sys/xfs/xfs_common.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_common.h,v 1.5 2000/09/11 14:26:51 art Exp $ */ +/* $Id: xfs_common.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_common_h #define _xfs_common_h @@ -69,4 +64,9 @@ memcpy (void *s1, const void *s2, size_t n); const char * xfs_devtoname_r (dev_t dev, char *buf, size_t sz); +#ifndef HAVE_KERNEL_STRLCPY +size_t +strlcpy (char *dst, const char *src, size_t dst_sz); +#endif + #endif /* _xfs_common_h */ diff --git a/sys/xfs/xfs_config.h b/sys/xfs/xfs_config.h index 2249b2be0f4..f96423b5831 100644 --- a/sys/xfs/xfs_config.h +++ b/sys/xfs/xfs_config.h @@ -34,6 +34,9 @@ /* Define if you have the chown function. */ #define HAVE_CHOWN 1 +/* Define if you have the copyhostent function. */ +/* #undef HAVE_COPYHOSTENT */ + /* Define if you have the daemon function. */ #define HAVE_DAEMON 1 @@ -61,6 +64,21 @@ /* Define if you have the flock function. */ #define HAVE_FLOCK 1 +/* Define if you have the freeaddrinfo function. */ +#define HAVE_FREEADDRINFO 1 + +/* Define if you have the freehostent function. */ +/* #undef HAVE_FREEHOSTENT */ + +/* Define if you have the gai_strerror function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define if you have the get_progname function. */ +/* #undef HAVE_GET_PROGNAME */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + /* Define if you have the getcwd function. */ #define HAVE_GETCWD 1 @@ -73,9 +91,24 @@ /* Define if you have the gethostbyname function. */ #define HAVE_GETHOSTBYNAME 1 +/* Define if you have the gethostbyname2 function. */ +#define HAVE_GETHOSTBYNAME2 1 + +/* Define if you have the getipnodebyaddr function. */ +/* #undef HAVE_GETIPNODEBYADDR */ + +/* Define if you have the getipnodebyname function. */ +/* #undef HAVE_GETIPNODEBYNAME */ + /* Define if you have the getitimer function. */ #define HAVE_GETITIMER 1 +/* Define if you have the getlogin function. */ +#define HAVE_GETLOGIN 1 + +/* Define if you have the getnameinfo function. */ +#define HAVE_GETNAMEINFO 1 + /* Define if you have the getopt function. */ #define HAVE_GETOPT 1 @@ -85,6 +118,9 @@ /* Define if you have the getrlimit function. */ #define HAVE_GETRLIMIT 1 +/* Define if you have the getrusage function. */ +#define HAVE_GETRUSAGE 1 + /* Define if you have the getspnam function. */ /* #undef HAVE_GETSPNAM */ @@ -94,15 +130,18 @@ /* Define if you have the getusershell function. */ #define HAVE_GETUSERSHELL 1 -/* Define if you have the getvfsbyname function. */ -/* #undef HAVE_GETVFSBYNAME */ - /* Define if you have the hstrerror function. */ #define HAVE_HSTRERROR 1 /* Define if you have the inet_aton function. */ #define HAVE_INET_ATON 1 +/* Define if you have the inet_ntop function. */ +#define HAVE_INET_NTOP 1 + +/* Define if you have the inet_pton function. */ +#define HAVE_INET_PTON 1 + /* Define if you have the initgroups function. */ #define HAVE_INITGROUPS 1 @@ -130,6 +169,9 @@ /* Define if you have the kernel_aout_sysent function. */ /* #undef HAVE_KERNEL_AOUT_SYSENT */ +/* Define if you have the kernel_cache_purgevfs function. */ +#define HAVE_KERNEL_CACHE_PURGEVFS 1 + /* Define if you have the kernel_cdevsw_add function. */ /* #undef HAVE_KERNEL_CDEVSW_ADD */ @@ -163,6 +205,9 @@ /* Define if you have the kernel_snprintf function. */ #define HAVE_KERNEL_SNPRINTF 1 +/* Define if you have the kernel_strlcpy function. */ +#define HAVE_KERNEL_STRLCPY 1 + /* Define if you have the kernel_sys_lkmnosys function. */ #define HAVE_KERNEL_SYS_LKMNOSYS 1 @@ -181,12 +226,18 @@ /* Define if you have the kernel_vfs_cache_lookup function. */ /* #undef HAVE_KERNEL_VFS_CACHE_LOOKUP */ +/* Define if you have the kernel_vfs_deallocate_syncvnode function. */ +/* #undef HAVE_KERNEL_VFS_DEALLOCATE_SYNCVNODE */ + /* Define if you have the kernel_vfs_getnewfsid function. */ #define HAVE_KERNEL_VFS_GETNEWFSID 1 /* Define if you have the kernel_vfs_getvfs function. */ #define HAVE_KERNEL_VFS_GETVFS 1 +/* Define if you have the kernel_vfs_name_hash function. */ +/* #undef HAVE_KERNEL_VFS_NAME_HASH */ + /* Define if you have the kernel_vfs_object_create function. */ /* #undef HAVE_KERNEL_VFS_OBJECT_CREATE */ @@ -253,6 +304,9 @@ /* Define if you have the linux_kernel_u_int8_t function. */ /* #undef HAVE_LINUX_KERNEL_U_INT8_T */ +/* Define if you have the localtime_r function. */ +#define HAVE_LOCALTIME_R 1 + /* Define if you have the lstat function. */ #define HAVE_LSTAT 1 @@ -268,6 +322,9 @@ /* Define if you have the off64_t function. */ /* #undef HAVE_OFF64_T */ +/* Define if you have the pthread_create function. */ +/* #undef HAVE_PTHREAD_CREATE */ + /* Define if you have the putenv function. */ #define HAVE_PUTENV 1 @@ -286,12 +343,21 @@ /* Define if you have the register_t function. */ #define HAVE_REGISTER_T 1 +/* Define if you have the res_init function. */ +#define HAVE_RES_INIT 1 + /* Define if you have the res_search function. */ #define HAVE_RES_SEARCH 1 +/* Define if you have the sa_family_t function. */ +#define HAVE_SA_FAMILY_T 1 + /* Define if you have the sendmsg function. */ #define HAVE_SENDMSG 1 +/* Define if you have the set_progname function. */ +/* #undef HAVE_SET_PROGNAME */ + /* Define if you have the setegid function. */ #define HAVE_SETEGID 1 @@ -301,6 +367,9 @@ /* Define if you have the seteuid function. */ #define HAVE_SETEUID 1 +/* Define if you have the setlogin function. */ +#define HAVE_SETLOGIN 1 + /* Define if you have the setregid function. */ #define HAVE_SETREGID 1 @@ -319,6 +388,9 @@ /* Define if you have the socket function. */ #define HAVE_SOCKET 1 +/* Define if you have the socklen_t function. */ +#define HAVE_SOCKLEN_T 1 + /* Define if you have the ssize_t function. */ #define HAVE_SSIZE_T 1 @@ -358,6 +430,15 @@ /* Define if you have the strtok_r function. */ #define HAVE_STRTOK_R 1 +/* Define if you have the struct_addrinfo function. */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define if you have the struct_sockaddr function. */ +#define HAVE_STRUCT_SOCKADDR 1 + +/* Define if you have the struct_sockaddr_storage function. */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 + /* Define if you have the strupr function. */ /* #undef HAVE_STRUPR */ @@ -370,6 +451,9 @@ /* Define if you have the syslog function. */ #define HAVE_SYSLOG 1 +/* Define if you have the tf_init function. */ +#define HAVE_TF_INIT 1 + /* Define if you have the tgetent function. */ #define HAVE_TGETENT 1 @@ -409,12 +493,6 @@ /* Define if you have the verrx function. */ #define HAVE_VERRX 1 -/* Define if you have the vfsisloadable function. */ -/* #undef HAVE_VFSISLOADABLE */ - -/* Define if you have the vfsload function. */ -/* #undef HAVE_VFSLOAD */ - /* Define if you have the vsnprintf function. */ #define HAVE_VSNPRINTF 1 @@ -430,6 +508,9 @@ /* Define if you have the warn function. */ #define HAVE_WARN 1 +/* Define if you have the warnerr function. */ +/* #undef HAVE_WARNERR */ + /* Define if you have the warnx function. */ #define HAVE_WARNX 1 @@ -484,6 +565,9 @@ /* Define if you have the <linux/devfs_fs_kernel.h> header file. */ /* #undef HAVE_LINUX_DEVFS_FS_KERNEL_H */ +/* Define if you have the <linux/stddef.h> header file. */ +/* #undef HAVE_LINUX_STDDEF_H */ + /* Define if you have the <machine/alpha/asm.h> header file. */ /* #undef HAVE_MACHINE_ALPHA_ASM_H */ @@ -559,6 +643,9 @@ /* Define if you have the <sys/ioctl.h> header file. */ #define HAVE_SYS_IOCTL_H 1 +/* Define if you have the <sys/libkern.h> header file. */ +/* #undef HAVE_SYS_LIBKERN_H */ + /* Define if you have the <sys/lkm.h> header file. */ #define HAVE_SYS_LKM_H 1 @@ -577,6 +664,9 @@ /* Define if you have the <sys/poll.h> header file. */ #define HAVE_SYS_POLL_H 1 +/* Define if you have the <sys/prctl.h> header file. */ +/* #undef HAVE_SYS_PRCTL_H */ + /* Define if you have the <sys/proc.h> header file. */ #define HAVE_SYS_PROC_H 1 @@ -616,6 +706,9 @@ /* Define if you have the <sys/sysproto.h> header file. */ /* #undef HAVE_SYS_SYSPROTO_H */ +/* Define if you have the <sys/systm.h> header file. */ +/* #undef HAVE_SYS_SYSTM_H */ + /* Define if you have the <sys/time.h> header file. */ #define HAVE_SYS_TIME_H 1 @@ -625,6 +718,9 @@ /* Define if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 +/* Define if you have the <sys/ubc.h> header file. */ +/* #undef HAVE_SYS_UBC_H */ + /* Define if you have the <sys/uio.h> header file. */ #define HAVE_SYS_UIO_H 1 @@ -637,6 +733,12 @@ /* Define if you have the <sys/vfs.h> header file. */ /* #undef HAVE_SYS_VFS_H */ +/* Define if you have the <sys/vfs_proto.h> header file. */ +/* #undef HAVE_SYS_VFS_PROTO_H */ + +/* Define if you have the <sys/vnode.h> header file. */ +#define HAVE_SYS_VNODE_H 1 + /* Define if you have the <sys/wait.h> header file. */ #define HAVE_SYS_WAIT_H 1 @@ -679,6 +781,12 @@ /* Define if you have the editline library (-leditline). */ /* #undef HAVE_LIBEDITLINE */ +/* Define if you have the inet6 library (-linet6). */ +/* #undef HAVE_LIBINET6 */ + +/* Define if you have the ip6 library (-lip6). */ +/* #undef HAVE_LIBIP6 */ + /* Define if you have the kvm library (-lkvm). */ #define HAVE_LIBKVM 1 @@ -688,6 +796,9 @@ /* Define if you have the nsl library (-lnsl). */ /* #undef HAVE_LIBNSL */ +/* Define if you have the pthread library (-lpthread). */ +/* #undef HAVE_LIBPTHREAD */ + /* Define if you have the readline library (-lreadline). */ #define HAVE_LIBREADLINE 1 @@ -707,7 +818,7 @@ #define PACKAGE "arla" /* and what version? */ -#define VERSION "0.35pre" +#define VERSION "0.35.7" /* how should ntohl be done? */ #define EFF_NTOHL ntohl @@ -725,7 +836,7 @@ /* #undef HAVE_KRB5_COMPAT_KRB4 */ /* define if you have kerberos 5 */ -/* #undef HAVE_KRB5 */ +#define HAVE_KRB5 1 /* define if you have kerberos */ #define KERBEROS 1 @@ -751,6 +862,9 @@ /* define if you have krb_get_default_tkt_root */ #define HAVE_KRB_GET_DEFAULT_TKT_ROOT 1 +/* define if you have krb_get_default_principal */ +#define HAVE_KRB_GET_DEFAULT_PRINCIPAL 1 + /* define if you have krb_kdctimeofday */ #define HAVE_KRB_KDCTIMEOFDAY 1 @@ -767,7 +881,7 @@ /* #undef HAVE_GLIBC */ /* define if target is big endian */ -#define WORDS_BIGENDIAN 1 +/* #undef WORDS_BIGENDIAN */ /* define if sys/param.h defines the endiness */ #define ENDIANESS_IN_SYS_PARAM_H 1 @@ -793,6 +907,9 @@ /* define if struct winsize has ws_ypixel */ #define HAVE_WS_YPIXEL 1 +/* Define if you have IPv6. */ +#define HAVE_IPV6 1 + /* define if you have a working snprintf */ #define HAVE_SNPRINTF 1 @@ -802,11 +919,8 @@ /* define if you have sigaction */ #define HAVE_POSIX_SIGNALS 1 -/* define if you have res */ -/* #undef HAVE_RES */ - -/* define if your system declares res */ -/* #undef HAVE_RES_DECLARATION */ +/* Define if getlogin has POSIX flavour (and not BSD). */ +/* #undef POSIX_GETLOGIN */ /* define if the system is missing a prototype for hstrerror() */ /* #undef NEED_HSTRERROR_PROTO */ @@ -817,9 +931,6 @@ /* define if the system is missing a prototype for inet_aton() */ /* #undef NEED_INET_ATON_PROTO */ -/* define if getvfsbyname takes two arguments */ -/* #undef HAVE_GETVFSBYNAME_TWO_ARGS */ - /* define if you have optreset */ #define HAVE_OPTRESET 1 @@ -844,6 +955,9 @@ /* Define if struct sockaddr has field sa_len. */ #define HAVE_STRUCT_SOCKADDR_SA_LEN 1 +/* Define if struct sockaddr_in has field sin_len. */ +#define HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 + /* define if you have h_errno */ #define HAVE_H_ERRNO 1 @@ -865,6 +979,21 @@ /* define this if your as understands .register */ /* #undef AS_UNDERSTANDS_REGISTER */ +/* define if the system is missing a prototype for vgonel() */ +/* #undef NEED_VGONEL_PROTO */ + +/* define if the system is missing a prototype for issignal() */ +/* #undef NEED_ISSIGNAL_PROTO */ + +/* define if the system is missing a prototype for vn_writechk() */ +/* #undef NEED_VN_WRITECHK_PROTO */ + +/* define if the system is missing a prototype for ubc_pushdirty() */ +#define NEED_UBC_PUSHDIRTY_PROTO 1 + +/* define if the system is missing a prototype for strncmp() */ +#define NEED_STRNCMP_PROTO 1 + /* define if you have a vop_t */ /* #undef HAVE_VOP_T */ @@ -910,9 +1039,18 @@ /* define if lockstatus takes one argument */ #define HAVE_ONE_ARGUMENT_LOCKSTATUS 1 +/* define if selrecord takes three arguments */ +/* #undef HAVE_THREE_ARGUMENT_SELRECORD */ + /* define if ubc_lookup takes six arguments */ /* #undef HAVE_SIX_ARGUMENT_UBC_LOOKUP */ +/* define if vfs_name_hash takes four arguments */ +/* #undef HAVE_FOUR_ARGUMENT_VFS_NAME_HASH */ + +/* define if vfs_name_hash takes three arguments */ +/* #undef HAVE_THREE_ARGUMENT_VFS_NAME_HASH */ + /* define if DIRSIZ is defined in dirent.h */ /* #undef DIRSIZ_IN_DIRENT_H */ @@ -925,9 +1063,15 @@ /* Define if struct proc has field p_sigmask. */ #define HAVE_STRUCT_PROC_P_SIGMASK 1 +/* Define if struct proc has field p_sigctx. */ +/* #undef HAVE_STRUCT_PROC_P_SIGCTX */ + /* Define if struct mount has field mnt_syncer */ #define HAVE_STRUCT_MOUNT_MNT_SYNCER 1 +/* Define if struct mount has field mnt_nvnodelist */ +/* #undef HAVE_STRUCT_MOUNT_MNT_NVNODELIST */ + /* Define if struct mount has field m_info */ /* #undef HAVE_STRUCT_MOUNT_M_INFO */ @@ -949,6 +1093,9 @@ /* Define if struct vfsops has field vfs_uninit */ /* #undef HAVE_STRUCT_VFSOPS_VFS_UNINIT */ +/* Define if struct vfsops has field vfs_reinit */ +/* #undef HAVE_STRUCT_VFSOPS_VFS_REINIT */ + /* Define if struct vfsops has field vfs_oid */ /* #undef HAVE_STRUCT_VFSOPS_VFS_OID */ @@ -958,9 +1105,27 @@ /* Define if struct vfsops has field vfs_checkexp */ #define HAVE_STRUCT_VFSOPS_VFS_CHECKEXP 1 +/* Define if struct vfsops has field vfs_mountroot */ +/* #undef HAVE_STRUCT_VFSOPS_VFS_MOUNTROOT */ + +/* Define if struct vfsops has field vfs_swapvp */ +/* #undef HAVE_STRUCT_VFSOPS_VFS_SWAPVP */ + +/* Define if struct vfsops has field vfs_smoothsync */ +/* #undef HAVE_STRUCT_VFSOPS_VFS_SMOOTHSYNC */ + +/* Define if struct sysent has field sy_flags */ +/* #undef HAVE_STRUCT_SYSENT_SY_FLAGS */ + +/* Define if struct sysent has field sy_info */ +/* #undef HAVE_STRUCT_SYSENT_SY_INFO */ + /* Define if struct vop_fsync_args has field a_flags */ /* #undef HAVE_STRUCT_VOP_FSYNC_ARGS_A_FLAGS */ +/* Define if struct vop_putpages_args has field a_sync */ +/* #undef HAVE_STRUCT_VOP_PUTPAGES_ARGS_A_SYNC */ + /* Define if struct proc has field p_retval */ /* #undef HAVE_STRUCT_PROC_P_RETVAL */ @@ -991,9 +1156,15 @@ /* Define if struct cdevsw has field d_maxio */ /* #undef HAVE_STRUCT_CDEVSW_D_MAXIO */ +/* Define if struct cdevsw has field d_bmaj */ +/* #undef HAVE_STRUCT_CDEVSW_D_BMAJ */ + /* Define if struct componentname has field cn_hash */ #define HAVE_STRUCT_COMPONENTNAME_CN_HASH 1 +/* define if we only can include uvm headers */ +/* #undef HAVE_KERNEL_UVM_ONLY */ + /* define if d_alloc_root takes two arguments */ /* #undef HAVE_D_ALLOC_ROOT_TWO_ARGS */ @@ -1021,12 +1192,30 @@ /* define if you have a wait_queue_head_t */ /* #undef HAVE_WAIT_QUEUE_HEAD_T */ +/* define if you have a wait_queue_task_list */ +/* #undef HAVE_WAIT_QUEUE_TASK_LIST */ + /* define if you have a init_waitqueue_head */ /* #undef HAVE_INIT_WAITQUEUE_HEAD */ /* define if you have a function init_MUTEX */ /* #undef HAVE_INIT_MUTEX */ +/* define if you have a function list_del_init */ +/* #undef HAVE_LIST_DEL_INIT */ + +/* define if filldir_t takes a dt_type argument */ +/* #undef HAVE_FILLDIR_T_DT_TYPE */ + +/* define if you have a function dget_locked */ +/* #undef HAVE_DGET_LOCKED */ + +/* Define if struct task_struct has field pending */ +/* #undef HAVE_STRUCT_TASK_STRUCT_PENDING */ + +/* define if d_delete in struct dentry_operations returns void */ +/* #undef HAVE_D_DELETE_VOID */ + /* Define if struct vfsops has field vfs_freevfs */ /* #undef HAVE_STRUCT_VFSOPS_VFS_FREEVFS */ diff --git a/sys/xfs/xfs_deb.c b/sys/xfs/xfs_deb.c index 9be92277178..be655c777d5 100644 --- a/sys/xfs/xfs_deb.c +++ b/sys/xfs/xfs_deb.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,7 +34,7 @@ #include <xfs/xfs_deb.h> #include <xfs/xfs_debug.h> -/* $Id: xfs_deb.c,v 1.4 2000/09/11 14:26:51 art Exp $ */ +/* $Id: xfs_deb.c,v 1.5 2002/06/07 04:10:32 hin Exp $ */ /* X is on */ #define X(y) y diff --git a/sys/xfs/xfs_deb.h b/sys/xfs/xfs_deb.h index bfcfccd640a..5c37a157929 100644 --- a/sys/xfs/xfs_deb.h +++ b/sys/xfs/xfs_deb.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_deb.h,v 1.5 2000/09/11 14:26:51 art Exp $ */ +/* $Id: xfs_deb.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_deb_h #define _xfs_deb_h diff --git a/sys/xfs/xfs_debug.h b/sys/xfs/xfs_debug.h index 3fa58ac7da3..d96d4c80d5a 100644 --- a/sys/xfs/xfs_debug.h +++ b/sys/xfs/xfs_debug.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_debug.h,v 1.3 2000/09/11 14:26:51 art Exp $ */ +/* $Id: xfs_debug.h,v 1.4 2002/06/07 04:10:32 hin Exp $ */ #ifndef __XFS_DEBUG_H #define __XFS_DEBUG_H diff --git a/sys/xfs/xfs_dev-bsd.c b/sys/xfs/xfs_dev-bsd.c index f8922108fd4..a310d119a71 100644 --- a/sys/xfs/xfs_dev-bsd.c +++ b/sys/xfs/xfs_dev-bsd.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,14 +38,14 @@ #include <xfs/xfs_dev.h> #include <xfs/xfs_deb.h> -RCSID("$Id: xfs_dev-bsd.c,v 1.3 2000/09/11 14:26:51 art Exp $"); +RCSID("$Id: xfs_dev-bsd.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); int xfs_devopen(dev_t dev, int flag, int devtype, struct proc *proc) { XFSDEB(XDEBDEV, ("xfsopen dev = %d.%d, flag = %d, devtype = %d\n", major(dev), minor(dev), flag, devtype)); - return xfs_devopen_common(dev); + return xfs_devopen_common(dev, proc); } int @@ -85,14 +80,18 @@ xfs_devioctl(dev_t dev, } static int -xfs_realselect(dev_t dev, struct proc *p) +xfs_realselect(dev_t dev, struct proc *p, void *wql) { struct xfs_channel *chan = &xfs_channel[minor(dev)]; if (!xfs_emptyq(&chan->messageq)) return 1; /* Something to read */ +#ifdef HAVE_THREE_ARGUMENT_SELRECORD + selrecord (p, &chan->selinfo, wql); +#else selrecord (p, &chan->selinfo); +#endif return 0; } @@ -110,23 +109,35 @@ xfs_devpoll(dev_t dev, int events, struct proc * p) if (!(events & POLLRDNORM)) return 0; - return xfs_realselect(dev, p); + return xfs_realselect(dev, p, NULL); } #endif #ifdef HAVE_VOP_SELECT +#ifdef HAVE_THREE_ARGUMENT_SELRECORD int -xfs_devselect(dev_t dev, int which, struct proc * p) +xfs_devselect(dev_t dev, int which, void *wql, struct proc * p) { XFSDEB(XDEBDEV, ("xfs_devselect dev = %d, which = %d\n", dev, which)); if (which != FREAD) return 0; - return xfs_realselect(dev, p); + return xfs_realselect(dev, p, wql); } +#else +int +xfs_devselect(dev_t dev, int which, struct proc * p) +{ + XFSDEB(XDEBDEV, ("xfs_devselect dev = %d, which = %d\n", dev, which)); + if (which != FREAD) + return 0; + + return xfs_realselect(dev, p, NULL); +} +#endif #endif void @@ -207,11 +218,13 @@ struct cdevsw xfs_dev = { #ifdef HAVE_STRUCT_CDEVSW_D_MAXIO 0, /* maxio */ #endif +#ifdef HAVE_STRUCT_CDEVSW_D_BMAJ #ifdef NOUDEV NOUDEV /* bmaj */ #else NODEV /* bmaj */ #endif +#endif /* HAVE_STRUCT_CDEVSW_D_BMAJ */ }; #elif defined(__APPLE__) @@ -309,7 +322,7 @@ xfs_stat_device(void) return xfs_uprintf_device(); } -#if !defined(_LKM) && !defined(KLD_MODULE) +#if !defined(_LKM) && !defined(KLD_MODULE) && !defined(__APPLE__) int xfs_is_xfs_dev(dev_t dev) { diff --git a/sys/xfs/xfs_dev-common.c b/sys/xfs/xfs_dev-common.c index ecbc3f1902e..929e8a41628 100644 --- a/sys/xfs/xfs_dev-common.c +++ b/sys/xfs/xfs_dev-common.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -44,7 +39,7 @@ #include <xfs/xfs_dev.h> #include <xfs/xfs_deb.h> -RCSID("$Id: xfs_dev-common.c,v 1.3 2000/09/11 14:26:51 art Exp $"); +RCSID("$Id: xfs_dev-common.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); struct xfs_channel xfs_channel[NXFS]; @@ -92,7 +87,7 @@ xfs_outq(struct xfs_link *p) * Only allow one open. */ int -xfs_devopen_common(dev_t dev) +xfs_devopen_common(dev_t dev, struct proc *p) { struct xfs_channel *chan; @@ -105,8 +100,9 @@ xfs_devopen_common(dev_t dev) if (chan->status & CHANNEL_OPENED) { XFSDEB(XDEBDEV, ("xfs_devopen: already open\n")); return EBUSY; - } else + } else { chan->status |= CHANNEL_OPENED; + } chan->message_buffer = xfs_alloc(MAX_XMSG_SIZE); @@ -233,6 +229,8 @@ xfs_devread(dev_t dev, struct uio * uiop, int ioflag) (unsigned long)chan->messageq.prev, (unsigned long)chan->messageq.next)); + chan->proc = xfs_uio_to_proc(uiop); + again: if (!xfs_emptyq (&chan->messageq)) { @@ -298,6 +296,7 @@ xfs_devwrite(dev_t dev, struct uio *uiop, int ioflag) XFSDEB(XDEBDEV, ("xfs_devwrite dev = %s\n", xfs_devtoname_r (dev, devname, sizeof(devname)))); + chan->proc = xfs_uio_to_proc(uiop); cnt = uiop->uio_resid; error = uiomove((caddr_t) chan->message_buffer, MAX_XMSG_SIZE, uiop); if (error != 0) @@ -367,29 +366,61 @@ xfs_message_send(int fd, struct xfs_message_header * message, u_int size) #error what is your exit named ? #endif +#if defined(HAVE_STRUCT_PROC_P_SIGMASK) || defined(HAVE_STRUCT_PROC_P_SIGCTX) +static void +xfs_block_sigset (sigset_t *sigset) +{ +#if defined(__sigaddset) + __sigaddset(sigset, SIGIO); + __sigaddset(sigset, SIGALRM); + __sigaddset(sigset, SIGVTALRM); +#elif defined(SIGADDSET) + SIGADDSET(*sigset, SIGIO); + SIGADDSET(*sigset, SIGALRM); + SIGADDSET(*sigset, SIGVTALRM); +#else + *sigset |= sigmask(SIGIO); + *sigset |= sigmask(SIGALRM); + *sigset |= sigmask(SIGVTALRM); +#endif /* __sigaddset */ +} +#endif + /* * Send a message to user space and wait for reply. */ int -xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size) +xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size, + struct proc *proc) { int ret; struct xfs_channel *chan = &xfs_channel[fd]; struct xfs_link *this_message; struct xfs_link *this_process; struct xfs_message_header *msg; -#if defined(HAVE_STRUCT_PROC_P_SIGMASK) +#if defined(HAVE_STRUCT_PROC_P_SIGMASK) || defined(HAVE_STRUCT_PROC_P_SIGCTX) || defined(__osf__) sigset_t oldsigmask; -#endif /* HAVE_STRUCT_PROC_P_SIGMASK */ +#endif int catch; - struct proc *proc = xfs_curproc (); XFSDEB(XDEBMSG, ("xfs_message_rpc opcode = %d\n", message->opcode)); + if (proc == NULL) + proc = xfs_curproc(); + if (!(chan->status & CHANNEL_OPENED)) /* No receiver? */ return ENODEV; + if (chan->proc != NULL && proc->p_pid == chan->proc->p_pid) { + printf("xfs_message_rpc: deadlock avoided " + "pid = %u == %u\n", proc->p_pid, chan->proc->p_pid); +#if 0 + psignal (proc, SIGABRT); +#endif + return EDEADLK; + } + if (size < sizeof(struct xfs_message_wakeup)) { printf("XFS PANIC Error: Message to small to receive wakeup, opcode = %d\n", message->opcode); return ENOMEM; @@ -420,25 +451,24 @@ xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size) */ #ifdef HAVE_STRUCT_PROC_P_SIGMASK + /* NetBSD 1.5, Darwin 1.3, FreeBSD 4.3, 5.0, OpenBSD 2.8 */ oldsigmask = proc->p_sigmask; -#if defined(__sigaddset) - __sigaddset(&proc->p_sigmask, SIGIO); - __sigaddset(&proc->p_sigmask, SIGALRM); - __sigaddset(&proc->p_sigmask, SIGVTALRM); -#elif defined(SIGADDSET) - SIGADDSET(proc->p_sigmask, SIGIO); - SIGADDSET(proc->p_sigmask, SIGALRM); - SIGADDSET(proc->p_sigmask, SIGVTALRM); -#else - proc->p_sigmask |= sigmask(SIGIO); - proc->p_sigmask |= sigmask(SIGALRM); - proc->p_sigmask |= sigmask(SIGVTALRM); -#endif /* __sigaddset */ + xfs_block_sigset (&proc->p_sigmask); +#elif defined(HAVE_STRUCT_PROC_P_SIGCTX) + /* NetBSD 1.6 */ + oldsigmask = proc->p_sigctx.ps_sigmask; + xfs_block_sigset (&proc->p_sigctx.ps_sigmask); #elif defined(HAVE_STRUCT_PROC_P_SIGWAITMASK) + /* OSF 4.0 */ oldsigmask = proc->p_sigwaitmask; sigaddset(&proc->p_sigwaitmask, SIGIO); sigaddset(&proc->p_sigwaitmask, SIGALRM); sigaddset(&proc->p_sigwaitmask, SIGVTALRM); +#elif defined(__osf__) + oldsigmask = u.u_sigmask; + sigaddset(&u.u_sigmask, SIGIO); + sigaddset(&u.u_sigmask, SIGALRM); + sigaddset(&u.u_sigmask, SIGVTALRM); #endif /* @@ -469,8 +499,12 @@ xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size) #ifdef HAVE_STRUCT_PROC_P_SIGMASK proc->p_sigmask = oldsigmask; +#elif defined(HAVE_STRUCT_PROC_P_SIGCTX) + proc->p_sigctx.ps_sigmask = oldsigmask; #elif defined(HAVE_STRUCT_PROC_P_SIGWAITMASK) proc->p_sigwaitmask = oldsigmask; +#elif defined(__osf__) + u.u_sigmask = oldsigmask; #endif /* diff --git a/sys/xfs/xfs_dev.h b/sys/xfs/xfs_dev.h index 6b7ef481fe8..4531dfdb512 100644 --- a/sys/xfs/xfs_dev.h +++ b/sys/xfs/xfs_dev.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_dev.h,v 1.5 2000/09/11 14:26:52 art Exp $ */ +/* $Id: xfs_dev.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_dev_h #define _xfs_dev_h @@ -68,6 +63,7 @@ struct xfs_channel { int status; #define CHANNEL_OPENED 0x1 #define CHANNEL_WAITING 0x2 + struct proc *proc; }; extern struct xfs_channel xfs_channel[NXFS]; @@ -108,14 +104,18 @@ void xfs_outq(struct xfs_link *p); int -xfs_devopen_common(dev_t dev); +xfs_devopen_common(dev_t dev, struct proc *); #ifndef __osf__ /* XXX - we should do the same for osf */ int xfs_devopen(dev_t dev, int flag, int devtype, struct proc *proc); int xfs_devclose(dev_t dev, int flag, int devtype, struct proc *proc); int xfs_devioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p); +#ifdef HAVE_THREE_ARGUMENT_SELRECORD +int xfs_devselect(dev_t dev, int which, void *wql, struct proc *p); +#else int xfs_devselect(dev_t dev, int which, struct proc *p); +#endif #endif /* ! __osf__ */ int @@ -131,7 +131,8 @@ int xfs_message_send(int fd, struct xfs_message_header * message, u_int size); int -xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size); +xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size, + struct proc *p); int xfs_message_receive(int fd, diff --git a/sys/xfs/xfs_extern.h b/sys/xfs/xfs_extern.h index 812a710fdf8..a74a34a94a4 100644 --- a/sys/xfs/xfs_extern.h +++ b/sys/xfs/xfs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xfs_extern.h,v 1.4 2002/03/14 01:27:19 millert Exp $ */ +/* $OpenBSD: xfs_extern.h,v 1.5 2002/06/07 04:10:32 hin Exp $ */ /* * Copyright (c) 1998 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). diff --git a/sys/xfs/xfs_fs.h b/sys/xfs/xfs_fs.h index 3ccfe00fa5d..bdab1525ea8 100644 --- a/sys/xfs/xfs_fs.h +++ b/sys/xfs/xfs_fs.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_fs.h,v 1.5 2000/09/11 14:26:52 art Exp $ */ +/* $Id: xfs_fs.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_h #define _xfs_h @@ -47,7 +42,7 @@ #include <xfs/xfs_node.h> #include <xfs/xfs_attr.h> -#define NXFS 2 /* maximal number of filesystems on a single device */ +#include <xfs/nxfs.h> /* * Filesystem struct. @@ -93,7 +88,7 @@ int xfs_dnlc_lookup(struct vnode *, xfs_componentname *, struct vnode **); int xfs_dnlc_lookup_name(struct vnode *, const char *, struct vnode **); void vattr2xfs_attr(const struct vattr *, struct xfs_attr *); -void xfs_attr2vattr(const struct xfs_attr *, struct vattr *); +void xfs_attr2vattr(const struct xfs_attr *, struct vattr *, int); int xfs_has_pag(const struct xfs_node *, xfs_pag_t); diff --git a/sys/xfs/xfs_locl.h b/sys/xfs/xfs_locl.h index b46093e0bb4..80999053858 100644 --- a/sys/xfs/xfs_locl.h +++ b/sys/xfs/xfs_locl.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_locl.h,v 1.4 2001/06/27 04:58:49 art Exp $ */ +/* $Id: xfs_locl.h,v 1.5 2002/06/07 04:10:32 hin Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -111,7 +106,7 @@ typedef struct nameidata xfs_componentname; #define xfs_uio_to_proc(uiop) (u.u_procp) #define xfs_cnp_to_proc(cnp) (u.u_procp) #define xfs_proc_to_cred(p) ((p)->p_rcred) -#define xfs_proc_to_ruid(p) ((p)->p_ruid) +#define xfs_proc_to_euid(p) ((p)->p_rcred->cr_uid) #define xfs_curproc() (u.u_procp) @@ -122,6 +117,8 @@ typedef struct nameidata xfs_componentname; struct vop_generic_args; +typedef u_long va_size_t; + #else /* !__osf__ */ typedef struct componentname xfs_componentname; @@ -177,6 +174,7 @@ typedef struct componentname xfs_componentname; #ifdef HAVE_MISCFS_GENFS_GENFS_H #include <miscfs/genfs/genfs.h> #endif +#ifndef HAVE_KERNEL_UVM_ONLY #ifdef HAVE_VM_VM_H #include <vm/vm.h> #endif @@ -189,6 +187,7 @@ typedef struct componentname xfs_componentname; #ifdef HAVE_VM_VM_OBJECT_H #include <vm/vm_object.h> #endif +#endif #ifdef HAVE_UVM_UVM_EXTERN_H #include <uvm/uvm_extern.h> #endif @@ -196,6 +195,7 @@ typedef struct componentname xfs_componentname; #if defined(__APPLE__) #include <machine/machine_routines.h> #include <mach/machine/vm_types.h> +#include <sys/ubc.h> void cache_purge(struct vnode *); int cache_lookup(struct vnode *, struct vnode **, struct componentname *); void cache_enter(struct vnode *, struct vnode *, struct componentname *); @@ -205,7 +205,7 @@ void cache_purgevfs(struct mount *); #define xfs_uio_to_proc(uiop) ((uiop)->uio_procp) #define xfs_cnp_to_proc(cnp) ((cnp)->cn_proc) #define xfs_proc_to_cred(p) ((p)->p_ucred) -#define xfs_proc_to_ruid(p) ((p)->p_cred->p_ruid) +#define xfs_proc_to_euid(p) ((p)->p_ucred->cr_uid) #ifdef __APPLE__ #define xfs_curproc() (current_proc()) @@ -218,6 +218,8 @@ void cache_purgevfs(struct mount *); #define xfs_vop_getattr(t, attr, cred, proc, error) (error) = VOP_GETATTR((t), (attr), (cred), (proc)) #define xfs_vop_access(dvp, mode, cred, proc, error) (error) = VOP_ACCESS((dvp), (mode), (cred), (proc)) +typedef u_quad_t va_size_t; + #endif /* !__osf__ */ /* @@ -268,10 +270,12 @@ struct xfs_setgroups_args{ #define xfs_vfs_object_create(vp,proc,ucred) vfs_object_create(vp,proc,ucred) #endif -#ifdef __OpenBSD__ +#ifdef UVM #define xfs_set_vp_size(vp, sz) uvm_vnp_setsize(vp, sz) #elif HAVE_KERNEL_VNODE_PAGER_SETSIZE #define xfs_set_vp_size(vp, sz) vnode_pager_setsize(vp, sz) +#elif defined(__APPLE__) +#define xfs_set_vp_size(vp, sz) ubc_setsize(vp, sz) #else #define xfs_set_vp_size(vp, sz) #endif diff --git a/sys/xfs/xfs_message.c b/sys/xfs/xfs_message.c index de1dd1c7810..cc4a349b13a 100644 --- a/sys/xfs/xfs_message.c +++ b/sys/xfs/xfs_message.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -46,7 +41,7 @@ #include <xfs/xfs_vnodeops.h> #include <xfs/xfs_dev.h> -RCSID("$Id: xfs_message.c,v 1.7 2000/09/11 14:26:52 art Exp $"); +RCSID("$Id: xfs_message.c,v 1.8 2002/06/07 04:10:32 hin Exp $"); int xfs_message_installroot(int fd, @@ -139,7 +134,7 @@ xfs_message_installattr(int fd, printf ("xfs_message_installattr: tokens and no data\n"); t->tokens &= ~XFS_DATA_MASK; } - xfs_attr2vattr(&message->node.attr, &t->attr); + xfs_attr2vattr(&message->node.attr, &t->attr, 0); xfs_set_vp_size(XNODE_TO_VNODE(t), t->attr.va_size); bcopy(message->node.id, t->id, sizeof(t->id)); bcopy(message->node.rights, t->rights, sizeof(t->rights)); @@ -147,7 +142,7 @@ xfs_message_installattr(int fd, } else { XFSDEB(XDEBMSG, ("xfs_message_installattr: no such node\n")); } - + return error; } @@ -173,12 +168,17 @@ retry: struct vnode *vp; struct vnode *t_vnode = XNODE_TO_VNODE(t); + message->cache_name[sizeof(message->cache_name)-1] = '\0'; XFSDEB(XDEBMSG, ("cache_name = '%s'\n", message->cache_name)); if (xfs_do_vget(t_vnode, 0 /* LK_SHARED */, p)) goto retry; - error = xfs_fhlookup (p, fh, &vp); + if (message->flag & XFS_ID_HANDLE_VALID) { + error = xfs_fhlookup (p, fh, &vp); + } else { + error = EINVAL; + } if (error != 0) { #ifdef __osf__ struct nameidata *ndp = &u.u_nd; @@ -210,7 +210,7 @@ retry: (unsigned long)t, message->node.tokens)); t->tokens = message->node.tokens; - xfs_attr2vattr(&message->node.attr, &t->attr); + xfs_attr2vattr(&message->node.attr, &t->attr, 1); xfs_set_vp_size(XNODE_TO_VNODE(t), t->attr.va_size); if (XNODE_TO_VNODE(t)->v_type == VDIR && (message->flag & XFS_ID_INVALID_DNLC)) @@ -281,6 +281,21 @@ xfs_message_invalidnode(int fd, } #endif /* __FreeBSD__ */ + /* If node is in use, mark as stale */ + if (vp->v_usecount > 0 && vp->v_type != VDIR) { +#ifdef __APPLE__ + if (UBCISVALID(vp) && !ubc_isinuse(vp, 0)) { + ubc_setsize(vp, 0); + } else { + t->flags |= XFS_STALE; + return 0; + } +#else + t->flags |= XFS_STALE; + return 0; +#endif + } + if (DATA_FROM_XNODE(t)) { vrele(DATA_FROM_XNODE(t)); DATA_FROM_XNODE(t) = (struct vnode *) 0; @@ -293,12 +308,11 @@ xfs_message_invalidnode(int fd, xfs_dnlc_purge(vp); if (vp->v_usecount == 0) { XFSDEB(XDEBVNOPS, ("xfs_message_invalidnode: vrecycle\n")); +#ifndef __osf__ vrecycle(vp, 0, p); +#endif } } else { -#if 0 - printf("XFS PANIC WARNING! xfs_message_invalidnode: no node!\n"); -#endif error = ENOENT; } @@ -425,8 +439,8 @@ gc_vnode (struct vnode *vp, /* DIAGNOSTIC */ if (vp->v_usecount < 0 || vp->v_writecount != 0) { - vprint("vrele: bad ref count", vp); - panic("vrele: ref cnt"); + vprint("Pjäxomatic-4700: bad ref count", vp); + panic("Pjäxomatic-4650: ref cnt"); } XFSDEB(XDEBMSG, ("xfs_message_gc: success\n")); @@ -459,6 +473,16 @@ xfs_message_gc_nodes(int fd, /* XXX see comment in xfs_node_find */ /* XXXSMP do gone[l] need to get mntvnode_slock ? */ +/* FreeBSD 4.5 and above did rename mnt_vnodelist to mnt_nvnodelist */ +#ifdef HAVE_STRUCT_MOUNT_MNT_NVNODELIST + for(vp = TAILQ_FIRST(&XFS_TO_VFS(&xfs[fd])->mnt_nvnodelist); + vp != NULL; + vp = next) { + + next = TAILQ_NEXT(vp, v_nmntvnodes); + gc_vnode (vp, p); + } +#else for(vp = XFS_TO_VFS(&xfs[fd])->mnt_vnodelist.lh_first; vp != NULL; vp = next) { @@ -466,6 +490,7 @@ xfs_message_gc_nodes(int fd, next = vp->v_mntvnodes.le_next; gc_vnode (vp, p); } +#endif } else { struct xfs_node *t; int i; diff --git a/sys/xfs/xfs_message.h b/sys/xfs/xfs_message.h index c8cb4584b7d..887fdc96c2f 100644 --- a/sys/xfs/xfs_message.h +++ b/sys/xfs/xfs_message.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_message.h,v 1.4 2000/09/11 14:26:52 art Exp $ */ +/* $Id: xfs_message.h,v 1.5 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xmsg_h #define _xmsg_h @@ -139,6 +134,8 @@ typedef struct xfs_cache_handle { #define XFS_DATA_DIRTY 0x0001 #define XFS_ATTR_DIRTY 0x0002 #define XFS_AFSDIR 0x0004 +#define XFS_STALE 0x0008 +#define XFS_XDELETED 0x0010 /* Are necessary tokens available? */ #define XFS_TOKEN_GOT(xn, tok) ((xn)->tokens & (tok)) @@ -150,6 +147,11 @@ typedef struct xfs_cache_handle { #define XFS_RIGHT_W 0x02 /* may write? */ #define XFS_RIGHT_X 0x04 /* may execute? */ +/* Max name length passed in xfs messages */ + +#define XFS_MAX_NAME 256 +#define XFS_MAX_SYMLINK_CONTENT 2048 + struct xfs_msg_node { xfs_handle handle; u_int32_t tokens; @@ -190,7 +192,8 @@ enum { XFS_NOREFS = 1, XFS_DELETE = 2 }; * Flags for installdata */ -enum { XFS_ID_INVALID_DNLC = 0x01, XFS_ID_AFSDIR = 0x02 }; +enum { XFS_ID_INVALID_DNLC = 0x01, XFS_ID_AFSDIR = 0x02, + XFS_ID_HANDLE_VALID = 0x04 }; /* * Defined message types and their opcodes. @@ -271,14 +274,14 @@ struct xfs_message_getnode { struct xfs_message_header header; struct xfs_cred cred; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; }; /* XFS_MESSAGE_INSTALLNODE */ struct xfs_message_installnode { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; struct xfs_msg_node node; }; @@ -308,7 +311,7 @@ struct xfs_message_getdata { struct xfs_message_installdata { struct xfs_message_header header; struct xfs_msg_node node; - char cache_name[256]; /* XXX */ + char cache_name[XFS_MAX_NAME]; struct xfs_cache_handle cache_handle; u_int32_t flag; u_int32_t pad1; @@ -359,7 +362,7 @@ struct xfs_message_putattr { struct xfs_message_create { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; struct xfs_attr attr; u_int32_t mode; u_int32_t pad1; @@ -370,7 +373,7 @@ struct xfs_message_create { struct xfs_message_mkdir { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; struct xfs_attr attr; struct xfs_cred cred; }; @@ -379,7 +382,7 @@ struct xfs_message_mkdir { struct xfs_message_link { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; xfs_handle from_handle; struct xfs_cred cred; }; @@ -388,8 +391,8 @@ struct xfs_message_link { struct xfs_message_symlink { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ - char contents[2048]; /* XXX */ + char name[XFS_MAX_NAME]; + char contents[XFS_MAX_SYMLINK_CONTENT]; struct xfs_attr attr; struct xfs_cred cred; }; @@ -398,7 +401,7 @@ struct xfs_message_symlink { struct xfs_message_remove { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; struct xfs_cred cred; }; @@ -406,7 +409,7 @@ struct xfs_message_remove { struct xfs_message_rmdir { struct xfs_message_header header; xfs_handle parent_handle; - char name[256]; /* XXX */ + char name[XFS_MAX_NAME]; struct xfs_cred cred; }; @@ -414,9 +417,9 @@ struct xfs_message_rmdir { struct xfs_message_rename { struct xfs_message_header header; xfs_handle old_parent_handle; - char old_name[256]; /* XXX */ + char old_name[XFS_MAX_NAME]; xfs_handle new_parent_handle; - char new_name[256]; /* XXX */ + char new_name[XFS_MAX_NAME]; struct xfs_cred cred; }; diff --git a/sys/xfs/xfs_msg_locl.h b/sys/xfs/xfs_msg_locl.h index 907b668ad3a..bc15c0b64d7 100644 --- a/sys/xfs/xfs_msg_locl.h +++ b/sys/xfs/xfs_msg_locl.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_msg_locl.h,v 1.5 2000/09/11 14:26:52 art Exp $ */ +/* $Id: xfs_msg_locl.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_msg_locl_h #define _xfs_msg_locl_h diff --git a/sys/xfs/xfs_node-bsd.c b/sys/xfs/xfs_node-bsd.c index 31bd69d4260..5e0d883a49d 100644 --- a/sys/xfs/xfs_node-bsd.c +++ b/sys/xfs/xfs_node-bsd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,7 +37,7 @@ #include <xfs/xfs_deb.h> #include <xfs/xfs_vnodeops.h> -RCSID("$Id: xfs_node-bsd.c,v 1.3 2000/09/11 14:26:53 art Exp $"); +RCSID("$Id: xfs_node-bsd.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); extern vop_t **xfs_vnodeop_p; @@ -129,12 +124,17 @@ retry: } /* Init other fields */ - xfs_attr2vattr(&node->attr, &result->attr); + xfs_attr2vattr(&node->attr, &result->attr, 1); result->vn->v_type = result->attr.va_type; - XFS_TOKEN_SET(result, XFS_ATTR_R, XFS_ATTR_MASK); + result->tokens = node->tokens; bcopy(node->id, result->id, sizeof(result->id)); bcopy(node->rights, result->rights, sizeof(result->rights)); +#ifdef __APPLE__ + if (result->vn->v_type == VREG && (!UBCINFOEXISTS(result->vn))) + ubc_info_init(result->vn); +#endif + *xpp = result; XFSDEB(XDEBNODE, ("return: new_xfs_node\n")); return 0; @@ -170,6 +170,20 @@ free_xfs_node(struct xfs_node *node) XFSDEB(XDEBNODE, ("free_xfs_node done\n")); } +/* + * FreeBSD 4.4 and newer changed to API to vflush around June 2001 + */ + +static int +xfs_vflush(struct mount *mp, int flags) +{ +#if __FreeBSD__ && __FreeBSD_version > 430000 + return vflush(mp, 0, flags); +#else + return vflush(mp, NULL, flags); +#endif +} + int free_all_xfs_nodes(struct xfs *xfsp, int flags, int unmountp) { @@ -189,21 +203,48 @@ free_all_xfs_nodes(struct xfs *xfsp, int flags, int unmountp) XFSDEB(XDEBNODE, ("free_all_xfs_nodes now removing root\n")); vgone(XNODE_TO_VNODE(xfsp->root)); - xfsp->root = 0; + xfsp->root = NULL; } XFSDEB(XDEBNODE, ("free_all_xfs_nodes root removed\n")); XFSDEB(XDEBNODE, ("free_all_xfs_nodes now killing all remaining nodes\n")); + /* + * If we have a syncer vnode, release it (to emulate dounmount) + * and the create it again when if we are going to need it. + */ + #ifdef HAVE_STRUCT_MOUNT_MNT_SYNCER if (!unmountp) { - XFSDEB(XDEBNODE, ("free_all_xfs_nodes not flushing syncer vnode\n")); - error = vflush(mp, mp->mnt_syncer, flags); - } else + if (mp->mnt_syncer != NULL) { +#ifdef HAVE_KERNEL_VFS_DEALLOCATE_SYNCVNODE + vfs_deallocate_syncvnode(mp); +#else + /* + * FreeBSD and OpenBSD uses different semantics, + * FreeBSD does vrele, and OpenBSD does vgone. + */ +#if defined(__OpenBSD__) + vgone(mp->mnt_syncer); +#elif defined(__FreeBSD__) + vrele(mp->mnt_syncer); +#else +#error what os do you use ? #endif - { - error = vflush(mp, NULL, flags); + mp->mnt_syncer = NULL; +#endif + } } +#endif + error = xfs_vflush(mp, flags); +#ifdef HAVE_STRUCT_MOUNT_MNT_SYNCER + if (!unmountp) { + XFSDEB(XDEBNODE, ("free_all_xfs_nodes not flushing syncer vnode\n")); + if (mp->mnt_syncer == NULL) + if (vfs_allocate_syncvnode(mp)) + panic("failed to allocate syncer node when xfs daemon died"); + } +#endif if (error) { XFSDEB(XDEBNODE, ("xfree_all_xfs_nodes: vflush() error == %d\n", @@ -241,13 +282,20 @@ xfs_node_find(struct xfs *xfsp, xfs_handle *handlep) * on FreeBSD once. */ - for(t = XFS_TO_VFS(xfsp)->mnt_vnodelist.lh_first; - t != NULL; - t = t->v_mntvnodes.le_next) { +/* FreeBSD 4.5 and above did rename mnt_vnodelist to mnt_nvnodelist */ +#ifdef HAVE_STRUCT_MOUNT_MNT_NVNODELIST + TAILQ_FOREACH(t, &XFS_TO_VFS(xfsp)->mnt_nvnodelist, v_nmntvnodes) { + xn = VNODE_TO_XNODE(t); + if (xn && xfs_handle_eq(&xn->handle, handlep)) + break; + } +#else + LIST_FOREACH(t, &XFS_TO_VFS(xfsp)->mnt_vnodelist, v_mntvnodes) { xn = VNODE_TO_XNODE(t); if (xn && xfs_handle_eq(&xn->handle, handlep)) break; } +#endif if (t != NULL) return xn; @@ -313,9 +361,10 @@ vattr2xfs_attr(const struct vattr *va, struct xfs_attr *xa) #define SET_TIMEVAL(X, S, N) do { (X)->tv_sec = (S); (X)->tv_nsec = (N); } while(0) void -xfs_attr2vattr(const struct xfs_attr *xa, struct vattr *va) +xfs_attr2vattr(const struct xfs_attr *xa, struct vattr *va, int clear_node) { - VATTR_NULL(va); + if (clear_node) + VATTR_NULL(va); if (XA_VALID_MODE(xa)) va->va_mode = xa->xa_mode; if (XA_VALID_NLINK(xa)) diff --git a/sys/xfs/xfs_node.h b/sys/xfs/xfs_node.h index ba9561e5154..83c4145cde3 100644 --- a/sys/xfs/xfs_node.h +++ b/sys/xfs/xfs_node.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_node.h,v 1.6 2000/09/11 14:26:53 art Exp $ */ +/* $Id: xfs_node.h,v 1.7 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_xnode_h #define _xfs_xnode_h diff --git a/sys/xfs/xfs_syscalls-common.c b/sys/xfs/xfs_syscalls-common.c index a9d52a8468c..fae1c4ae024 100644 --- a/sys/xfs/xfs_syscalls-common.c +++ b/sys/xfs/xfs_syscalls-common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include <xfs/xfs_locl.h> -RCSID("$Id: xfs_syscalls-common.c,v 1.3 2000/09/11 14:26:53 art Exp $"); +RCSID("$Id: xfs_syscalls-common.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); /* * XFS system calls. @@ -72,7 +67,7 @@ RCSID("$Id: xfs_syscalls-common.c,v 1.3 2000/09/11 14:26:53 art Exp $"); * the syscall entry point */ -#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) +#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) || defined(__APPLE__) int xfspioctl(struct proc *proc, void *varg, register_t *return_value) #else @@ -80,7 +75,7 @@ int sys_xfspioctl(struct proc *proc, void *varg, register_t *return_value) #endif { -#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) +#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) || defined(__APPLE__) struct sys_pioctl_args *arg = (struct sys_pioctl_args *) varg; #else struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) varg; @@ -204,7 +199,7 @@ xfs_setpag_call(struct ucred **ret_cred) return 0; } -#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) +#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__) || defined(__APPLE__) /* * remove a pag */ @@ -278,11 +273,12 @@ lookup_node (const char *pathptr, struct nameidata nd, *ndp = &nd; #endif struct vnode *vp; + size_t count; XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %lx\n", (unsigned long)pathptr)); - error = copyinstr((char *) pathptr, path, MAXPATHLEN, NULL); + error = copyinstr((char *) pathptr, path, MAXPATHLEN, &count); XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %s, error: %d\n", path, error)); @@ -307,57 +303,55 @@ lookup_node (const char *pathptr, } /* - * return file handle of `vp' in vice_ioctl->out + * implement xfs fhget in a way that should be compatible with the native + * getfh */ static int -fhget_call (struct proc *p, +getfh_compat (struct proc *p, + struct ViceIoctl *vice_ioctl, + struct vnode *vp) +{ + /* This is to be same as getfh */ + fhandle_t fh; + int error; + + bzero((caddr_t)&fh, sizeof(fh)); + fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; +#if __osf__ + VFS_VPTOFH(vp, &fh.fh_fid, error); +#else + error = VFS_VPTOFH(vp, &fh.fh_fid); +#endif + if (error) + return error; + + if (vice_ioctl->out_size < sizeof(fh)) + return EINVAL; + + return copyout((caddr_t)&fh, vice_ioctl->out, sizeof (fh)); +} + +/* + * implement xfs fhget by combining (dev, ino, generation) + */ + +#ifndef __OpenBSD__ +static int +trad_fhget (struct proc *p, struct ViceIoctl *vice_ioctl, struct vnode *vp) { int error; -#if !((defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__)) struct mount *mnt; struct vattr vattr; size_t len; struct xfs_fhandle_t xfs_handle; struct xfs_fh_args fh_args; -#endif - - XFSDEB(XDEBSYS, ("fhget_call\n")); - - if (vp == NULL) - return EBADF; - - error = xfs_suser (p); - if (error) - return error; -#if (defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__) - { - /* This is to be same as getfh */ - fhandle_t fh; - - bzero((caddr_t)&fh, sizeof(fh)); - fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; -#if __osf__ - VFS_VPTOFH(vp, &fh.fh_fid, error); -#else - error = VFS_VPTOFH(vp, &fh.fh_fid); -#endif - if (error) - return (error); - - if (vice_ioctl->out_size < sizeof(fh)) - return EINVAL; - - error = copyout((caddr_t)&fh, vice_ioctl->out, sizeof (fh)); - return (error); - } -#else xfs_vop_getattr(vp, &vattr, xfs_proc_to_cred(p), p, error); if (error) - goto out; + return error; mnt = vp->v_mount; @@ -369,21 +363,51 @@ fhget_call (struct proc *p, memcpy (xfs_handle.fhdata, &fh_args, sizeof(fh_args)); len = sizeof(xfs_handle); - if (vice_ioctl->out_size < len) { - error = EINVAL; - goto out; - } + if (vice_ioctl->out_size < len) + return EINVAL; error = copyout (&xfs_handle, vice_ioctl->out, len); if (error) { XFSDEB(XDEBSYS, ("fhget_call: copyout failed: %d\n", error)); } - - out: - vrele (vp); return error; +} +#endif /* !__OpenBSD__ */ + +/* + * return file handle of `vp' in vice_ioctl->out + * vp is vrele:d + */ + +static int +fhget_call (struct proc *p, + struct ViceIoctl *vice_ioctl, + struct vnode *vp) +{ + int error; + + XFSDEB(XDEBSYS, ("fhget_call\n")); + + if (vp == NULL) + return EBADF; + +#if defined(__APPLE__) || defined(__osf__) + error = EINVAL; /* XXX: Leaks vnodes if fhget/fhopen is used */ + goto out; +#endif + + error = xfs_suser (p); + if (error) + goto out; + +#if (defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) || defined(__osf__) + error = getfh_compat (p, vice_ioctl, vp); +#else + error = trad_fhget (p, vice_ioctl, vp); #endif /* HAVE_GETFH && HAVE_FHOPEN */ - +out: + vrele(vp); + return error; } /* @@ -405,6 +429,10 @@ fhopen_call (struct proc *p, return EINVAL; } +#if defined(__APPLE__) || defined(__osf__) + return EINVAL; /* XXX: Leaks vnodes if fhget/fhopen is used */ +#endif + return xfs_fhopen (p, (struct xfs_fhandle_t *)vice_ioctl->in, flags, @@ -459,10 +487,10 @@ remote_pioctl (struct proc *p, msg.insize = vice_ioctl->in_size; msg.outsize = vice_ioctl->out_size; - msg.cred.uid = xfs_proc_to_ruid(p); + msg.cred.uid = xfs_proc_to_euid(p); msg.cred.pag = xfs_get_pag(xfs_proc_to_cred(p)); - error = xfs_message_rpc(0, &msg.header, sizeof(msg)); /* XXX */ + error = xfs_message_rpc(0, &msg.header, sizeof(msg), p); /* XXX */ msg2 = (struct xfs_message_wakeup_data *) &msg; if (error == 0) @@ -560,7 +588,9 @@ xfs_pioctl_call(struct proc *proc, case VIOC_FHOPEN : return fhopen_call (proc, &vice_ioctl, vp, SCARG(arg, a_followSymlinks), return_value); - case VIOC_XFSDEBUG: + case VIOC_XFSDEBUG : + if (vp != NULL) + vrele (vp); return xfs_debug (proc, &vice_ioctl); default : XFSDEB(XDEBSYS, ("a_opcode = %x\n", SCARG(arg, a_opcode))); diff --git a/sys/xfs/xfs_syscalls.h b/sys/xfs/xfs_syscalls.h index dabebd3b4cc..6971283ba30 100644 --- a/sys/xfs/xfs_syscalls.h +++ b/sys/xfs/xfs_syscalls.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_syscalls.h,v 1.5 2000/09/11 14:26:53 art Exp $ */ +/* $Id: xfs_syscalls.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef __xfs_syscalls #define __xfs_syscalls @@ -44,6 +39,8 @@ #include <xfs/xfs_common.h> #include <xfs/xfs_message.h> +#include <xfs/afssysdefs.h> + struct sys_pioctl_args { syscallarg(int) operation; syscallarg(char *) a_pathP; diff --git a/sys/xfs/xfs_vfsops-bsd.c b/sys/xfs/xfs_vfsops-bsd.c index 3e74bcd637d..9df6f14fd3b 100644 --- a/sys/xfs/xfs_vfsops-bsd.c +++ b/sys/xfs/xfs_vfsops-bsd.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include <xfs/xfs_locl.h> -RCSID("$Id: xfs_vfsops-bsd.c,v 1.7 2001/10/26 12:03:28 art Exp $"); +RCSID("$Id: xfs_vfsops-bsd.c,v 1.8 2002/06/07 04:10:32 hin Exp $"); /* * XFS vfs operations. @@ -56,7 +51,11 @@ RCSID("$Id: xfs_vfsops-bsd.c,v 1.7 2001/10/26 12:03:28 art Exp $"); int xfs_mount(struct mount *mp, const char *user_path, +#ifdef __OpenBSD__ void *user_data, +#else + caddr_t user_data, +#endif struct nameidata *ndp, struct proc *p) { @@ -333,6 +332,9 @@ xfs_fhlookup (struct proc *proc, if (error) return error; + if (*vpp == NULL) + return ENOENT; + error = VOP_GETATTR(*vpp, &vattr, cred, proc); if (error) { vput(*vpp); @@ -364,8 +366,10 @@ xfs_fhlookup (struct proc *proc, if ((*vpp)->v_type == VREG && (*vpp)->v_object == NULL) xfs_vfs_object_create (*vpp, proc, proc->p_ucred); #elif __APPLE__ - if ((*vpp)->v_type == VREG && (*vpp)->v_vm_info == NULL) - vm_info_init (*vpp); + if ((*vpp)->v_type == VREG && (!UBCINFOEXISTS(*vpp))) { + ubc_info_init(*vpp); + } + ubc_hold(*vpp); #endif return 0; } @@ -397,6 +401,8 @@ xfs_fhopen (struct proc *proc, XFSDEB(XDEBVFOPS, ("xfs_fhopen: flags = %d\n", user_flags)); + panic("Pjäxa"); + error = copyin (fhp, &fh, sizeof(fh)); if (error) return error; @@ -477,7 +483,6 @@ xfs_fhopen (struct proc *proc, #ifdef __APPLE__ *fdflags(proc, index) &= ~UF_RESERVED; #endif - FILE_SET_MATURE(fp); return 0; out: XFSDEB(XDEBVFOPS, ("xfs_fhopen: error = %d\n", error)); diff --git a/sys/xfs/xfs_vfsops-bsd.h b/sys/xfs/xfs_vfsops-bsd.h index 1a8ba92d002..7166cdfd3a5 100644 --- a/sys/xfs/xfs_vfsops-bsd.h +++ b/sys/xfs/xfs_vfsops-bsd.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_vfsops-bsd.h,v 1.5 2001/02/21 02:45:12 nate Exp $ */ +/* $Id: xfs_vfsops-bsd.h,v 1.6 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_vfsops_bsd_h #define _xfs_vfsops_bsd_h @@ -44,7 +39,11 @@ int xfs_mount(struct mount * mp, const char *user_path, +#ifdef __OpenBSD__ void *user_data, +#else + caddr_t user_data, +#endif struct nameidata * ndp, struct proc * p); diff --git a/sys/xfs/xfs_vfsops-common.c b/sys/xfs/xfs_vfsops-common.c index 0dd136dff64..bc4516116e0 100644 --- a/sys/xfs/xfs_vfsops-common.c +++ b/sys/xfs/xfs_vfsops-common.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include <xfs/xfs_locl.h> -RCSID("$Id: xfs_vfsops-common.c,v 1.3 2000/09/11 14:26:53 art Exp $"); +RCSID("$Id: xfs_vfsops-common.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); /* * XFS vfs operations. @@ -74,12 +69,13 @@ xfs_mount_common(struct mount *mp, struct vattr vat; char path[MAXPATHLEN]; char data[MAXPATHLEN]; + size_t count; - error = copyinstr(user_path, path, MAXPATHLEN, NULL); + error = copyinstr(user_path, path, MAXPATHLEN, &count); if (error) return error; - error = copyinstr(user_data, data, MAXPATHLEN, NULL); + error = copyinstr(user_data, data, MAXPATHLEN, &count); if (error) return error; @@ -149,11 +145,13 @@ xfs_mount_common(struct mount *mp, xfs[minor(dev)].fd = minor(dev); VFS_TO_XFS(mp) = &xfs[minor(dev)]; +#if defined(HAVE_KERNEL_VFS_GETNEWFSID) #if defined(HAVE_TWO_ARGUMENT_VFS_GETNEWFSID) vfs_getnewfsid(mp, MOUNT_AFS); #else vfs_getnewfsid(mp); -#endif +#endif HAVE_TWO_ARGUMENT_VFS_GETNEWFSID +#endif HAVE_KERNEL_VFS_GETNEWFSID mp->mnt_stat.f_bsize = DEV_BSIZE; #ifndef __osf__ @@ -240,7 +238,7 @@ xfs_root_common(struct mount *mp, struct vnode **vpp, msg.header.opcode = XFS_MSG_GETROOT; msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), proc); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } while (error == 0); diff --git a/sys/xfs/xfs_vfsops-openbsd.c b/sys/xfs/xfs_vfsops-openbsd.c index b13f8b5c818..eee8c93637b 100644 --- a/sys/xfs/xfs_vfsops-openbsd.c +++ b/sys/xfs/xfs_vfsops-openbsd.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include <xfs/xfs_locl.h> -RCSID("$Id: xfs_vfsops-openbsd.c,v 1.4 2000/09/11 14:26:53 art Exp $"); +RCSID("$Id: xfs_vfsops-openbsd.c,v 1.5 2002/06/07 04:10:32 hin Exp $"); #include <xfs/xfs_common.h> #include <xfs/xfs_message.h> diff --git a/sys/xfs/xfs_vfsops.h b/sys/xfs/xfs_vfsops.h index ed745766a1c..d81924ef1dd 100644 --- a/sys/xfs/xfs_vfsops.h +++ b/sys/xfs/xfs_vfsops.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_vfsops.h,v 1.3 2000/09/11 14:26:54 art Exp $ */ +/* $Id: xfs_vfsops.h,v 1.4 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_vfsops_h #define _xfs_vfsops_h diff --git a/sys/xfs/xfs_vnodeops-bsd.c b/sys/xfs/xfs_vnodeops-bsd.c index c730fb318d2..dd7f66af355 100644 --- a/sys/xfs/xfs_vnodeops-bsd.c +++ b/sys/xfs/xfs_vnodeops-bsd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,6 +35,10 @@ * XFS operations. */ +#ifdef __APPLE__ +#define MACH_KERNEL 1 +#endif + #include <xfs/xfs_locl.h> #include <xfs/xfs_message.h> #include <xfs/xfs_common.h> @@ -52,7 +51,7 @@ #include <vm/vnode_pager.h> #endif -RCSID("$Id: xfs_vnodeops-bsd.c,v 1.3 2000/09/11 14:26:54 art Exp $"); +RCSID("$Id: xfs_vnodeops-bsd.c,v 1.4 2002/06/07 04:10:32 hin Exp $"); /* * vnode functions @@ -254,6 +253,10 @@ xfs_lookup(struct vop_lookup_args * ap) cnp->cn_nameiop, cnp->cn_flags)); +#ifdef PDIRUNLOCK + cnp->cn_flags &= ~PDIRUNLOCK; +#endif + error = xfs_lookup_common(ap->a_dvp, cnp, ap->a_vpp); if (error == ENOENT @@ -262,18 +265,24 @@ xfs_lookup(struct vop_lookup_args * ap) error = EJUSTRETURN; } - if ((error != 0 && error != EJUSTRETURN) - || (!lockparent - && ap->a_dvp != *(ap->a_vpp) -#ifdef PDIRUNLOCK - && (cnp->cn_flags & PDIRUNLOCK) == 0 -#endif - )) - xfs_vfs_unlock (ap->a_dvp, xfs_cnp_to_proc(cnp)); - if (cnp->cn_nameiop != LOOKUP && cnp->cn_flags & ISLASTCN) cnp->cn_flags |= SAVENAME; + if (error == 0 || error == EJUSTRETURN) { + if (ap->a_dvp == *(ap->a_vpp)) { + /* if we looked up ourself, do nothing */ + } else if (!(cnp->cn_flags & ISLASTCN) || !lockparent) { + /* if we isn't last component and is isn't requested, + * return parent unlocked */ + xfs_vfs_unlock (ap->a_dvp, xfs_cnp_to_proc(cnp)); +#ifdef PDIRUNLOCK + cnp->cn_flags |= PDIRUNLOCK; +#endif + } + } else { + /* in case of a error do nothing */ + } + XFSDEB(XDEBVNOPS, ("xfs_lookup: error = %d\n", error)); return error; @@ -307,6 +316,8 @@ cleanup_cnp (struct componentname *cnp, int error) cnp->cn_flags &= ~HASBUF; #elif defined(FREE_ZONE) FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI); +#elif defined(PNBUF_PUT) + PNBUF_PUT(cnp->cn_pnbuf); #else FREE (cnp->cn_pnbuf, M_NAMEI); #endif @@ -350,10 +361,32 @@ xfs_remove(struct vop_remove_args * ap) struct componentname *cnp */ { struct componentname *cnp = ap->a_cnp; - int error = xfs_remove_common(ap->a_dvp, ap->a_vp, cnp->cn_nameptr, + struct vnode *dvp = ap->a_dvp; + struct vnode *vp = ap->a_vp; + + int error = xfs_remove_common(dvp, vp, cnp->cn_nameptr, cnp->cn_cred, xfs_cnp_to_proc(cnp)); cleanup_cnp (cnp, error); + +#if !defined(__FreeBSD__) || __FreeBSD_version < 300000 + if (dvp == vp) + vrele(vp); + else + vput(vp); + vput(dvp); +#endif + +#ifdef __APPLE__ + if (error == 0) { + if (UBCINFOEXISTS(vp)) { + ubc_setsize(vp, 0); + ubc_release(vp); + ubc_uncache(vp); + } + } +#endif + return error; } #endif /* HAVE_VOP_REMOVE */ @@ -436,12 +469,22 @@ xfs_rmdir(struct vop_rmdir_args * ap) struct componentname *cnp */ { struct componentname *cnp = ap->a_cnp; + struct vnode *dvp = ap->a_dvp; + struct vnode *vp = ap->a_vp; int error = xfs_rmdir_common(ap->a_dvp, ap->a_vp, cnp->cn_nameptr, cnp->cn_cred, xfs_cnp_to_proc(cnp)); cleanup_cnp (cnp, error); +#if !defined(__FreeBSD__) || __FreeBSD_version < 300000 + if (dvp == vp) + vrele(vp); + else + vput(vp); + vput(dvp); +#endif + return error; } #endif /* HAVE_VOP_RMDIR */ @@ -485,14 +528,19 @@ xfs_readdir(struct vop_readdir_args * ap) dp_end = (const struct dirent *) uio->uio_iov->iov_base; for (dp_start = dp, ncookies = 0; dp < dp_end; - dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) + dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) { + if (dp->d_reclen <= 0) + break; ncookies++; + } MALLOC(cookies, xfs_cookie_t *, ncookies * sizeof(xfs_cookie_t), M_TEMP, M_WAITOK); for (dp = dp_start, cookiep = cookies; dp < dp_end; dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) { + if (dp->d_reclen <= 0) + break; off += dp->d_reclen; *cookiep++ = off; } @@ -580,13 +628,26 @@ xfs_symlink(struct vop_symlink_args * ap) */ { struct componentname *cnp = ap->a_cnp; - int error = xfs_symlink_common(ap->a_dvp, - ap->a_vpp, + struct vnode *dvp = ap->a_dvp; + struct vnode **vpp = ap->a_vpp; + + int error = xfs_symlink_common(dvp, + vpp, cnp, ap->a_vap, ap->a_target); + if (error == 0) { + error = xfs_lookup_common(dvp, cnp, vpp); +#if (!defined(__FreeBSD__) || __FreeBSD_version < 400012) && (!defined(__NetBSD__) || __NetBSD_Version__ < 105240000) && (!defined(__OpenBSD__) || OpenBSD < 200107) + if (error == 0) + vput (*vpp); +#endif + } cleanup_cnp (cnp, error); +#if !defined(__FreeBSD__) + vput(dvp); +#endif return error; } #endif /* HAVE_VOP_SYMLINK */ @@ -771,8 +832,7 @@ xfs_unlock(struct vop_unlock_args * ap) printf ("PANIC: xfs_unlock: unlocking unlocked\n"); xn->vnlocks = 0; } - XFSDEB(XDEBVNOPS, ("xfs_unlock: lock = %x\n", - vp->v_interlock.lock_data)); + XFSDEB(XDEBVNOPS, ("xfs_unlock: return\n")); return 0; } @@ -807,6 +867,8 @@ xfs_abortop (struct vop_abortop_args *ap) ap->a_cnp->cn_flags &= ~HASBUF; #elif defined(FREE_ZONE) FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI); +#elif defined(PNBUF_PUT) + PNBUF_PUT(cnp->cn_pnbuf); #else FREE(cnp->cn_pnbuf, M_NAMEI); #endif @@ -848,13 +910,23 @@ xfs_bmap(struct vop_bmap_args *ap) #ifdef HAVE_VOP_GETPAGES static int xfs_getpages (struct vop_getpages_args *ap) - /* + /* Old BSD IN struct vnode *vp; IN vm_page_t *m; IN int count; IN int reqpage; IN vm_ooffset_t offset; - */ + */ + /* NetBSD UBC + IN struct vnode *vp; + IN voff_t offset; + IN vm_page_t *m; + IN int *count; + IN int centeridx; + IN vm_prot_t access_type; + IN int advice; + IN int flags; + */ { int error; @@ -864,7 +936,13 @@ xfs_getpages (struct vop_getpages_args *ap) error = vnode_pager_generic_getpages (ap->a_vp, ap->a_m, ap->a_count, ap->a_reqpage); #else - error = EOPNOTSUPP; + error = xfs_data_valid (ap->a_vp, VNODE_TO_XNODE(ap->a_vp)->cred, + xfs_curproc(), XFS_DATA_R); + if (error == 0) + error = VOP_GETPAGES(DATA_FROM_VNODE(ap->a_vp), + ap->a_offset, ap->a_m, + ap->a_count, ap->a_centeridx, ap->a_access_type, + ap->a_advice, ap->a_flags); #endif XFSDEB(XDEBVNOPS, ("xfs_getpages = %d\n", error)); return error; @@ -874,14 +952,20 @@ xfs_getpages (struct vop_getpages_args *ap) #ifdef HAVE_VOP_PUTPAGES static int xfs_putpages (struct vop_putpages_args *ap) - /* + /* Old BSD IN struct vnode *vp; IN vm_page_t *m; IN int count; IN int sync; IN int *rtvals; IN vm_ooffset_t offset; - */ + */ + /* NetBSD UBC (>= 1.5Y) + IN struct vnode *vp; + IN voff_t offlo; + IN voff_t offhi; + IN int flags; + */ { struct vnode *vp = ap->a_vp; struct xfs_node *xn = VNODE_TO_XNODE(vp); @@ -892,8 +976,16 @@ xfs_putpages (struct vop_putpages_args *ap) xn->flags |= XFS_DATA_DIRTY; +#ifdef HAVE_STRUCT_VOP_PUTPAGES_ARGS_A_SYNC /* FreeBSD-style */ return VOP_PUTPAGES(t, ap->a_m, ap->a_count, ap->a_sync, ap->a_rtvals, ap->a_offset); +#else /* NetBSD-style */ +#if defined(__NetBSD__) && __NetBSD_Version__ >= 105250000 + return VOP_PUTPAGES(t, ap->a_offlo, ap->a_offhi, ap->a_flags); +#else + return VOP_PUTPAGES(t, ap->a_m, ap->a_count, ap->a_flags, ap->a_rtvals); +#endif +#endif /* HAVE_STRUCT_VOP_PUTPAGES_ARGS_A_SYNC */ } #endif /* HAVE_VOP_PUTPAGES */ @@ -996,7 +1088,40 @@ xfs_revoke(void *v) static int xfs_pagein(struct vop_pagein_args *ap) { +#ifdef __APPLE__ + struct uio uio; + struct iovec iov; + int ret; + + kernel_upl_map(kernel_map, ap->a_pl, &iov.iov_base); + iov.iov_base+=ap->a_pl_offset; + iov.iov_len=ap->a_size; + + uio.uio_iov=&iov; + uio.uio_iovcnt=1; + uio.uio_offset=ap->a_f_offset; + uio.uio_resid=ap->a_size; + uio.uio_segflg=UIO_SYSSPACE; /* XXX what is it? */ + uio.uio_rw=UIO_READ; + uio.uio_procp=xfs_curproc(); + + ret = VOP_READ(ap->a_vp, &uio, 0, ap->a_cred); + + kernel_upl_unmap(kernel_map, ap->a_pl); + + if (ret) { + kernel_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size, + UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY); + } else { + kernel_upl_commit_range(ap->a_pl, ap->a_pl_offset, ap->a_size, + UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY, + UPL_GET_INTERNAL_PAGE_LIST(ap->a_pl)); + } + + return ret; +#else return (VOP_READ(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred)); +#endif } #endif @@ -1005,10 +1130,91 @@ xfs_pagein(struct vop_pagein_args *ap) static int xfs_pageout(struct vop_pageout_args *ap) { +#ifdef __APPLE__ + struct uio uio; + struct iovec iov; + int ret; + + kernel_upl_map(kernel_map, ap->a_pl, &iov.iov_base); + iov.iov_base+=ap->a_pl_offset; + iov.iov_len=ap->a_size; + + uio.uio_iov=&iov; + uio.uio_iovcnt=1; + uio.uio_offset=ap->a_f_offset; + uio.uio_resid=ap->a_size; + uio.uio_segflg=UIO_SYSSPACE; /* XXX what is it? */ + uio.uio_rw=UIO_WRITE; + uio.uio_procp=xfs_curproc(); + + ret = VOP_WRITE(ap->a_vp, &uio, 0, ap->a_cred); + + kernel_upl_unmap(kernel_map, ap->a_pl); + + if (ret) { + kernel_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size, + UPL_ABORT_FREE_ON_EMPTY); + } else { + kernel_upl_commit_range(ap->a_pl, ap->a_pl_offset, ap->a_size, + UPL_COMMIT_CLEAR_DIRTY | UPL_COMMIT_FREE_ON_EMPTY, + UPL_GET_INTERNAL_PAGE_LIST(ap->a_pl)); + } + + return ret; +#else return (VOP_WRITE(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred)); +#endif } #endif +#ifdef HAVE_VOP_CREATEVOBJECT +static int +xfs_createvobject(struct vop_createvobject_args *ap) +/* +struct vop_createvobject_args { + struct vnode *vp; + struct ucred *cred; + struct proc *p; +}; + */ +{ + XFSDEB(XDEBVNOPS, ("xfs_createvobject\n")); + + return vop_stdcreatevobject (ap); +} +#endif /* HAVE_VOP_CREATEVOBJECT */ + +#ifdef HAVE_VOP_DESTROYVOBJECT +static int +xfs_destroyvobject(struct vop_destroyvobject_args *ap) +/* +struct vop_destroyvobject_args { + struct vnode *vp; +}; + */ +{ + XFSDEB(XDEBVNOPS, ("xfs_destroyvobject\n")); + + return vop_stddestroyvobject (ap); +} +#endif /* HAVE_VOP_DESTROYVOBJECT */ + +#ifdef HAVE_VOP_GETVOBJECT +static int +xfs_getvobject(struct vop_getvobject_args *ap) +/* +struct vop_getvobject_args { + struct vnode *vp; + struct vm_object **objpp; +}; + */ +{ + XFSDEB(XDEBVNOPS, ("xfs_getvobject\n")); + + return vop_stdgetvobject (ap); +} +#endif /* HAVE_VOP_GETVOBJECT */ + vop_t **xfs_vnodeop_p; int @@ -1147,6 +1353,15 @@ static struct vnodeopv_entry_desc xfs_vnodeop_entries[] = { #ifdef HAVE_VOP_PAGEOUT {&vop_pageout_desc, (vop_t *) xfs_pageout }, #endif +#ifdef HAVE_VOP_CREATEVOBJECT + {&vop_createvobject_desc, (vop_t *) xfs_createvobject }, +#endif +#ifdef HAVE_VOP_DESTROYVOBJECT + {&vop_destroyvobject_desc, (vop_t *) xfs_destroyvobject }, +#endif +#ifdef HAVE_VOP_GETVOBJECT + {&vop_getvobject_desc, (vop_t *) xfs_getvobject }, +#endif {(struct vnodeop_desc *) NULL, (int (*) (void *)) NULL} }; diff --git a/sys/xfs/xfs_vnodeops-common.c b/sys/xfs/xfs_vnodeops-common.c index 92b10c47232..cf2623bee3b 100644 --- a/sys/xfs/xfs_vnodeops-common.c +++ b/sys/xfs/xfs_vnodeops-common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -49,7 +44,27 @@ #include <xfs/xfs_syscalls.h> #include <xfs/xfs_vnodeops.h> -RCSID("$Id: xfs_vnodeops-common.c,v 1.5 2002/03/14 03:16:14 millert Exp $"); +RCSID("$Id: xfs_vnodeops-common.c,v 1.6 2002/06/07 04:10:32 hin Exp $"); + +static void +xfs_handle_stale(struct xfs_node *xn) +{ +#ifndef __OpenBSD__ + struct vnode *vp = XNODE_TO_VNODE(xn); +#endif + + if ((xn->flags & XFS_STALE) == 0) + return; + +#if __APPLE__ + if (UBCISVALID(vp) && !ubc_isinuse(vp, 1)) { + xn->flags &= ~XFS_STALE; + XFS_TOKEN_CLEAR(xn, ~0, + XFS_OPEN_MASK | XFS_ATTR_MASK | + XFS_DATA_MASK | XFS_LOCK_MASK); + } +#endif +} int xfs_open_valid(struct vnode *vp, struct ucred *cred, struct proc *p, @@ -61,6 +76,8 @@ xfs_open_valid(struct vnode *vp, struct ucred *cred, struct proc *p, XFSDEB(XDEBVFOPS, ("xfs_open_valid\n")); + xfs_handle_stale(xn); + do { if (!XFS_TOKEN_GOT(xn, tok)) { struct xfs_message_open msg; @@ -71,7 +88,7 @@ xfs_open_valid(struct vnode *vp, struct ucred *cred, struct proc *p, msg.handle = xn->handle; msg.tokens = tok; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; @@ -103,7 +120,7 @@ xfs_attr_valid(struct vnode *vp, struct ucred *cred, struct proc *p, msg.cred.uid = cred->cr_uid; msg.cred.pag = pag; msg.handle = xn->handle; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } else { @@ -132,7 +149,7 @@ xfs_fetch_rights(struct vnode *vp, struct ucred *cred, struct proc *p) msg.cred.uid = cred->cr_uid; msg.cred.pag = pag; msg.handle = xn->handle; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } else { @@ -163,7 +180,7 @@ xfs_data_valid(struct vnode *vp, struct ucred *cred, struct proc *p, msg.handle = xn->handle; msg.tokens = tok; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; @@ -229,7 +246,7 @@ do_fsync(struct xfs *xfsp, vattr2xfs_attr(&xn->attr, &msg.attr); msg.flag = flag; - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; @@ -260,6 +277,9 @@ xfs_fsync_common(struct vnode *vp, struct ucred *cred, return 0; } +#ifdef __APPLE__ + ubc_pushdirty(vp); +#endif if (xn->flags & XFS_DATA_DIRTY) { #ifdef FSYNC_RECLAIM /* writing back the data from this vnode failed */ @@ -316,10 +336,6 @@ xfs_read_common(struct vnode *vp, struct uio *uio, int ioflag, xfs_vfs_readlock(t, xfs_uio_to_proc(uio)); xfs_vop_read(t, uio, ioflag, cred, error); xfs_vfs_unlock(t, xfs_uio_to_proc(uio)); - - if (uio->uio_iovcnt && uio->uio_iov[0].iov_len > 0) - XFSDEB(XDEBVNOPS, ("xfs_read: byte: %d\n", - ((char *)uio->uio_iov[0].iov_base)[0])); } XFSDEB(XDEBVNOPS, ("xfs_read offset: %lu resid: %d\n", @@ -391,7 +407,7 @@ xfs_setattr_common(struct vnode *vp, struct vattr *vap, #define CHECK_XFSATTR(A, cast) (vap->A == cast VNOVAL || vap->A == xn->attr.A) if (CHECK_XFSATTR(va_mode,(mode_t)) && CHECK_XFSATTR(va_nlink,(short)) && - CHECK_XFSATTR(va_size,(u_quad_t)) && + CHECK_XFSATTR(va_size,(va_size_t)) && CHECK_XFSATTR(va_uid,(uid_t)) && CHECK_XFSATTR(va_gid,(gid_t)) && CHECK_XFSATTR(va_mtime.tv_sec,(unsigned int)) && @@ -420,10 +436,14 @@ xfs_setattr_common(struct vnode *vp, struct vattr *vap, vattr2xfs_attr(vap, &msg.attr); if (XFS_TOKEN_GOT(xn, XFS_DATA_R)) { if (vp->v_type == VREG) { - if (vap->va_size != (u_quad_t)VNOVAL) + if (vap->va_size != (va_size_t)VNOVAL) XA_SET_SIZE(&msg.attr, vap->va_size); else XA_SET_SIZE(&msg.attr, xn->attr.va_size); +#ifdef __APPLE__ + if (UBCINFOEXISTS(vp)) + ubc_setsize(vp, msg.attr.xa_size); +#endif } if (vap->va_mtime.tv_sec != (unsigned int)VNOVAL) XA_SET_MTIME(&msg.attr, vap->va_mtime.tv_sec); @@ -432,7 +452,7 @@ xfs_setattr_common(struct vnode *vp, struct vattr *vap, } XFS_TOKEN_CLEAR(xn, XFS_ATTR_VALID, XFS_ATTR_MASK); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } @@ -508,8 +528,13 @@ xfs_lookup_common(struct vnode *dvp, struct proc *proc = xfs_cnp_to_proc(cnp); struct ucred *cred = xfs_proc_to_cred(proc); + XFSDEB(XDEBVNOPS, ("xfs_lookup_common: enter\n")); + *vpp = NULL; + if (cnp->cn_namelen >= XFS_MAX_NAME) + return ENAMETOOLONG; + if (dvp->v_type != VDIR) return ENOTDIR; @@ -524,6 +549,9 @@ xfs_lookup_common(struct vnode *dvp, if (error != 0) goto done; + XFSDEB(XDEBVNOPS, ("xfs_lookup_common: dvp = %lx\n", (unsigned long) dvp)); + + error = xfs_dnlc_lookup(dvp, cnp, vpp); if (error == 0) { @@ -548,12 +576,10 @@ xfs_lookup_common(struct vnode *dvp, msg.cred.pag = XFS_ANONYMOUSID; } msg.parent_handle = d->handle; - - bcopy(cnp->cn_nameptr, msg.name, cnp->cn_namelen); + memcpy(msg.name, cnp->cn_nameptr, cnp->cn_namelen); msg.name[cnp->cn_namelen] = '\0'; - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); - + error = xfs_message_rpc(xfsp->fd, &msg.header, + sizeof(msg), proc); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; if(error == ENOENT && cnp->cn_nameiop != CREATE) { @@ -569,6 +595,7 @@ xfs_lookup_common(struct vnode *dvp, } while (error == 0); done: + XFSDEB(XDEBVNOPS, ("xfs_lookup_common: return\n")); return error; } @@ -590,7 +617,8 @@ xfs_create_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_CREATE; msg.parent_handle = xn->handle; - strncpy(msg.name, name, 256); + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) + return ENAMETOOLONG; vattr2xfs_attr(vap, &msg.attr); msg.mode = 0; /* XXX - mode */ @@ -603,7 +631,7 @@ xfs_create_common(struct vnode *dvp, } - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; @@ -633,25 +661,19 @@ xfs_remove_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_REMOVE; msg.parent_handle = xn->handle; - strncpy(msg.name, name, 256); msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) + error = ENAMETOOLONG; + else + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) &msg)->error; if (error == 0) xfs_dnlc_purge (vp); -#if !defined(__FreeBSD__) || __FreeBSD_version < 300000 - if (dvp == vp) - vrele(vp); - else - vput(vp); - vput(dvp); -#endif - return error; } @@ -680,12 +702,14 @@ xfs_rename_common(struct vnode *fdvp, msg.header.opcode = XFS_MSG_RENAME; msg.old_parent_handle = VNODE_TO_XNODE(fdvp)->handle; - strncpy(msg.old_name, fname, 256); + if (strlcpy(msg.old_name, fname, sizeof(msg.old_name)) >= XFS_MAX_NAME) + return ENAMETOOLONG; msg.new_parent_handle = VNODE_TO_XNODE(tdvp)->handle; - strncpy(msg.new_name, tname, 256); + if (strlcpy(msg.new_name, tname, sizeof(msg.new_name)) >= XFS_MAX_NAME) + return ENAMETOOLONG; msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) &msg)->error; @@ -713,7 +737,8 @@ xfs_mkdir_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_MKDIR; msg.parent_handle = xn->handle; - strncpy(msg.name, name, 256); + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) + return ENAMETOOLONG; vattr2xfs_attr(vap, &msg.attr); if (cred != NOCRED) { msg.cred.uid = cred->cr_uid; @@ -722,7 +747,7 @@ xfs_mkdir_common(struct vnode *dvp, msg.cred.uid = 0; msg.cred.pag = XFS_ANONYMOUSID; } - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } @@ -746,24 +771,18 @@ xfs_rmdir_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_RMDIR; msg.parent_handle = xn->handle; - strncpy(msg.name, name, 256); msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) + error = ENAMETOOLONG; + else + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) &msg)->error; if (error == 0) xfs_dnlc_purge (vp); -#if !defined(__FreeBSD__) || __FreeBSD_version < 300000 - if (dvp == vp) - vrele(vp); - else - vput(vp); - vput(dvp); -#endif - XFSDEB(XDEBVNOPS, ("xfs_rmdir error: %d\n", error)); return error; @@ -819,11 +838,12 @@ xfs_link_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_LINK; msg.parent_handle = xn->handle; msg.from_handle = xn2->handle; - strncpy(msg.name, name, 256); + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) + return ENAMETOOLONG; msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; @@ -849,30 +869,22 @@ xfs_symlink_common(struct vnode *dvp, msg.header.opcode = XFS_MSG_SYMLINK; msg.parent_handle = xn->handle; - strncpy(msg.name, name, sizeof(msg.name)); - msg.name[sizeof(msg.name) - 1] = '\0'; vattr2xfs_attr(vap, &msg.attr); msg.cred.uid = cred->cr_uid; msg.cred.pag = xfs_get_pag(cred); - strncpy (msg.contents, target, sizeof(msg.contents)); - msg.contents[sizeof(msg.contents) - 1] = '\0'; - - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + if (strlcpy (msg.contents, target, sizeof(msg.contents)) >= XFS_MAX_SYMLINK_CONTENT) { + error = ENAMETOOLONG; + goto done; + } + if (strlcpy(msg.name, name, sizeof(msg.name)) >= XFS_MAX_NAME) { + error = ENAMETOOLONG; + goto done; + } + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), proc); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; - if (error == 0) { - error = xfs_lookup_common(dvp, cnp, vpp); -#if !defined(__FreeBSD__) || __FreeBSD_version < 400012 - if (error == 0) - vput (*vpp); -#endif - } - -#if !defined(__FreeBSD__) - vput(dvp); -#endif - + done: return error; } @@ -918,18 +930,23 @@ xfs_inactive_common(struct vnode *vp, struct proc *p) error = xfs_fsync_common(vp, xn->cred, /* XXX */ 0, p); if (error) { printf ("xfs_inactive: failed writing back data: %d\n", error); + xn->flags &= ~XFS_DATA_DIRTY; } #ifndef __osf__ xfs_vfs_unlock(vp, p); /* If this node is no longer valid, recycle immediately. */ - if (!XFS_TOKEN_GOT(xn, XFS_ATTR_R | XFS_ATTR_W)) { + if (!XFS_TOKEN_GOT(xn, XFS_ATTR_R | XFS_ATTR_W) + || (xn->flags & XFS_STALE) == XFS_STALE) { XFSDEB(XDEBVNOPS, ("xfs_inactive: vrecycle\n")); vrecycle(vp, 0, p); } #else - /* XXX ? */ + + XFSDEB(XDEBVNOPS, ("xfs_inactive: vp = %lx vp->v_usecount= %d\n", + (unsigned long)vp, vp?vp->v_usecount:0)); #endif + xn->flags &= ~XFS_STALE; XFSDEB(XDEBVNOPS, ("return: xfs_inactive\n")); @@ -943,7 +960,7 @@ xfs_reclaim_common(struct vnode *vp) struct xfs *xfsp = XFS_FROM_VNODE(vp); struct xfs_node *xn = VNODE_TO_XNODE(vp); - XFSDEB(XDEBVNOPS, ("xfs_reclaim: %lx", + XFSDEB(XDEBVNOPS, ("xfs_reclaim: %lx\n", (unsigned long)vp)); XFS_TOKEN_CLEAR(xn, @@ -998,7 +1015,7 @@ xfs_advlock_common(struct vnode *dvp, msg.cred.uid = 0; msg.cred.pag = XFS_ANONYMOUSID; } - error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg)); + error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg), p); if (error == 0) error = ((struct xfs_message_wakeup *) & msg)->error; } diff --git a/sys/xfs/xfs_vnodeops.h b/sys/xfs/xfs_vnodeops.h index 7848ca28a54..84261ab6341 100644 --- a/sys/xfs/xfs_vnodeops.h +++ b/sys/xfs/xfs_vnodeops.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: xfs_vnodeops.h,v 1.3 2000/09/11 14:26:54 art Exp $ */ +/* $Id: xfs_vnodeops.h,v 1.4 2002/06/07 04:10:32 hin Exp $ */ #ifndef _xfs_vnodeops_h #define _xfs_vnodeops_h diff --git a/sys/xfs/xfs_vopdefs.h b/sys/xfs/xfs_vopdefs.h index 4bbf5df2391..b31fa1ac4d3 100644 --- a/sys/xfs/xfs_vopdefs.h +++ b/sys/xfs/xfs_vopdefs.h @@ -12,6 +12,7 @@ #define HAVE_VOP_LEASE 1 #define HAVE_VOP_IOCTL 1 #define HAVE_VOP_SELECT 1 +#define HAVE_VOP_KQFILTER 1 #define HAVE_VOP_REVOKE 1 #define HAVE_VOP_FSYNC 1 #define HAVE_VOP_REMOVE 1 @@ -31,7 +32,9 @@ #define HAVE_VOP_PRINT 1 #define HAVE_VOP_PATHCONF 1 #define HAVE_VOP_ADVLOCK 1 -#define HAVE_VOP_BLKATOFF 1 +#define HAVE_VOP_REALLOCBLKS 1 #define HAVE_VOP_WHITEOUT 1 +#define HAVE_VOP_GETEXTATTR 1 +#define HAVE_VOP_SETEXTATTR 1 #define HAVE_VOP_STRATEGY 1 #define HAVE_VOP_BWRITE 1 |