summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/xfs/xfs_attr.h53
-rw-r--r--sys/xfs/xfs_common-bsd.c66
-rw-r--r--sys/xfs/xfs_common.h26
-rw-r--r--sys/xfs/xfs_config.h762
-rw-r--r--sys/xfs/xfs_deb.c2
-rw-r--r--sys/xfs/xfs_deb.h2
-rw-r--r--sys/xfs/xfs_debug.h2
-rw-r--r--sys/xfs/xfs_dev-bsd.c142
-rw-r--r--sys/xfs/xfs_dev-common.c149
-rw-r--r--sys/xfs/xfs_dev.h21
-rw-r--r--sys/xfs/xfs_fs.h19
-rw-r--r--sys/xfs/xfs_locl.h119
-rw-r--r--sys/xfs/xfs_message.c321
-rw-r--r--sys/xfs/xfs_message.h113
-rw-r--r--sys/xfs/xfs_msg_locl.h14
-rw-r--r--sys/xfs/xfs_node-bsd.c270
-rw-r--r--sys/xfs/xfs_node.h27
-rw-r--r--sys/xfs/xfs_pioctl.h8
-rw-r--r--sys/xfs/xfs_syscalls-common.c206
-rw-r--r--sys/xfs/xfs_syscalls.h49
-rw-r--r--sys/xfs/xfs_vfsops-bsd.c218
-rw-r--r--sys/xfs/xfs_vfsops-bsd.h29
-rw-r--r--sys/xfs/xfs_vfsops-common.c62
-rw-r--r--sys/xfs/xfs_vfsops-openbsd.c34
-rw-r--r--sys/xfs/xfs_vfsops.h10
-rw-r--r--sys/xfs/xfs_vnodeops-bsd.c478
-rw-r--r--sys/xfs/xfs_vnodeops-common.c314
-rw-r--r--sys/xfs/xfs_vnodeops.h86
-rw-r--r--sys/xfs/xfs_vopdefs.h2
29 files changed, 2530 insertions, 1074 deletions
diff --git a/sys/xfs/xfs_attr.h b/sys/xfs/xfs_attr.h
index 29057b04a46..71c79bd5014 100644
--- a/sys/xfs/xfs_attr.h
+++ b/sys/xfs/xfs_attr.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_attr.h,v 1.3 2000/03/03 00:54:57 todd Exp $ */
/*
- * Copyright (c) 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_attr.h,v 1.4 2000/09/11 14:26:51 art Exp $ */
#ifndef _XFS_ATTR_H
#define _XFS_ATTR_H
@@ -53,9 +53,15 @@
#define XA_V_FILEID (1 << 8)
#define XA_V_TYPE (1 << 9)
-enum xfs_file_type { XFS_FILE_NON, XFS_FILE_REG, XFS_FILE_DIR,
- XFS_FILE_BLK, XFS_FILE_CHR, XFS_FILE_LNK,
- XFS_FILE_SOCK, XFS_FILE_FIFO, XFS_FILE_BAD };
+#define XFS_FILE_NON 1
+#define XFS_FILE_REG 2
+#define XFS_FILE_DIR 3
+#define XFS_FILE_BLK 4
+#define XFS_FILE_CHR 5
+#define XFS_FILE_LNK 6
+#define XFS_FILE_SOCK 7
+#define XFS_FILE_FIFO 8
+#define XFS_FILE_BAD 9
#define XA_CLEAR(xa_p) \
((xa_p)->valid = XA_V_NONE)
@@ -102,31 +108,24 @@ enum xfs_file_type { XFS_FILE_NON, XFS_FILE_REG, XFS_FILE_DIR,
#define XA_VALID_TYPE(xa_p) \
(((xa_p)->valid) & XA_V_TYPE)
-/*
- * Under glibc and Linux, foo_t in the kernel is not the same type as
- * foo_t in user-level. Therefore we need these defines.
- */
-
-#if !defined(HAVE_LINUX_TYPES_H) && !defined(__KERNEL__)
-typedef mode_t __kernel_mode_t;
-typedef nlink_t __kernel_nlink_t;
-typedef off_t __kernel_off_t;
-typedef uid_t __kernel_uid_t;
-typedef gid_t __kernel_gid_t;
-#endif
-
struct xfs_attr {
u_int32_t valid;
- __kernel_mode_t xa_mode;
- __kernel_nlink_t xa_nlink;
- __kernel_off_t xa_size;
- __kernel_uid_t xa_uid;
- __kernel_gid_t xa_gid;
- time_t xa_atime;
- time_t xa_mtime;
- time_t xa_ctime;
+ u_int32_t xa_mode;
+
+ u_int32_t xa_nlink;
+ u_int32_t xa_size;
+
+ u_int32_t xa_uid;
+ u_int32_t xa_gid;
+
+ u_int32_t xa_atime;
+ u_int32_t xa_mtime;
+
+ u_int32_t xa_ctime;
u_int32_t xa_fileid;
- enum xfs_file_type xa_type;
+
+ u_int32_t xa_type;
+ u_int32_t pad1;
};
#endif /* _XFS_ATTR_H */
diff --git a/sys/xfs/xfs_common-bsd.c b/sys/xfs/xfs_common-bsd.c
index ce9c86b0c07..b5501d1f57a 100644
--- a/sys/xfs/xfs_common-bsd.c
+++ b/sys/xfs/xfs_common-bsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_common-bsd.c,v 1.2 2000/03/03 00:54:57 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -38,30 +36,84 @@
* SUCH DAMAGE.
*/
-#ifdef XFS_DEBUG
#include <xfs/xfs_locl.h>
#include <xfs/xfs_common.h>
#include <xfs/xfs_deb.h>
-RCSID("$OpenBSD: xfs_common-bsd.c,v 1.2 2000/03/03 00:54:57 todd Exp $");
+RCSID("$Id: xfs_common-bsd.c,v 1.3 2000/09/11 14:26:51 art Exp $");
+
+#ifdef MALLOC_DEFINE
+MALLOC_DEFINE(M_XFS, "xfs", "xfs buffer");
+#endif
+#ifdef XFS_DEBUG
static u_int xfs_allocs;
static u_int xfs_frees;
void *
xfs_alloc(u_int size)
{
+ void *ret;
+
xfs_allocs++;
XFSDEB(XDEBMEM, ("xfs_alloc: xfs_allocs - xfs_frees %d\n",
xfs_allocs - xfs_frees));
- return malloc(size, M_TEMP, M_WAITOK); /* What kind? */
+ MALLOC(ret, void *, size, M_XFS, M_WAITOK);
+ return ret;
}
void
xfs_free(void *ptr, u_int size)
{
xfs_frees++;
- free(ptr, M_TEMP);
+ FREE(ptr, M_XFS);
+}
+
+#endif /* XFS_DEBUG */
+
+int
+xfs_suser(struct proc *p)
+{
+#ifdef HAVE_TWO_ARGUMENT_SUSER
+ return suser (xfs_proc_to_cred(p), NULL);
+#else
+ return suser (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
+ */
+
+#ifdef HAVE_KERNEL_DEVTONAME
+
+const char *
+xfs_devtoname_r (dev_t dev, char *buf, size_t sz)
+{
+ return devtoname (dev);
}
+
+#else /* !HAVE_KERNEL_DEVTONAME */
+
+const char *
+xfs_devtoname_r (dev_t dev, char *buf, size_t sz)
+{
+#ifdef HAVE_KERNEL_SNPRINTF
+ snprintf (buf, sz, "%u/%u", major(dev), minor(dev));
+ return buf;
+#else
+ return "<unknown device>";
#endif
+}
+
+#endif /* HAVE_KERNEL_DEVTONAME */
diff --git a/sys/xfs/xfs_common.h b/sys/xfs/xfs_common.h
index 97ed1a8dba1..bf6cbd31830 100644
--- a/sys/xfs/xfs_common.h
+++ b/sys/xfs/xfs_common.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_common.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,20 +36,37 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_common.h,v 1.5 2000/09/11 14:26:51 art Exp $ */
#ifndef _xfs_common_h
#define _xfs_common_h
+#if defined(MALLOC_DECLARE)
+MALLOC_DECLARE(M_XFS);
+#elif !defined(M_XFS)
+#define M_XFS M_TEMP
+#endif
+
#ifdef XFS_DEBUG
void *xfs_alloc(u_int size);
void xfs_free(void *, u_int size);
#else
#ifdef __osf__
-#define xfs_alloc(a) malloc((a), BUCKETINDEX(a), M_TEMP, M_WAITOK)
+#define xfs_alloc(a) malloc((a), BUCKETINDEX(a), M_XFS, M_WAITOK)
#else
-#define xfs_alloc(a) malloc((a), M_TEMP, M_WAITOK)
+#define xfs_alloc(a) malloc((a), M_XFS, M_WAITOK)
#endif
-#define xfs_free(a, size) free(a, M_TEMP)
+#define xfs_free(a, size) free(a, M_XFS)
#endif /* XFS_DEBUG */
+int xfs_suser(struct proc *p);
+
+#ifndef HAVE_KERNEL_MEMCPY
+void *
+memcpy (void *s1, const void *s2, size_t n);
+#endif
+
+const char *
+xfs_devtoname_r (dev_t dev, char *buf, size_t sz);
+
#endif /* _xfs_common_h */
diff --git a/sys/xfs/xfs_config.h b/sys/xfs/xfs_config.h
index aa8a53346de..92de1f9b3a3 100644
--- a/sys/xfs/xfs_config.h
+++ b/sys/xfs/xfs_config.h
@@ -1,6 +1,9 @@
/* include/config.h. Generated automatically by configure. */
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
+/* Define to empty if the keyword does not work. */
+/* #undef const */
+
/* Define if you have a working `mmap' system call. */
#define HAVE_MMAP 1
@@ -19,113 +22,26 @@
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
-/* Define this if we can include both sys/dir.h and dirent.h */
-#define USE_SYS_DIR_H 1
-
-/* Define this if RETSIGTYPE == void */
-/* #undef VOID_RETSIGTYPE */
-
-/* Define this if struct winsize is declared in sys/termios.h */
-#define HAVE_STRUCT_WINSIZE 1
-
-/* Define this if struct msghdr is declared in sys/socket.h */
-#define HAVE_STRUCT_MSGHDR 1
-
-/* Define this if struct iovec is declared in sys/uio.h */
-#define HAVE_STRUCT_IOVEC 1
-
-/* Define this if struct winsize have ws_xpixel */
-#define HAVE_WS_XPIXEL 1
-
-/* Define this if struct winsize have ws_ypixel */
-#define HAVE_WS_YPIXEL 1
-
-/* Define this if `struct sockaddr' includes sa_len */
-#define SOCKADDR_HAS_SA_LEN 1
-
-/* define if the system is missing a prototype for strtok_r() */
-/* #undef NEED_STRTOK_R_PROTO */
-
-/* define if you have h_errno */
-#define HAVE_H_ERRNO 1
-
-/* define if you have h_errlist but not hstrerror */
-#define HAVE_H_ERRLIST 1
-
-/* define if you have h_nerr but not hstrerror */
-#define HAVE_H_NERR 1
-
-/* define if your system has a declaration for h_errlist */
-/* #undef HAVE_H_ERRLIST_DECLARATION */
-
-/* define if your system has a declaration for h_nerr */
-/* #undef HAVE_H_NERR_DECLARATION */
-
-/* define if your system has a declaration for h_errno */
-#define HAVE_H_ERRNO_DECLARATION 1
-
-/* define if your system has optreset */
-#define HAVE_OPTRESET 1
-
-/* define if your system has a declaration for optreset */
-#define HAVE_OPTRESET_DECLARATION 1
-
-/* define if your compiler has __FUNCTION__ */
-#define HAVE___FUNCTION__ 1
-
-/* define if your compiler has __attribute__ */
-#define HAVE___ATTRIBUTE__ 1
-
-/* Check if select need a prototype */
-/* #undef NEED_SELECT_PROTO */
-
-/* Define if you have the FOUR_ARGUMENT_VFS_BUSY function. */
-#define HAVE_FOUR_ARGUMENT_VFS_BUSY 1
-
-/* Define if you have the FOUR_ARGUMENT_VFS_OBJECT_CREATE function. */
-/* #undef HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE */
-
-/* Define if you have the ONE_ARGUMENT_VOP_LOCK function. */
-/* #undef HAVE_ONE_ARGUMENT_VOP_LOCK */
-
-/* Define if you have the THREE_ARGUMENT_VFS_BUSY function. */
-/* #undef HAVE_THREE_ARGUMENT_VFS_BUSY */
-
-/* Define if you have the THREE_ARGUMENT_VGET function. */
-#define HAVE_THREE_ARGUMENT_VGET 1
-
-/* Define if you have the THREE_ARGUMENT_VOP_LOCK function. */
-#define HAVE_THREE_ARGUMENT_VOP_LOCK 1
-
-/* Define if you have the TWO_ARGUMENT_VFS_GETNEWFSID function. */
-/* #undef HAVE_TWO_ARGUMENT_VFS_GETNEWFSID */
-
-/* Define if you have the TWO_ARGUMENT_VGET function. */
-/* #undef HAVE_TWO_ARGUMENT_VGET */
-
-/* Define if you have the TWO_ARGUMENT_VOP_LOCK function. */
-/* #undef HAVE_TWO_ARGUMENT_VOP_LOCK */
-
/* Define if you have the asnprintf function. */
/* #undef HAVE_ASNPRINTF */
/* Define if you have the asprintf function. */
#define HAVE_ASPRINTF 1
+/* Define if you have the bool function. */
+/* #undef HAVE_BOOL */
+
/* Define if you have the chown function. */
#define HAVE_CHOWN 1
/* Define if you have the daemon function. */
#define HAVE_DAEMON 1
-/* Define if you have the dbm_firstkey function. */
-#define HAVE_DBM_FIRSTKEY 1
-
/* Define if you have the dn_expand function. */
#define HAVE_DN_EXPAND 1
/* Define if you have the el_init function. */
-#define HAVE_EL_INIT 1
+/* #undef HAVE_EL_INIT */
/* Define if you have the err function. */
#define HAVE_ERR 1
@@ -139,6 +55,9 @@
/* Define if you have the fcntl function. */
#define HAVE_FCNTL 1
+/* Define if you have the fhopen function. */
+#define HAVE_FHOPEN 1
+
/* Define if you have the flock function. */
#define HAVE_FLOCK 1
@@ -148,9 +67,15 @@
/* Define if you have the getdtablesize function. */
#define HAVE_GETDTABLESIZE 1
+/* Define if you have the getfh function. */
+#define HAVE_GETFH 1
+
/* Define if you have the gethostbyname function. */
#define HAVE_GETHOSTBYNAME 1
+/* Define if you have the getitimer function. */
+#define HAVE_GETITIMER 1
+
/* Define if you have the getopt function. */
#define HAVE_GETOPT 1
@@ -181,12 +106,153 @@
/* Define if you have the initgroups function. */
#define HAVE_INITGROUPS 1
+/* Define if you have the int16 function. */
+/* #undef HAVE_INT16 */
+
+/* Define if you have the int16_t function. */
+#define HAVE_INT16_T 1
+
+/* Define if you have the int32 function. */
+/* #undef HAVE_INT32 */
+
+/* Define if you have the int32_t function. */
+#define HAVE_INT32_T 1
+
+/* Define if you have the int64_t function. */
+#define HAVE_INT64_T 1
+
+/* Define if you have the int8_t function. */
+#define HAVE_INT8_T 1
+
+/* Define if you have the intptr_t function. */
+/* #undef HAVE_INTPTR_T */
+
+/* Define if you have the kernel_aout_sysent function. */
+/* #undef HAVE_KERNEL_AOUT_SYSENT */
+
+/* Define if you have the kernel_cdevsw_add function. */
+/* #undef HAVE_KERNEL_CDEVSW_ADD */
+
+/* Define if you have the kernel_debuglockmgr function. */
+/* #undef HAVE_KERNEL_DEBUGLOCKMGR */
+
+/* Define if you have the kernel_devtoname function. */
+/* #undef HAVE_KERNEL_DEVTONAME */
+
+/* Define if you have the kernel_doforce function. */
+#define HAVE_KERNEL_DOFORCE 1
+
+/* Define if you have the kernel_genfs_revoke function. */
+/* #undef HAVE_KERNEL_GENFS_REVOKE */
+
+/* Define if you have the kernel_lockmgr function. */
+#define HAVE_KERNEL_LOCKMGR 1
+
+/* Define if you have the kernel_lockstatus function. */
+#define HAVE_KERNEL_LOCKSTATUS 1
+
+/* Define if you have the kernel_make_dev function. */
+/* #undef HAVE_KERNEL_MAKE_DEV */
+
+/* Define if you have the kernel_memcpy function. */
+#define HAVE_KERNEL_MEMCPY 1
+
+/* Define if you have the kernel_nosys function. */
+/* #undef HAVE_KERNEL_NOSYS */
+
+/* Define if you have the kernel_snprintf function. */
+#define HAVE_KERNEL_SNPRINTF 1
+
+/* Define if you have the kernel_sys_lkmnosys function. */
+#define HAVE_KERNEL_SYS_LKMNOSYS 1
+
+/* Define if you have the kernel_sys_nosys function. */
+#define HAVE_KERNEL_SYS_NOSYS 1
+
+/* Define if you have the kernel_udev2dev function. */
+/* #undef HAVE_KERNEL_UDEV2DEV */
+
+/* Define if you have the kernel_vfs_add_vnodeops function. */
+/* #undef HAVE_KERNEL_VFS_ADD_VNODEOPS */
+
+/* Define if you have the kernel_vfs_attach function. */
+/* #undef HAVE_KERNEL_VFS_ATTACH */
+
+/* Define if you have the kernel_vfs_cache_lookup function. */
+/* #undef HAVE_KERNEL_VFS_CACHE_LOOKUP */
+
+/* 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_object_create function. */
+/* #undef HAVE_KERNEL_VFS_OBJECT_CREATE */
+
+/* Define if you have the kernel_vfs_opv_init function. */
+#define HAVE_KERNEL_VFS_OPV_INIT 1
+
+/* Define if you have the kernel_vfs_opv_init_default function. */
+#define HAVE_KERNEL_VFS_OPV_INIT_DEFAULT 1
+
+/* Define if you have the kernel_vfs_opv_init_explicit function. */
+#define HAVE_KERNEL_VFS_OPV_INIT_EXPLICIT 1
+
+/* Define if you have the kernel_vfs_register function. */
+#define HAVE_KERNEL_VFS_REGISTER 1
+
+/* Define if you have the kernel_vgonel function. */
+#define HAVE_KERNEL_VGONEL 1
+
+/* Define if you have the kernel_vnode_pager_generic_getpages function. */
+/* #undef HAVE_KERNEL_VNODE_PAGER_GENERIC_GETPAGES */
+
+/* Define if you have the kernel_vnode_pager_generic_putpages function. */
+/* #undef HAVE_KERNEL_VNODE_PAGER_GENERIC_PUTPAGES */
+
+/* Define if you have the kernel_vnode_pager_setsize function. */
+/* #undef HAVE_KERNEL_VNODE_PAGER_SETSIZE */
+
+/* Define if you have the kernel_vop_revoke function. */
+/* #undef HAVE_KERNEL_VOP_REVOKE */
+
+/* Define if you have the kernel_zfreei function. */
+/* #undef HAVE_KERNEL_ZFREEI */
+
+/* Define if you have the krb_afslog_uid function. */
+#define HAVE_KRB_AFSLOG_UID 1
+
/* Define if you have the kvm_nlist function. */
#define HAVE_KVM_NLIST 1
/* Define if you have the kvm_open function. */
#define HAVE_KVM_OPEN 1
+/* Define if you have the linux_kernel_int16_t function. */
+/* #undef HAVE_LINUX_KERNEL_INT16_T */
+
+/* Define if you have the linux_kernel_int32_t function. */
+/* #undef HAVE_LINUX_KERNEL_INT32_T */
+
+/* Define if you have the linux_kernel_int64_t function. */
+/* #undef HAVE_LINUX_KERNEL_INT64_T */
+
+/* Define if you have the linux_kernel_int8_t function. */
+/* #undef HAVE_LINUX_KERNEL_INT8_T */
+
+/* Define if you have the linux_kernel_u_int16_t function. */
+/* #undef HAVE_LINUX_KERNEL_U_INT16_T */
+
+/* Define if you have the linux_kernel_u_int32_t function. */
+/* #undef HAVE_LINUX_KERNEL_U_INT32_T */
+
+/* Define if you have the linux_kernel_u_int64_t function. */
+/* #undef HAVE_LINUX_KERNEL_U_INT64_T */
+
+/* Define if you have the linux_kernel_u_int8_t function. */
+/* #undef HAVE_LINUX_KERNEL_U_INT8_T */
+
/* Define if you have the lstat function. */
#define HAVE_LSTAT 1
@@ -199,6 +265,9 @@
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
+/* Define if you have the off64_t function. */
+/* #undef HAVE_OFF64_T */
+
/* Define if you have the putenv function. */
#define HAVE_PUTENV 1
@@ -214,6 +283,9 @@
/* Define if you have the recvmsg function. */
#define HAVE_RECVMSG 1
+/* Define if you have the register_t function. */
+#define HAVE_REGISTER_T 1
+
/* Define if you have the res_search function. */
#define HAVE_RES_SEARCH 1
@@ -244,12 +316,12 @@
/* Define if you have the setsockopt function. */
#define HAVE_SETSOCKOPT 1
-/* Define if you have the snprintf function. */
-#define HAVE_SNPRINTF 1
-
/* Define if you have the socket function. */
#define HAVE_SOCKET 1
+/* Define if you have the ssize_t function. */
+#define HAVE_SSIZE_T 1
+
/* Define if you have the strcasecmp function. */
#define HAVE_STRCASECMP 1
@@ -262,17 +334,29 @@
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
+/* Define if you have the strlcat function. */
+#define HAVE_STRLCAT 1
+
+/* Define if you have the strlcpy function. */
+#define HAVE_STRLCPY 1
+
/* Define if you have the strlwr function. */
/* #undef HAVE_STRLWR */
/* Define if you have the strnlen function. */
/* #undef HAVE_STRNLEN */
+/* Define if you have the strptime function. */
+#define HAVE_STRPTIME 1
+
/* Define if you have the strsep function. */
#define HAVE_STRSEP 1
+/* Define if you have the strsep_copy function. */
+/* #undef HAVE_STRSEP_COPY */
+
/* Define if you have the strtok_r function. */
-/* #undef HAVE_STRTOK_R */
+#define HAVE_STRTOK_R 1
/* Define if you have the strupr function. */
/* #undef HAVE_STRUPR */
@@ -292,6 +376,24 @@
/* Define if you have the thr_yield function. */
/* #undef HAVE_THR_YIELD */
+/* Define if you have the u_int16 function. */
+/* #undef HAVE_U_INT16 */
+
+/* Define if you have the u_int16_t function. */
+#define HAVE_U_INT16_T 1
+
+/* Define if you have the u_int32 function. */
+/* #undef HAVE_U_INT32 */
+
+/* Define if you have the u_int32_t function. */
+#define HAVE_U_INT32_T 1
+
+/* Define if you have the u_int64_t function. */
+#define HAVE_U_INT64_T 1
+
+/* Define if you have the u_int8_t function. */
+#define HAVE_U_INT8_T 1
+
/* Define if you have the unsetenv function. */
#define HAVE_UNSETENV 1
@@ -340,11 +442,8 @@
/* Define if you have the <arpa/nameser.h> header file. */
#define HAVE_ARPA_NAMESER_H 1
-/* Define if you have the <asm/smp_lock.h> header file. */
-/* #undef HAVE_ASM_SMP_LOCK_H */
-
-/* Define if you have the <asm/smplock.h> header file. */
-/* #undef HAVE_ASM_SMPLOCK_H */
+/* Define if you have the <com_err.h> header file. */
+#define HAVE_COM_ERR_H 1
/* Define if you have the <crypt.h> header file. */
/* #undef HAVE_CRYPT_H */
@@ -358,6 +457,9 @@
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
+/* Define if you have the <et/com_err.h> header file. */
+/* #undef HAVE_ET_COM_ERR_H */
+
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
@@ -379,11 +481,8 @@
/* Define if you have the <linux/devfs_fs.h> header file. */
/* #undef HAVE_LINUX_DEVFS_FS_H */
-/* Define if you have the <linux/modversions.h> header file. */
-/* #undef HAVE_LINUX_MODVERSIONS_H */
-
-/* Define if you have the <linux/types.h> header file. */
-/* #undef HAVE_LINUX_TYPES_H */
+/* Define if you have the <linux/devfs_fs_kernel.h> header file. */
+/* #undef HAVE_LINUX_DEVFS_FS_KERNEL_H */
/* Define if you have the <machine/alpha/asm.h> header file. */
/* #undef HAVE_MACHINE_ALPHA_ASM_H */
@@ -391,6 +490,9 @@
/* Define if you have the <machine/asm.h> header file. */
#define HAVE_MACHINE_ASM_H 1
+/* Define if you have the <machine/endian.h> header file. */
+#define HAVE_MACHINE_ENDIAN_H 1
+
/* Define if you have the <machine/regdef.h> header file. */
/* #undef HAVE_MACHINE_REGDEF_H */
@@ -436,12 +538,18 @@
/* Define if you have the <shadow.h> header file. */
/* #undef HAVE_SHADOW_H */
+/* Define if you have the <sys/attr.h> header file. */
+/* #undef HAVE_SYS_ATTR_H */
+
/* Define if you have the <sys/bitypes.h> header file. */
/* #undef HAVE_SYS_BITYPES_H */
/* Define if you have the <sys/cdefs.h> header file. */
#define HAVE_SYS_CDEFS_H 1
+/* Define if you have the <sys/dir.h> header file. */
+#define HAVE_SYS_DIR_H 1
+
/* Define if you have the <sys/filedesc.h> header file. */
#define HAVE_SYS_FILEDESC_H 1
@@ -481,6 +589,9 @@
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
+/* Define if you have the <sys/signalvar.h> header file. */
+#define HAVE_SYS_SIGNALVAR_H 1
+
/* Define if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
@@ -526,6 +637,9 @@
/* Define if you have the <sys/vfs.h> header file. */
/* #undef HAVE_SYS_VFS_H */
+/* Define if you have the <sys/wait.h> header file. */
+#define HAVE_SYS_WAIT_H 1
+
/* Define if you have the <syslog.h> header file. */
#define HAVE_SYSLOG_H 1
@@ -535,6 +649,9 @@
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
+/* Define if you have the <uvm/uvm_extern.h> header file. */
+#define HAVE_UVM_UVM_EXTERN_H 1
+
/* Define if you have the <vm/vm.h> header file. */
#define HAVE_VM_VM_H 1
@@ -556,26 +673,23 @@
/* Define if you have the curses library (-lcurses). */
/* #undef HAVE_LIBCURSES */
-/* Define if you have the db library (-ldb). */
-/* #undef HAVE_LIBDB */
-
/* Define if you have the edit library (-ledit). */
-#define HAVE_LIBEDIT 1
+/* #undef HAVE_LIBEDIT */
-/* Define if you have the gdbm library (-lgdbm). */
-/* #undef HAVE_LIBGDBM */
+/* Define if you have the editline library (-leditline). */
+/* #undef HAVE_LIBEDITLINE */
/* Define if you have the kvm library (-lkvm). */
#define HAVE_LIBKVM 1
-/* Define if you have the ndbm library (-lndbm). */
-/* #undef HAVE_LIBNDBM */
+/* Define if you have the ncurses library (-lncurses). */
+/* #undef HAVE_LIBNCURSES */
/* Define if you have the nsl library (-lnsl). */
/* #undef HAVE_LIBNSL */
/* Define if you have the readline library (-lreadline). */
-/* #undef HAVE_LIBREADLINE */
+#define HAVE_LIBREADLINE 1
/* Define if you have the resolv library (-lresolv). */
/* #undef HAVE_LIBRESOLV */
@@ -589,243 +703,347 @@
/* Define if you have the termcap library (-ltermcap). */
#define HAVE_LIBTERMCAP 1
-#define HAVE_INT8_T 1
-#define HAVE_INT16_T 1
-#define HAVE_INT32_T 1
-#define HAVE_INT64_T 1
-#define HAVE_U_INT8_T 1
-#define HAVE_U_INT16_T 1
-#define HAVE_U_INT32_T 1
-#define HAVE_U_INT64_T 1
-/* #undef HAVE_BOOL */
-#define HAVE_SSIZE_T 1
-#define HAVE_REGISTER_T 1
-/* #undef HAVE_INT32 */
-/* #undef HAVE_U_INT32 */
-/* #undef HAVE_INTPTR_T */
+/* what package is this? */
+#define PACKAGE "arla"
+
+/* and what version? */
+#define VERSION "0.35pre"
+/* how should ntohl be done? */
#define EFF_NTOHL ntohl
-/* RCSID */
-#define RCSID(msg) \
-static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
+/* define if you need 32 bit compat pioctl */
+/* #undef NEED_VICEIOCTL32 */
-#define VERSION "0.24pre"
-#define PACKAGE "arla"
+/* define this if on Irix6.4 or higher */
+/* #undef IRIX_64 */
-/* Check for posix signals */
-#define HAVE_POSIX_SIGNALS 1
+/* define if you need 32 bit compat pioctl */
+/* #undef NEED_VICEIOCTL32 */
-#define HAVE_READLINE 1
+/* define if you have kerberos 4 compat */
+/* #undef HAVE_KRB5_COMPAT_KRB4 */
-/* prefix for /dev/fd */
-/* #undef DEV_FD_PREFIX */
+/* define if you have kerberos 5 */
+/* #undef HAVE_KRB5 */
-/* does the system have /dev/fd? */
-/* #undef HAVE_DEV_FD */
+/* define if you have kerberos */
+#define KERBEROS 1
-/* we always have stds.h */
-#define HAVE_STDS_H
+/* define if you have kerberos */
+#define KERBEROS 1
+
+/* define if you have kerberos 4 */
+#define HAVE_KRB4 1
+
+/* define if you have struct msghdr */
+#define HAVE_STRUCT_MSGHDR 1
-/* We have krb_principal from kth-krb ? */
+/* define if you have struct iovec */
+#define HAVE_STRUCT_IOVEC 1
+
+/* define if you have a struct krb_principal */
#define HAVE_KRB_PRINCIPAL 1
-/* Define if you have a krb_get_err_text (otherwise, you should really
- get more modern kerberos code) */
+/* define if you have krb_get_err_text */
#define HAVE_KRB_GET_ERR_TEXT 1
-/* If we have _res */
-/* #undef HAVE__RES */
+/* define if you have krb_get_default_tkt_root */
+#define HAVE_KRB_GET_DEFAULT_TKT_ROOT 1
-/* Define if you have kerberos */
-#define KERBEROS 1
+/* define if you have krb_kdctimeofday */
+#define HAVE_KRB_KDCTIMEOFDAY 1
-/* Define if your kernel has a vop_nolock */
-/* #undef HAVE_KERNEL_VOP_NOLOCK */
+/* Define if you have the readline package. */
+/* #undef READLINE */
+
+/* define if you have a function readline */
+#define HAVE_READLINE 1
-/* Define if your kernel has a vop_nounlock */
-/* #undef HAVE_KERNEL_VOP_NOUNLOCK */
+/* define if you want to use mmaptime */
+/* #undef USE_MMAPTIME */
-/* Define if your kernel has a vop_noislocked */
-/* #undef HAVE_KERNEL_VOP_NOISLOCKED */
+/* define if you have a glibc-based system */
+/* #undef HAVE_GLIBC */
-/* Define if your kernel has a vop_stdnolock */
-/* #undef HAVE_KERNEL_VOP_STDLOCK */
+/* define if target is big endian */
+#define WORDS_BIGENDIAN 1
-/* Define if your kernel has a vop_stdnounlock */
-/* #undef HAVE_KERNEL_VOP_STDUNLOCK */
+/* define if sys/param.h defines the endiness */
+#define ENDIANESS_IN_SYS_PARAM_H 1
-/* Define if your kernel has a vop_stdnoislocked */
-/* #undef HAVE_KERNEL_VOP_STDISLOCKED */
+/* define if your compiler has __FUNCTION__ */
+#define HAVE___FUNCTION__ 1
-/* Define if your kernel has a vop_revoke */
-/* #undef HAVE_KERNEL_VOP_REVOKE */
+/* define if your compiler has __attribute__ */
+#define HAVE___ATTRIBUTE__ 1
-/* Define if your kernel has a genfs_nolock */
-/* #undef HAVE_KERNEL_GENFS_NOLOCK */
+/* Define if NDBM really is DB (creates files ending in .db). */
+#define HAVE_NEW_DB 1
-/* Define if your kernel has a genfs_nounlock */
-/* #undef HAVE_KERNEL_GENFS_NOUNLOCK */
+/* Define if you have NDBM (and not DBM) */
+#define NDBM 1
-/* Define if your kernel has a genfs_noislocked */
-/* #undef HAVE_KERNEL_GENFS_NOISLOCKED */
+/* define if struct winsize is declared in sys/termios.h */
+#define HAVE_STRUCT_WINSIZE 1
-/* Define if your kernel has a genfs_revoke */
-/* #undef HAVE_KERNEL_GENFS_REVOKE */
+/* define if struct winsize has ws_xpixel */
+#define HAVE_WS_XPIXEL 1
-/* Define if your kernel has a vfs_opv_init */
-#define HAVE_KERNEL_VFS_OPV_INIT 1
+/* define if struct winsize has ws_ypixel */
+#define HAVE_WS_YPIXEL 1
-/* Define if your kernel has a vfs_opv_init_default */
-#define HAVE_KERNEL_VFS_OPV_INIT_DEFAULT 1
+/* define if you have a working snprintf */
+#define HAVE_SNPRINTF 1
-/* Define if your kernel has a vfs_opv_init_explicit */
-#define HAVE_KERNEL_VFS_OPV_INIT_EXPLICIT 1
+/* define if the system is missing a prototype for snprintf() */
+/* #undef NEED_SNPRINTF_PROTO */
-/* Define if your kernel has a vfs_add_vnodeops */
-/* #undef HAVE_KERNEL_VFS_ADD_VNODEOPS */
+/* define if you have sigaction */
+#define HAVE_POSIX_SIGNALS 1
-/* Define if your kernel has a vfs_attach */
-/* #undef HAVE_KERNEL_VFS_ATTACH */
+/* define if you have res */
+/* #undef HAVE_RES */
-/* Define if your kernel has a vfs_register */
-#define HAVE_KERNEL_VFS_REGISTER 1
+/* define if your system declares res */
+/* #undef HAVE_RES_DECLARATION */
-/* Define if your kernel has a vfs_getnewfsid */
-#define HAVE_KERNEL_VFS_GETNEWFSID 1
+/* define if the system is missing a prototype for hstrerror() */
+/* #undef NEED_HSTRERROR_PROTO */
-/* Define if your kernel has a vfs_getvfs */
-#define HAVE_KERNEL_VFS_GETVFS 1
+/* define if hstrerror is const */
+#define NEED_HSTRERROR_CONST 1
-/* Define if your kernel has a vfs_object_create */
-/* #undef HAVE_KERNEL_VFS_OBJECT_CREATE */
+/* define if the system is missing a prototype for inet_aton() */
+/* #undef NEED_INET_ATON_PROTO */
-/* Define if your kernel has a zfreei */
-/* #undef HAVE_KERNEL_ZFREEI */
+/* define if getvfsbyname takes two arguments */
+/* #undef HAVE_GETVFSBYNAME_TWO_ARGS */
-/* Define if your kernel has a vfs_cache_lookup */
-/* #undef HAVE_KERNEL_VFS_CACHE_LOOKUP */
+/* define if you have optreset */
+#define HAVE_OPTRESET 1
-/* Define if your kernel has a vnode_pager_generic_putpages */
-/* #undef HAVE_KERNEL_VNODE_PAGER_GENERIC_PUTPAGES */
+/* define if your system declares optreset */
+#define HAVE_OPTRESET_DECLARATION 1
-/* Define if your kernel has a vnode_pager_generic_getpages */
-/* #undef HAVE_KERNEL_VNODE_PAGER_GENERIC_GETPAGES */
+/* define if your system declares optreset */
+#define HAVE_OPTRESET_DECLARATION 1
-/* Define if your kernel has a vnode_pager_setsize */
-#define HAVE_KERNEL_VNODE_PAGER_SETSIZE 1
+/* define if the system is missing a prototype for strtok_r() */
+/* #undef NEED_STRTOK_R_PROTO */
-/* Define if your kernel has a doforce */
-#define HAVE_KERNEL_DOFORCE 1
+/* define if the system is missing a prototype for select() */
+/* #undef NEED_SELECT_PROTO */
-/* Define if your struct dirent has a field d_type */
+/* define if you can include both dirent.h and sys/dir.h */
+#define DIRENT_AND_SYS_DIR_H 1
+
+/* Define if struct dirent has field d_type. */
#define HAVE_STRUCT_DIRENT_D_TYPE 1
-/* Define if your struct vfsconf has a field vfc_refcount */
+/* Define if struct sockaddr has field sa_len. */
+#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
+
+/* define if you have h_errno */
+#define HAVE_H_ERRNO 1
+
+/* define if your system declares h_errno */
+#define HAVE_H_ERRNO_DECLARATION 1
+
+/* define if you have h_errlist */
+#define HAVE_H_ERRLIST 1
+
+/* define if your system declares h_errlist */
+/* #undef HAVE_H_ERRLIST_DECLARATION */
+
+/* define if you have h_nerr */
+#define HAVE_H_NERR 1
+
+/* define if your system declares h_nerr */
+/* #undef HAVE_H_NERR_DECLARATION */
+
+/* define this if your as understands .register */
+/* #undef AS_UNDERSTANDS_REGISTER */
+
+/* define if you have a vop_t */
+/* #undef HAVE_VOP_T */
+
+/* if vfs_object_create takes four arguments */
+/* #undef HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE */
+
+/* define if VOP_LOCK takes one argument */
+/* #undef HAVE_ONE_ARGUMENT_VOP_LOCK */
+
+/* define if VOP_LOCK takes two arguments */
+/* #undef HAVE_TWO_ARGUMENT_VOP_LOCK */
+
+/* define if VOP_LOCK takes three arguments */
+#define HAVE_THREE_ARGUMENT_VOP_LOCK 1
+
+/* define if vfs_busy takes three arguments */
+/* #undef HAVE_THREE_ARGUMENT_VFS_BUSY */
+
+/* define if vfs_busy takes four arguments */
+#define HAVE_FOUR_ARGUMENT_VFS_BUSY 1
+
+/* define if vget takes one argument */
+/* #undef HAVE_ONE_ARGUMENT_VGET */
+
+/* define if vget takes two arguments */
+/* #undef HAVE_TWO_ARGUMENT_VGET */
+
+/* define if vget takes three arguments */
+#define HAVE_THREE_ARGUMENT_VGET 1
+
+/* define if suser takes two arguments */
+#define HAVE_TWO_ARGUMENT_SUSER 1
+
+/* define if vfs_getnewfsid takes two arguments */
+/* #undef HAVE_TWO_ARGUMENT_VFS_GETNEWFSID */
+
+/* define if lockmgr takes four arguments */
+#define HAVE_FOUR_ARGUMENT_LOCKMGR 1
+
+/* define if lockstatus takes two arguments */
+/* #undef HAVE_TWO_ARGUMENT_LOCKSTATUS */
+
+/* define if lockstatus takes one argument */
+#define HAVE_ONE_ARGUMENT_LOCKSTATUS 1
+
+/* define if ubc_lookup takes six arguments */
+/* #undef HAVE_SIX_ARGUMENT_UBC_LOOKUP */
+
+/* define if DIRSIZ is defined in dirent.h */
+/* #undef DIRSIZ_IN_DIRENT_H */
+
+/* define if DIRSIZ is defined in sys/dir.h */
+#define DIRSIZ_IN_SYS_DIR_H 1
+
+/* define if DIRSIZ is defined in sys/dirent.h */
+/* #undef GENERIC_DIRSIZ_IN_SYS_DIRENT_H */
+
+/* Define if struct proc has field p_sigmask. */
+#define HAVE_STRUCT_PROC_P_SIGMASK 1
+
+/* Define if struct mount has field mnt_syncer */
+#define HAVE_STRUCT_MOUNT_MNT_SYNCER 1
+
+/* Define if struct mount has field m_info */
+/* #undef HAVE_STRUCT_MOUNT_M_INFO */
+
+/* Define if struct vfsconf has field vfc_refcount */
#define HAVE_STRUCT_VFSCONF_VFC_REFCOUNT 1
-/* Define if your struct vfsconf has a field vfc_mountroot */
+/* Define if struct vfsconf has field vfc_mountroot */
/* #undef HAVE_STRUCT_VFSCONF_VFC_MOUNTROOT */
-/* Define if your struct uio has a field uio_procp */
+/* Define if struct uio has field uio_procp */
#define HAVE_STRUCT_UIO_UIO_PROCP 1
-/* Define if your struct vfsops has a field vfs_opv_descs */
+/* Define if struct vfsops has field vfs_opv_descs */
/* #undef HAVE_STRUCT_VFSOPS_VFS_OPV_DESCS */
-/* Define if your struct vfsops has a field vfs_name */
+/* Define if struct vfsops has field vfs_name */
/* #undef HAVE_STRUCT_VFSOPS_VFS_NAME */
-/* Define if your struct vfsops has a field vfs_oid */
+/* Define if struct vfsops has field vfs_uninit */
+/* #undef HAVE_STRUCT_VFSOPS_VFS_UNINIT */
+
+/* Define if struct vfsops has field vfs_oid */
/* #undef HAVE_STRUCT_VFSOPS_VFS_OID */
-/* Define if your struct vfsops has a field vfs_checkexp */
-/* #undef HAVE_STRUCT_VFSOPS_VFS_CHECKEXP */
+/* Define if struct vfsops has field vfs_done */
+/* #undef HAVE_STRUCT_VFSOPS_VFS_DONE */
-/* Define if your struct vfsops has a field vfs_uninit */
-/* #undef HAVE_STRUCT_VFSOPS_VFS_UNINIT */
+/* Define if struct vfsops has field vfs_checkexp */
+#define HAVE_STRUCT_VFSOPS_VFS_CHECKEXP 1
-/* Define if you want to use mmap:ed time */
-/* #undef USE_MMAPTIME */
+/* Define if struct vop_fsync_args has field a_flags */
+/* #undef HAVE_STRUCT_VOP_FSYNC_ARGS_A_FLAGS */
-/* Define if your hstrerror needs const like SunOS 5.6 */
-#define NEED_HSTRERROR_CONST 1
+/* Define if struct proc has field p_retval */
+/* #undef HAVE_STRUCT_PROC_P_RETVAL */
-/* Define if your hstrerror need proto */
-/* #undef NEED_HSTRERROR_PROTO */
+/* Define if you have struct setgroups_args */
+/* #undef HAVE_DEF_STRUCT_SETGROUPS_ARGS */
-/* define if the system is missing a prototype for inet_aton() */
-/* #undef NEED_INET_ATON_PROTO */
+/* Define if you have struct sys_setgroups_args */
+#define HAVE_DEF_STRUCT_SYS_SETGROUPS_ARGS 1
-/* Define if you have gnu libc */
-/* #undef HAVE_GLIBC */
+/* Define if struct cdevsw has field d_stop */
+/* #undef HAVE_STRUCT_CDEVSW_D_STOP */
-/* Define this if `struct sockaddr' includes sa_len */
-#define SOCKADDR_HAS_SA_LEN 1
+/* Define if struct cdevsw has field d_reset */
+/* #undef HAVE_STRUCT_CDEVSW_D_RESET */
-/* Define this if htnol is broken, but can be fixed with define magic */
-/* #undef HAVE_REPAIRABLE_HTONL */
+/* Define if struct cdevsw has field d_bogoreset */
+/* #undef HAVE_STRUCT_CDEVSW_D_BOGORESET */
-/* Define this if struct ViceIoctl is defined by linux/fs.h */
-/* #undef HAVE_STRUCT_VICEIOCTL_IN */
+/* Define if struct cdevsw has field d_devtotty */
+/* #undef HAVE_STRUCT_CDEVSW_D_DEVTOTTY */
-/* Linux kernel types */
-/* #undef HAVE_LINUX_KERNEL_INT8_T */
-/* #undef HAVE_LINUX_KERNEL_INT16_T */
-/* #undef HAVE_LINUX_KERNEL_INT32_T */
-/* #undef HAVE_LINUX_KERNEL_INT64_T */
-/* #undef HAVE_LINUX_KERNEL_U_INT8_T */
-/* #undef HAVE_LINUX_KERNEL_U_INT16_T */
-/* #undef HAVE_LINUX_KERNEL_U_INT32_T */
-/* #undef HAVE_LINUX_KERNEL_U_INT64_T */
+/* Define if struct cdevsw has field d_bogoparms */
+/* #undef HAVE_STRUCT_CDEVSW_D_BOGOPARMS */
-/* Define this if you have a struct new_stat */
-/* #undef HAVE_STRUCT_NEW_STAT */
+/* Define if struct cdevsw has field d_spare */
+/* #undef HAVE_STRUCT_CDEVSW_D_SPARE */
-/* Define this if you have a type vop_t */
-/* #undef HAVE_VOP_T */
+/* Define if struct cdevsw has field d_maxio */
+/* #undef HAVE_STRUCT_CDEVSW_D_MAXIO */
-/* Define this is you have a vfssw */
-/* #undef HAVE_VFSSW */
+/* Define if struct componentname has field cn_hash */
+#define HAVE_STRUCT_COMPONENTNAME_CN_HASH 1
-/* Define this if struct mount have mnt_syncer */
-#define HAVE_STRUCT_MOUNT_MNT_SYNCER 1
+/* define if d_alloc_root takes two arguments */
+/* #undef HAVE_D_ALLOC_ROOT_TWO_ARGS */
-/* Define this if struct proc have p_sigmask */
-#define HAVE_STRUCT_PROC_P_SIGMASK 1
+/* define if devfs_register takes eleven arguments */
+/* #undef HAVE_DEVFS_REGISTER_ELEVEN_ARGS */
-/* Define this if you have struct a_flags instead of a_waitfor in vop_fseek*/
-/* #undef HAVE_STRUCT_VOP_FSYNC_ARGS_A_FLAGS */
+/* Define if struct ViceIoctl has field in */
+/* #undef HAVE_STRUCT_VICEIOCTL_IN */
-/* Define this if struct proc have p_retval */
-/* #undef HAVE_STRUCT_PROC_P_RETVAL */
+/* Define if struct super_operations has field notify_change */
+/* #undef HAVE_STRUCT_SUPER_OPERATIONS_NOTIFY_CHANGE */
-/* Define this if struct file_operations has flush */
-/* #undef HAVE_STRUCT_FILE_OPERATIONS_FLUSH */
+/* Define if struct inode_operations has field default_file_ops */
+/* #undef HAVE_STRUCT_INODE_OPERATIONS_DEFAULT_FILE_OPS */
-/* Define this if the read_super superoperation takes the dir_d argument */
-/* #undef HAVE_READ_SUPER_FOUR_ARGS */
+/* Define if struct inode_operations has field updatepage */
+/* #undef HAVE_STRUCT_INODE_OPERATIONS_UPDATEPAGE */
-/* Define this if the follow_link inode-operation takes the follow argument */
-/* #undef HAVE_FOLLOW_LINK_THREE_ARGS */
+/* Define if struct inode_operations has field bmap */
+/* #undef HAVE_STRUCT_INODE_OPERATIONS_BMAP */
-/* Define this if your full_name_hash works with 8bit characters */
-/* #undef HAVE_FULL_NAME_HASH_8BIT */
+/* Define if struct inode_operations has field smap */
+/* #undef HAVE_STRUCT_INODE_OPERATIONS_SMAP */
-/* Define if your getvfsbyname takes two arguments */
-/* #undef HAVE_GETVFSBYNAME_TWO_ARGS */
+/* define if you have a wait_queue_head_t */
+/* #undef HAVE_WAIT_QUEUE_HEAD_T */
-/* Define if you have DIRSIZ in <dirent.h> */
-/* #undef DIRSIZ_IN_DIRENT_H */
+/* define if you have a init_waitqueue_head */
+/* #undef HAVE_INIT_WAITQUEUE_HEAD */
-/* Define if you have DIRSIZ in <sys/dir.h> */
-#define DIRSIZ_IN_SYS_DIR_H 1
+/* define if you have a function init_MUTEX */
+/* #undef HAVE_INIT_MUTEX */
-/* Define if you have GENERIC_DIRENT in <sys/dirent.h> */
-/* #undef GENERIC_DIRSIZ_IN_SYS_DIRENT_H */
+/* Define if struct vfsops has field vfs_freevfs */
+/* #undef HAVE_STRUCT_VFSOPS_VFS_FREEVFS */
-/* Define if running on Irix 6.4 or later */
-/* #undef IRIX_64 */
+/* define? */
+/* #undef HAVE_REPAIRABLE_HTONL */
+
+
+/* RCSID */
+#define RCSID(msg) \
+static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
+
+/* Maximum values on all known systems */
+#define MaxHostNameLen (64+4)
+#define MaxPathLen (1024+4)
+
+/* we always have stds.h */
+#define HAVE_STDS_H
/*
* Defintions that are ugly but needed to get all the symbols used
@@ -843,4 +1061,10 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
* other importatnt definitions on Solaris.
*/
+#ifndef __EXTENSIONS__
#define __EXTENSIONS__
+#endif
+
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(x)
+#endif
diff --git a/sys/xfs/xfs_deb.c b/sys/xfs/xfs_deb.c
index f6891e93154..9be92277178 100644
--- a/sys/xfs/xfs_deb.c
+++ b/sys/xfs/xfs_deb.c
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_deb.c,v 1.3 2000/03/03 00:54:58 todd Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -40,6 +39,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 $ */
/* X is on */
#define X(y) y
diff --git a/sys/xfs/xfs_deb.h b/sys/xfs/xfs_deb.h
index 88073ff9794..bfcfccd640a 100644
--- a/sys/xfs/xfs_deb.h
+++ b/sys/xfs/xfs_deb.h
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_deb.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_deb.h,v 1.5 2000/09/11 14:26:51 art Exp $ */
#ifndef _xfs_deb_h
#define _xfs_deb_h
diff --git a/sys/xfs/xfs_debug.h b/sys/xfs/xfs_debug.h
index dd008204081..3fa58ac7da3 100644
--- a/sys/xfs/xfs_debug.h
+++ b/sys/xfs/xfs_debug.h
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_debug.h,v 1.2 2000/03/03 00:54:58 todd Exp $ */
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_debug.h,v 1.3 2000/09/11 14:26:51 art 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 86af610ba85..f8922108fd4 100644
--- a/sys/xfs/xfs_dev-bsd.c
+++ b/sys/xfs/xfs_dev-bsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_dev-bsd.c,v 1.2 2000/03/03 00:54:58 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -45,7 +43,7 @@
#include <xfs/xfs_dev.h>
#include <xfs/xfs_deb.h>
-RCSID("$OpenBSD: xfs_dev-bsd.c,v 1.2 2000/03/03 00:54:58 todd Exp $");
+RCSID("$Id: xfs_dev-bsd.c,v 1.3 2000/09/11 14:26:51 art Exp $");
int
xfs_devopen(dev_t dev, int flag, int devtype, struct proc *proc)
@@ -55,17 +53,16 @@ xfs_devopen(dev_t dev, int flag, int devtype, struct proc *proc)
return xfs_devopen_common(dev);
}
-/* XXX ugly function so we can keep xfs_devopen static */
-int
-xfs_func_is_devopen(void *func)
-{
- return func == (void*)&xfs_devopen;
-}
-
int
xfs_devclose(dev_t dev, int flag, int devtype, struct proc *p)
{
- XFSDEB(XDEBDEV, ("xfs_devclose dev = %d, flag = %d\n", dev, flag));
+#ifdef XFS_DEBUG
+ char devname[64];
+#endif
+
+ XFSDEB(XDEBDEV, ("xfs_devclose dev = %s, flag = 0x%x\n",
+ xfs_devtoname_r(dev, devname, sizeof(devname)),
+ flag));
return xfs_devclose_common(dev, p);
}
@@ -75,16 +72,15 @@ xfs_devclose(dev_t dev, int flag, int devtype, struct proc *p)
int
xfs_devioctl(dev_t dev,
-#if defined(__NetBSD__) || defined(__OpenBSD__)
u_long cmd,
-#elif defined(__FreeBSD__)
- int cmd,
-#endif
- caddr_t data, int flags, struct proc *p)
+ caddr_t data,
+ int flags,
+ struct proc *p)
{
XFSDEB(XDEBDEV, ("xfs_devioctl dev = %d.%d, cmd = %lu, "
- "data = %p, flags = %x\n",
- major(dev), minor(dev), (unsigned long)cmd, data, flags));
+ "data = %lx, flags = %x\n",
+ major(dev), minor(dev), (unsigned long)cmd,
+ (unsigned long)data, flags));
return ENOTTY;
}
@@ -105,7 +101,11 @@ xfs_realselect(dev_t dev, struct proc *p)
static int
xfs_devpoll(dev_t dev, int events, struct proc * p)
{
- XFSDEB(XDEBDEV, ("xfs_devpoll dev = %d, events = %d\n", dev, events));
+ char devname[64];
+
+ XFSDEB(XDEBDEV, ("xfs_devpoll dev = %s, events = 0x%x\n",
+ xfs_devtoname_r (dev, devname, sizeof(devname)),
+ events));
if (!(events & POLLRDNORM))
return 0;
@@ -174,9 +174,16 @@ struct cdevsw xfs_dev = {
xfs_devread,
xfs_devwrite,
xfs_devioctl,
+#ifdef HAVE_STRUCT_CDEVSW_D_STOP
nostop,
+#endif
+#if defined(HAVE_STRUCT_CDEVSW_D_BOGORESET) \
+ || defined(HAVE_STRUCT_CDEVSW_D_RESET)
noreset,
+#endif
+#ifdef HAVE_STRUCT_CDEVSW_D_DEVTOTTY
nodevtotty,
+#endif
#if defined(HAVE_VOP_SELECT)
xfs_devselect,
#elif defined(HAVE_VOP_POLL)
@@ -186,23 +193,82 @@ struct cdevsw xfs_dev = {
#endif
nommap,
nostrategy,
- NULL,
- 0
+ "xfs",
+#ifdef HAVE_STRUCT_CDEVSW_D_BOGOPARMS
+ noparms, /* d_bogoparms */
+#endif
+#ifdef HAVE_STRUCT_CDEVSW_D_SPARE
+ NULL, /* d_spare */
+#endif
+ 128, /* XXX */
+ nodump,
+ nopsize,
+ 0, /* flags */
+#ifdef HAVE_STRUCT_CDEVSW_D_MAXIO
+ 0, /* maxio */
+#endif
+#ifdef NOUDEV
+ NOUDEV /* bmaj */
+#else
+ NODEV /* bmaj */
+#endif
};
-#endif /* FreeBSD */
+#elif defined(__APPLE__)
+static struct cdevsw xfs_dev = {
+ xfs_devopen,
+ xfs_devclose,
+ xfs_devread,
+ xfs_devwrite,
+ xfs_devioctl,
+ eno_stop,
+ eno_reset,
+ 0,
+ xfs_devselect,
+ eno_mmap,
+ eno_strat,
+ eno_getc,
+ eno_putc,
+ 0
+};
+#endif /* __APPLE__ */
+
+#if defined(__APPLE__)
+extern int xfs_dev_major;
+#include <miscfs/devfs/devfs.h>
+
+static void *devfs_handles[NXFS];
+
+#endif
int
xfs_install_device(void)
{
int i;
+#if defined(__APPLE__)
+ xfs_dev_major = cdevsw_add(-1, &xfs_dev);
+ if (xfs_dev_major == -1) {
+ XFSDEB(XDEBDEV, ("failed installing cdev\n"));
+ return ENFILE;
+ }
+
+ for (i = 0; i < NXFS; ++i)
+ devfs_handles[i] = devfs_make_node(makedev(xfs_dev_major, i),
+ DEVFS_CHAR,
+ UID_ROOT, GID_WHEEL, 0600,
+ "xfs%d", i);
+
+ XFSDEB(XDEBDEV, ("done installing cdev !\n"));
+ XFSDEB(XDEBDEV, ("Char device number %d\n", xfs_dev_major));
+#endif
+
for (i = 0; i < NXFS; i++) {
XFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n"));
xfs_initq(&xfs_channel[i].messageq);
xfs_initq(&xfs_channel[i].sleepq);
+ xfs_channel[i].status = 0;
}
-
return 0;
}
@@ -211,6 +277,7 @@ xfs_uninstall_device(void)
{
int i;
struct xfs_channel *chan;
+ int ret = 0;
for (i = 0; i < NXFS; i++) {
chan = &xfs_channel[i];
@@ -218,7 +285,22 @@ xfs_uninstall_device(void)
xfs_devclose(makedev(0, i), 0, 0, NULL);
}
- return 0;
+#if defined(__APPLE__)
+ for (i = 0; i < NXFS; ++i)
+ devfs_remove (devfs_handles[i]);
+
+ ret = cdevsw_remove(xfs_dev_major, &xfs_dev);
+ if (ret == -1) {
+ XFSDEB(XDEBLKM, ("xfs_uninstall_device error %d\n", ret));
+ } else if (ret == xfs_dev_major) {
+ ret = 0;
+ } else {
+ XFSDEB(XDEBLKM, ("xfs_uninstall_device unexpected error error %d\n",
+ ret));
+ }
+#endif
+ XFSDEB(XDEBLKM, ("xfs_uninstall_device error %d\n", ret));
+ return ret;
}
int
@@ -226,3 +308,13 @@ xfs_stat_device(void)
{
return xfs_uprintf_device();
}
+
+#if !defined(_LKM) && !defined(KLD_MODULE)
+int
+xfs_is_xfs_dev(dev_t dev)
+{
+ return major(dev) <= nchrdev &&
+ cdevsw[major(dev)].d_open == xfs_devopen &&
+ minor(dev) >= 0 && minor(dev) < NXFS;
+}
+#endif
diff --git a/sys/xfs/xfs_dev-common.c b/sys/xfs/xfs_dev-common.c
index d9e5af3fcd6..ecbc3f1902e 100644
--- a/sys/xfs/xfs_dev-common.c
+++ b/sys/xfs/xfs_dev-common.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_dev-common.c,v 1.2 2000/03/03 00:54:58 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -46,7 +44,7 @@
#include <xfs/xfs_dev.h>
#include <xfs/xfs_deb.h>
-RCSID("$OpenBSD: xfs_dev-common.c,v 1.2 2000/03/03 00:54:58 todd Exp $");
+RCSID("$Id: xfs_dev-common.c,v 1.3 2000/09/11 14:26:51 art Exp $");
struct xfs_channel xfs_channel[NXFS];
@@ -59,14 +57,14 @@ xfs_initq(struct xfs_link *q)
/* Is this queue empty? */
int
-xfs_emptyq(struct xfs_link *q)
+xfs_emptyq(const struct xfs_link *q)
{
return q->next == q;
}
/* Is this link on any queue? Link *must* be inited! */
int
-xfs_onq(struct xfs_link *link)
+xfs_onq(const struct xfs_link *link)
{
return link->next != NULL || link->prev != NULL;
}
@@ -81,12 +79,13 @@ xfs_appendq(struct xfs_link *q, struct xfs_link *p)
q->prev = p;
}
+/* remove `p' from its queue */
void
xfs_outq(struct xfs_link *p)
{
p->next->prev = p->prev;
p->prev->next = p->next;
- p->next = p->prev = 0;
+ p->next = p->prev = NULL;
}
/*
@@ -194,20 +193,45 @@ xfs_devclose_common(dev_t dev, struct proc *proc)
return 0;
}
+#ifdef XFS_DEBUG
+/*
+ * osf glue for CURSIG
+ */
+
+static long
+xfs_cursig (struct proc *p)
+{
+#ifdef __osf__
+ thread_t th = current_thread();
+ struct np_uthread *npu = thread_to_np_uthread(th);
+ return CURSIG(p,npu);
+#else
+ return CURSIG(p);
+#endif
+}
+#endif
+
/*
* Move messages from kernel to user space.
*/
+
int
xfs_devread(dev_t dev, struct uio * uiop, int ioflag)
{
struct xfs_channel *chan = &xfs_channel[minor(dev)];
struct xfs_link *first;
int error = 0;
+#ifdef XFS_DEBUG
+ char devname[64];
+#endif
- XFSDEB(XDEBDEV, ("xfs_devread dev = %d\n", dev));
+ XFSDEB(XDEBDEV, ("xfs_devread dev = %s\n",
+ xfs_devtoname_r(dev, devname, sizeof(devname))));
- XFSDEB(XDEBDEV, ("xfs_devread: m = %p, m->prev = %p, m->next = %p\n",
- &chan->messageq, chan->messageq.prev, chan->messageq.next));
+ XFSDEB(XDEBDEV, ("xfs_devread: m = %lx, m->prev = %lx, m->next = %lx\n",
+ (unsigned long)&chan->messageq,
+ (unsigned long)chan->messageq.prev,
+ (unsigned long)chan->messageq.next));
again:
@@ -215,13 +239,18 @@ xfs_devread(dev_t dev, struct uio * uiop, int ioflag)
while (!xfs_emptyq (&chan->messageq)) {
/* Remove message */
first = chan->messageq.next;
- XFSDEB(XDEBDEV, ("xfs_devread: first = %p, "
- "first->prev = %p, first->next = %p\n",
- first, first->prev, first->next));
+ XFSDEB(XDEBDEV, ("xfs_devread: first = %lx, "
+ "first->prev = %lx, first->next = %lx\n",
+ (unsigned long)first,
+ (unsigned long)first->prev,
+ (unsigned long)first->next));
XFSDEB(XDEBDEV, ("xfs_devread: message->size = %u\n",
first->message->size));
+ if (first->message->size > uiop->uio_resid)
+ break;
+
error = uiomove((caddr_t) first->message, first->message->size,
uiop);
if (error)
@@ -234,8 +263,10 @@ xfs_devread(dev_t dev, struct uio * uiop, int ioflag)
}
} else {
chan->status |= CHANNEL_WAITING;
- if (tsleep((caddr_t) chan, (PZERO + 1) | PCATCH, "xfsr", 0)) {
- XFSDEB(XDEBMSG, ("caught signal xfs_devread\n"));
+ if (tsleep((caddr_t) chan, (PZERO + 1) | PCATCH, "xfsread", 0)) {
+ XFSDEB(XDEBMSG,
+ ("caught signal xfs_devread: %ld\n",
+ xfs_cursig(xfs_uio_to_proc(uiop))));
error = EINTR;
} else if ((chan->status & CHANNEL_WAITING) == 0) {
goto again;
@@ -243,7 +274,6 @@ xfs_devread(dev_t dev, struct uio * uiop, int ioflag)
error = EIO;
}
-
XFSDEB(XDEBDEV, ("xfs_devread done error = %d\n", error));
return error;
@@ -261,8 +291,12 @@ xfs_devwrite(dev_t dev, struct uio *uiop, int ioflag)
int error;
u_int cnt;
struct xfs_message_header *msg_buf;
+#ifdef XFS_DEBUG
+ char devname[64];
+#endif
- XFSDEB(XDEBDEV, ("xfs_devwrite dev = %d\n", dev));
+ XFSDEB(XDEBDEV, ("xfs_devwrite dev = %s\n",
+ xfs_devtoname_r (dev, devname, sizeof(devname))));
cnt = uiop->uio_resid;
error = uiomove((caddr_t) chan->message_buffer, MAX_XMSG_SIZE, uiop);
@@ -325,9 +359,18 @@ xfs_message_send(int fd, struct xfs_message_header * message, u_int size)
return 0;
}
+#if defined(SWEXIT)
+#define XFS_P_EXIT SWEXIT
+#elif defined(P_WEXIT)
+#define XFS_P_EXIT P_WEXIT
+#else
+#error what is your exit named ?
+#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)
{
@@ -339,6 +382,8 @@ xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size)
#if defined(HAVE_STRUCT_PROC_P_SIGMASK)
sigset_t oldsigmask;
#endif /* HAVE_STRUCT_PROC_P_SIGMASK */
+ int catch;
+ struct proc *proc = xfs_curproc ();
XFSDEB(XDEBMSG, ("xfs_message_rpc opcode = %d\n", message->opcode));
@@ -375,31 +420,57 @@ xfs_message_rpc(int fd, struct xfs_message_header * message, u_int size)
*/
#ifdef HAVE_STRUCT_PROC_P_SIGMASK
- oldsigmask = xfs_curproc()->p_sigmask;
-#ifdef __sigaddset
- __sigaddset(&xfs_curproc()->p_sigmask, SIGIO);
+ 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
- xfs_curproc()->p_sigmask |= sigmask(SIGIO);
+ proc->p_sigmask |= sigmask(SIGIO);
+ proc->p_sigmask |= sigmask(SIGALRM);
+ proc->p_sigmask |= sigmask(SIGVTALRM);
#endif /* __sigaddset */
#elif defined(HAVE_STRUCT_PROC_P_SIGWAITMASK)
- oldsigmask = xfs_curproc()->p_sigwaitmask;
- sigaddset(&xfs_curproc()->p_sigwaitmask, SIGIO);
+ oldsigmask = proc->p_sigwaitmask;
+ sigaddset(&proc->p_sigwaitmask, SIGIO);
+ sigaddset(&proc->p_sigwaitmask, SIGALRM);
+ sigaddset(&proc->p_sigwaitmask, SIGVTALRM);
#endif
+
+ /*
+ * if we are exiting we should not try to catch signals, since
+ * there might not be enough context left in the process to handle
+ * signal delivery, and besides, most BSD-variants ignore all
+ * signals while closing anyway.
+ */
+
+ catch = 0;
+ if (!(proc->p_flag & XFS_P_EXIT))
+ catch |= PCATCH;
+
/*
* We have to check if we have a receiver here too because the
* daemon could have terminated before we sleep. This seems to
- * happen sometimes when rebooting.
- */
- if (!(chan->status & CHANNEL_OPENED) ||
- tsleep((caddr_t) this_process, (PZERO + 1) | PCATCH, "xfs", 0)) {
- XFSDEB(XDEBMSG, ("caught signal\n"));
+ * happen sometimes when rebooting. */
+
+ if (!(chan->status & CHANNEL_OPENED)) {
+ XFSDEB(XDEBMSG, ("xfs_message_rpc: channel went away\n"));
+ this_process->error_or_size = EINTR;
+ } else if ((ret = tsleep((caddr_t) this_process,
+ (PZERO + 1) | catch, "xfs", 0)) != 0) {
+ XFSDEB(XDEBMSG, ("caught signal (%d): %ld\n",
+ ret, xfs_cursig(proc)));
this_process->error_or_size = EINTR;
}
#ifdef HAVE_STRUCT_PROC_P_SIGMASK
- xfs_curproc()->p_sigmask = oldsigmask;
+ proc->p_sigmask = oldsigmask;
#elif defined(HAVE_STRUCT_PROC_P_SIGWAITMASK)
- xfs_curproc()->p_sigwaitmask = oldsigmask;
+ proc->p_sigwaitmask = oldsigmask;
#endif
/*
@@ -482,6 +553,16 @@ xfs_message_receive(int fd,
(struct xfs_message_updatefid *)message,
message->size,
p);
+ case XFS_MSG_GC_NODES:
+ return xfs_message_gc_nodes(fd,
+ (struct xfs_message_gc_nodes *)message,
+ message->size,
+ p);
+ case XFS_MSG_VERSION:
+ return xfs_message_version(fd,
+ (struct xfs_message_version *)message,
+ message->size,
+ p);
default:
printf("XFS PANIC Warning xfs_dev: Unknown message opcode == %d\n",
message->opcode);
@@ -552,10 +633,10 @@ xfs_uprintf_device(void)
for (i = 0; i < NXFS; i++) {
uprintf("xfs_channel[%d] = {\n", i);
- uprintf("messageq.next = %p ", xfs_channel[i].messageq.next);
- uprintf("messageq.prev = %p ", xfs_channel[i].messageq.prev);
- uprintf("sleepq.next = %p ", xfs_channel[i].sleepq.next);
- uprintf("sleepq.prev = %p ", xfs_channel[i].sleepq.prev);
+ uprintf("messageq.next = %lx ", xfs_channel[i].messageq.next);
+ uprintf("messageq.prev = %lx ", xfs_channel[i].messageq.prev);
+ uprintf("sleepq.next = %lx ", xfs_channel[i].sleepq.next);
+ uprintf("sleepq.prev = %lx ", xfs_channel[i].sleepq.prev);
uprintf("nsequence = %d status = %d\n",
xfs_channel[i].nsequence,
xfs_channel[i].status);
diff --git a/sys/xfs/xfs_dev.h b/sys/xfs/xfs_dev.h
index 89a1b38ed98..6b7ef481fe8 100644
--- a/sys/xfs/xfs_dev.h
+++ b/sys/xfs/xfs_dev.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_dev.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_dev.h,v 1.5 2000/09/11 14:26:52 art Exp $ */
#ifndef _xfs_dev_h
#define _xfs_dev_h
@@ -76,7 +76,6 @@ extern struct xfs_channel xfs_channel[NXFS];
* These are variant dependent
*/
-int xfs_func_is_devopen(void*);
void xfs_select_wakeup(struct xfs_channel *);
int xfs_install_device(void);
@@ -97,10 +96,10 @@ void
xfs_initq(struct xfs_link *q);
int
-xfs_emptyq(struct xfs_link *q);
+xfs_emptyq(const struct xfs_link *q);
int
-xfs_onq(struct xfs_link *link);
+xfs_onq(const struct xfs_link *link);
void
xfs_appendq(struct xfs_link *q, struct xfs_link *p);
@@ -114,13 +113,8 @@ xfs_devopen_common(dev_t dev);
#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,
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- u_long cmd,
-#else /* if defined(__FreeBSD__) */
- int cmd,
-#endif
- caddr_t data, int flags, struct proc *p);
+int xfs_devioctl(dev_t dev, u_long cmd, caddr_t data, int flags,
+ struct proc *p);
int xfs_devselect(dev_t dev, int which, struct proc *p);
#endif /* ! __osf__ */
@@ -160,4 +154,7 @@ xfs_message_wakeup_data(int fd,
int
xfs_uprintf_device(void);
+int
+xfs_is_xfs_dev (dev_t dev);
+
#endif /* _xfs_dev_h */
diff --git a/sys/xfs/xfs_fs.h b/sys/xfs/xfs_fs.h
index 06bc2dd42b4..3ccfe00fa5d 100644
--- a/sys/xfs/xfs_fs.h
+++ b/sys/xfs/xfs_fs.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_fs.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_fs.h,v 1.5 2000/09/11 14:26:52 art Exp $ */
#ifndef _xfs_h
#define _xfs_h
@@ -62,7 +62,11 @@ struct xfs {
};
#ifdef __osf__
+#ifdef HAVE_STRUCT_MOUNT_M_INFO
+#define VFS_TO_XFS(v) ((struct xfs *) ((v)->m_info))
+#else
#define VFS_TO_XFS(v) ((struct xfs *) ((v)->m_data))
+#endif
#else
#define VFS_TO_XFS(v) ((struct xfs *) ((v)->mnt_data))
#endif
@@ -88,18 +92,9 @@ void xfs_dnlc_purge(struct vnode *);
int xfs_dnlc_lookup(struct vnode *, xfs_componentname *, struct vnode **);
int xfs_dnlc_lookup_name(struct vnode *, const char *, struct vnode **);
-void
-xfs_cnp_init (xfs_componentname *ndp,
- const char *name,
- struct vnode *vp,
- struct vnode *dvp,
- struct proc *proc,
- struct ucred *cred,
- int nameiop);
-
void vattr2xfs_attr(const struct vattr *, struct xfs_attr *);
void xfs_attr2vattr(const struct xfs_attr *, struct vattr *);
-int xfs_has_pag(const struct xfs_node *, pag_t);
+int xfs_has_pag(const struct xfs_node *, xfs_pag_t);
#endif /* _xfs_h */
diff --git a/sys/xfs/xfs_locl.h b/sys/xfs/xfs_locl.h
index bf23a6577ff..d33b4ab64ad 100644
--- a/sys/xfs/xfs_locl.h
+++ b/sys/xfs/xfs_locl.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_locl.h,v 1.2 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,8 +36,11 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_locl.h,v 1.3 2000/09/11 14:26:52 art Exp $ */
-#if 1 /* XXX - ugly hack */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
#include <xfs/xfs_config.h>
#endif
@@ -69,6 +71,7 @@
#include <vm/vm_ubc.h>
typedef short int16_t;
+typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
@@ -108,15 +111,26 @@ 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_curproc() (u.u_procp)
-#else /* __osf__ */
+#define xfs_vop_read VOP_READ
+#define xfs_vop_write VOP_WRITE
+#define xfs_vop_getattr(t, attr, cred, proc, error) VOP_GETATTR((t), (attr), (cred), (error))
+#define xfs_vop_access(dvp, mode, cred, proc, error) VOP_ACCESS((dvp), (mode), (cred), (error))
+
+struct vop_generic_args;
+
+#else /* !__osf__ */
typedef struct componentname xfs_componentname;
#include <sys/types.h>
#include <sys/param.h>
+#if 0
+#include <sys/ioctl.h>
+#endif
#include <sys/proc.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
@@ -134,7 +148,9 @@ typedef struct componentname xfs_componentname;
#ifdef HAVE_SYS_SYSENT_H
#include <sys/sysent.h>
#endif
+#ifdef HAVE_SYS_LKM_H
#include <sys/lkm.h>
+#endif
#include <sys/errno.h>
#include <sys/file.h>
#include <sys/namei.h>
@@ -145,9 +161,19 @@ typedef struct componentname xfs_componentname;
#ifdef HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
+#ifdef HAVE_SYS_SIGNALVAR_H
+#include <sys/signalvar.h>
+#endif
#include <sys/syscall.h>
#include <sys/queue.h>
#include <sys/malloc.h>
+#ifdef HAVE_SYS_SYSCALLARGS_H
+#include <sys/syscallargs.h>
+#endif
+#ifdef HAVE_SYS_ATTR_H
+#include <sys/attr.h>
+#endif
+
#ifdef HAVE_MISCFS_GENFS_GENFS_H
#include <miscfs/genfs/genfs.h>
#endif
@@ -160,14 +186,97 @@ typedef struct componentname xfs_componentname;
#ifdef HAVE_VM_VM_ZONE_H
#include <vm/vm_zone.h>
#endif
+#ifdef HAVE_VM_VM_OBJECT_H
+#include <vm/vm_object.h>
+#endif
+#ifdef HAVE_UVM_UVM_EXTERN_H
+#include <uvm/uvm_extern.h>
+#endif
+
+#if defined(__APPLE__)
+#include <machine/machine_routines.h>
+#include <mach/machine/vm_types.h>
+void cache_purge(struct vnode *);
+int cache_lookup(struct vnode *, struct vnode **, struct componentname *);
+void cache_enter(struct vnode *, struct vnode *, struct componentname *);
+void cache_purgevfs(struct mount *);
+#endif
#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)
+#ifdef __APPLE__
+#define xfs_curproc() (current_proc())
+#else
#define xfs_curproc() (curproc)
+#endif
+
+#define xfs_vop_read(t, uio, ioflag, cred, error) (error) = VOP_READ((t), (uio), (ioflag), (cred))
+#define xfs_vop_write(t, uio, ioflag, cred, error) (error) = VOP_WRITE((t), (uio), (ioflag), (cred))
+#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))
+
+#endif /* !__osf__ */
+
+/*
+ * XXX
+ */
+
+#ifndef SCARG
+#define SCARG(a, b) ((a)->b.datum)
+#define syscallarg(x) union { x datum; register_t pad; }
+#endif
+
+#ifndef syscallarg
+#define syscallarg(x) x
+#endif
+
+#ifndef HAVE_REGISTER_T
+typedef int register_t;
+#endif
+
+#if defined(HAVE_DEF_STRUCT_SETGROUPS_ARGS)
+#define xfs_setgroups_args setgroups_args
+#elif defined(HAVE_DEF_STRUCT_SYS_SETGROUPS_ARGS)
+#define xfs_setgroups_args sys_setgroups_args
+#elif __osf__
+struct xfs_setgroups_args {
+ syscallarg(int) gidsetsize;
+ syscallarg(gid_t) *gidset;
+};
+#elif defined(__APPLE__)
+struct xfs_setgroups_args{
+ syscallarg(u_int) gidsetsize;
+ syscallarg(gid_t) *gidset;
+};
+#else
+#error what is you setgroups named ?
+#endif
+
+
+#ifdef HAVE_KERNEL_VFS_GETVFS
+#define xfs_vfs_getvfs vfs_getvfs
+#else
+#define xfs_vfs_getvfs getvfs
+#endif
+
+#ifdef HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE
+#define xfs_vfs_object_create(vp,proc,ucred) vfs_object_create(vp,proc,ucred,TRUE)
+#else
+#define xfs_vfs_object_create(vp,proc,ucred) vfs_object_create(vp,proc,ucred)
+#endif
+
+#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)
+#else
+#define xfs_set_vp_size(vp, sz)
+#endif
-#endif /* __osf__ */
+#include <xfs/xfs_syscalls.h>
/*
* The VOP table
diff --git a/sys/xfs/xfs_message.c b/sys/xfs/xfs_message.c
index 7e64ab6576a..de1dd1c7810 100644
--- a/sys/xfs/xfs_message.c
+++ b/sys/xfs/xfs_message.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_message.c,v 1.6 2000/03/03 00:54:58 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -46,8 +44,9 @@
#include <xfs/xfs_syscalls.h>
#include <xfs/xfs_vfsops.h>
#include <xfs/xfs_vnodeops.h>
+#include <xfs/xfs_dev.h>
-RCSID("$OpenBSD: xfs_message.c,v 1.6 2000/03/03 00:54:58 todd Exp $");
+RCSID("$Id: xfs_message.c,v 1.7 2000/09/11 14:26:52 art Exp $");
int
xfs_message_installroot(int fd,
@@ -57,7 +56,11 @@ xfs_message_installroot(int fd,
{
int error = 0;
- XFSDEB(XDEBMSG, ("xfs_message_installroot\n"));
+ XFSDEB(XDEBMSG, ("xfs_message_installroot (%d,%d,%d,%d)\n",
+ message->node.handle.a,
+ message->node.handle.b,
+ message->node.handle.c,
+ message->node.handle.d));
if (xfs[fd].root != NULL) {
printf("XFS PANIC WARNING! xfs_message_installroot: called again!\n");
@@ -80,13 +83,19 @@ xfs_message_installnode(int fd,
int error = 0;
struct xfs_node *n, *dp;
- XFSDEB(XDEBMSG, ("xfs_message_installnode\n"));
+ XFSDEB(XDEBMSG, ("xfs_message_installnode (%d,%d,%d,%d)\n",
+ message->node.handle.a,
+ message->node.handle.b,
+ message->node.handle.c,
+ message->node.handle.d));
+retry:
dp = xfs_node_find(&xfs[fd], &message->parent_handle);
if (dp) {
struct vnode *t_vnode = XNODE_TO_VNODE(dp);
- xfs_do_vget (t_vnode, LK_INTERLOCK|LK_SHARED, p);
+ if (xfs_do_vget(t_vnode, 0 /* LK_SHARED */, p))
+ goto retry;
error = new_xfs_node(&xfs[fd], &message->node, &n, p);
if (error) {
@@ -97,8 +106,8 @@ xfs_message_installnode(int fd,
xfs_dnlc_enter_name(t_vnode,
message->name,
XNODE_TO_VNODE(n));
- vrele(XNODE_TO_VNODE(n));
- vput (t_vnode);
+ vrele (XNODE_TO_VNODE(n));
+ vrele (t_vnode);
} else {
printf("XFS PANIC WARNING! xfs_message_installnode: no parent\n");
error = ENOENT;
@@ -117,23 +126,26 @@ xfs_message_installattr(int fd,
int error = 0;
struct xfs_node *t;
+ XFSDEB(XDEBMSG, ("xfs_message_installattr (%d,%d,%d,%d) \n",
+ message->node.handle.a,
+ message->node.handle.b,
+ message->node.handle.c,
+ message->node.handle.d));
+
t = xfs_node_find(&xfs[fd], &message->node.handle);
if (t != 0) {
t->tokens = message->node.tokens;
+ if ((t->tokens & XFS_DATA_MASK) && DATA_FROM_XNODE(t) == NULL) {
+ printf ("xfs_message_installattr: tokens and no data\n");
+ t->tokens &= ~XFS_DATA_MASK;
+ }
xfs_attr2vattr(&message->node.attr, &t->attr);
-#ifdef UVM
- uvm_vnp_setsize(XNODE_TO_VNODE(t), t->attr.va_size);
-#else
-#ifdef HAVE_KERNEL_VNODE_PAGER_SETSIZE
- vnode_pager_setsize(XNODE_TO_VNODE(t), t->attr.va_size);
-#endif
-#endif
+ 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));
t->anonrights = message->node.anonrights;
} else {
- printf("XFS PANIC WARNING! xfs_message_installattr: no node!\n");
- error = ENOENT;
+ XFSDEB(XDEBMSG, ("xfs_message_installattr: no such node\n"));
}
return error;
@@ -148,28 +160,25 @@ xfs_message_installdata(int fd,
struct xfs_node *t;
int error = 0;
- XFSDEB(XDEBMSG, ("xfs_message_installdata\n"));
+ XFSDEB(XDEBMSG, ("xfs_message_installdata (%d,%d,%d,%d)\n",
+ message->node.handle.a,
+ message->node.handle.b,
+ message->node.handle.c,
+ message->node.handle.d));
+retry:
t = xfs_node_find(&xfs[fd], &message->node.handle);
-
if (t != NULL) {
- struct xfs_fh_args *fh_args = (struct xfs_fh_args *)&message->cache_handle;
+ struct xfs_fhandle_t *fh = (struct xfs_fhandle_t *)&message->cache_handle;
struct vnode *vp;
struct vnode *t_vnode = XNODE_TO_VNODE(t);
XFSDEB(XDEBMSG, ("cache_name = '%s'\n", message->cache_name));
- XFSDEB(XDEBMSG, ("fileno = %ld, gen = %ld\n",
- SCARG(fh_args, fileid),
- SCARG(fh_args, gen)));
-
- xfs_do_vget (t_vnode, LK_INTERLOCK|LK_SHARED, p);
- error = xfs_fhlookup (p,
- SCARG(fh_args,fsid),
- SCARG(fh_args,fileid),
- SCARG(fh_args,gen),
- &vp);
+ if (xfs_do_vget(t_vnode, 0 /* LK_SHARED */, p))
+ goto retry;
+ error = xfs_fhlookup (p, fh, &vp);
if (error != 0) {
#ifdef __osf__
struct nameidata *ndp = &u.u_nd;
@@ -189,36 +198,36 @@ xfs_message_installdata(int fd,
}
if (error == 0) {
+#ifndef __osf__
xfs_vfs_unlock(vp, p);
+#endif
if (DATA_FROM_XNODE(t))
vrele(DATA_FROM_XNODE(t));
DATA_FROM_XNODE(t) = vp;
- XFSDEB(XDEBMSG, ("xfs_message_installdata: t = %p;"
+ XFSDEB(XDEBMSG, ("xfs_message_installdata: t = %lx;"
" tokens = %x\n",
- t, message->node.tokens));
+ (unsigned long)t, message->node.tokens));
t->tokens = message->node.tokens;
xfs_attr2vattr(&message->node.attr, &t->attr);
-#ifdef UVM
- uvm_vnp_setsize(XNODE_TO_VNODE(t), t->attr.va_size);
-#else
-#ifdef HAVE_KERNEL_VNODE_PAGER_SETSIZE
- vnode_pager_setsize(XNODE_TO_VNODE(t), t->attr.va_size);
-#endif
-#endif
+ xfs_set_vp_size(XNODE_TO_VNODE(t), t->attr.va_size);
if (XNODE_TO_VNODE(t)->v_type == VDIR
- && (message->flag & XFS_INVALID_DNLC))
+ && (message->flag & XFS_ID_INVALID_DNLC))
cache_purge (XNODE_TO_VNODE(t));
bcopy(message->node.id, t->id, sizeof(t->id));
bcopy(message->node.rights, t->rights, sizeof(t->rights));
t->anonrights = message->node.anonrights;
+#if 0
+ if (message->flag & XFS_ID_AFSDIR)
+ t->flags |= XFS_AFSDIR;
+#endif
} else {
printf("XFS PANIC WARNING! xfs_message_installdata failed!\n");
printf("Reason: lookup failed on cache file '%s', error = %d\n",
message->cache_name, error);
}
- vput (t_vnode);
+ vrele (t_vnode);
} else {
printf("XFS PANIC WARNING! xfs_message_installdata failed\n");
printf("Reason: No node to install the data into!\n");
@@ -228,6 +237,12 @@ xfs_message_installdata(int fd,
return error;
}
+#ifdef __osf__
+#define xfs_writecount v_wrcnt
+#else
+#define xfs_writecount v_writecount
+#endif
+
int
xfs_message_invalidnode(int fd,
struct xfs_message_invalidnode * message,
@@ -237,11 +252,35 @@ xfs_message_invalidnode(int fd,
int error = 0;
struct xfs_node *t;
- XFSDEB(XDEBMSG, ("xfs_message_invalidnode\n"));
+ XFSDEB(XDEBMSG, ("xfs_message_invalidnode (%d,%d,%d,%d)\n",
+ message->handle.a,
+ message->handle.b,
+ message->handle.c,
+ message->handle.d));
t = xfs_node_find(&xfs[fd], &message->handle);
if (t != 0) {
- /* XXX Really need to put back dirty data first. */
+ struct vnode *vp = XNODE_TO_VNODE(t);
+
+ /* If open for writing, return immediately. Last close:er wins! */
+ if (vp->v_usecount >= 0 && vp->xfs_writecount >= 1)
+ return 0;
+
+#ifdef __FreeBSD__
+ {
+ vm_object_t obj = vp->v_object;
+
+ if (obj != NULL
+ && (obj->ref_count != 0
+#ifdef OBJ_MIGHTBEDIRTY
+ || (obj->flags & OBJ_MIGHTBEDIRTY) != 0
+#endif
+ ))
+ return 0;
+
+ }
+#endif /* __FreeBSD__ */
+
if (DATA_FROM_XNODE(t)) {
vrele(DATA_FROM_XNODE(t));
DATA_FROM_XNODE(t) = (struct vnode *) 0;
@@ -249,9 +288,17 @@ xfs_message_invalidnode(int fd,
XFS_TOKEN_CLEAR(t, ~0,
XFS_OPEN_MASK | XFS_ATTR_MASK |
XFS_DATA_MASK | XFS_LOCK_MASK);
- cache_purge(XNODE_TO_VNODE(t));
+ /* Dir changed, must invalidate DNLC. */
+ if (vp->v_type == VDIR)
+ xfs_dnlc_purge(vp);
+ if (vp->v_usecount == 0) {
+ XFSDEB(XDEBVNOPS, ("xfs_message_invalidnode: vrecycle\n"));
+ vrecycle(vp, 0, p);
+ }
} else {
+#if 0
printf("XFS PANIC WARNING! xfs_message_invalidnode: no node!\n");
+#endif
error = ENOENT;
}
@@ -267,7 +314,12 @@ xfs_message_updatefid(int fd,
int error = 0;
struct xfs_node *t;
- XFSDEB(XDEBMSG, ("xfs_message_updatefid\n"));
+ XFSDEB(XDEBMSG, ("xfs_message_updatefid (%d,%d,%d,%d)\n",
+ message->old_handle.a,
+ message->old_handle.b,
+ message->old_handle.c,
+ message->old_handle.d));
+
t = xfs_node_find (&xfs[fd], &message->old_handle);
if (t != NULL) {
t->handle = message->new_handle;
@@ -277,3 +329,180 @@ xfs_message_updatefid(int fd,
}
return error;
}
+
+#if __osf__
+
+/*
+ * Try to clean out nodes for the userland daemon
+ */
+
+static void
+gc_vnode (struct vnode *vp,
+ struct proc *p)
+{
+ /* This node is on the freelist */
+ if (vp->v_usecount <= 0) {
+
+ /* DIAGNOSTIC */
+ if (vp->v_usecount < 0) {
+ vprint("vrele: bad ref count", vp);
+ panic("vrele: ref cnt");
+ }
+
+ XFSDEB(XDEBMSG, ("xfs_message_gc: success\n"));
+
+ vgone(vp, VX_NOSLEEP, NULL);
+ } else {
+ XFSDEB(XDEBMSG, ("xfs_message_gc: used\n"));
+ }
+
+}
+
+int
+xfs_message_gc_nodes(int fd,
+ struct xfs_message_gc_nodes *message,
+ u_int size,
+ struct proc *p)
+{
+ XFSDEB(XDEBMSG, ("xfs_message_gc\n"));
+
+ if (message->len == 0) {
+ struct vnode *vp;
+
+ /* XXX see comment in xfs_node_find */
+
+ for(vp = XFS_TO_VFS(&xfs[fd])->m_mounth;
+ vp != NULL;
+ vp = vp->v_mountf) {
+ gc_vnode (vp, p);
+ }
+
+ } else {
+ struct xfs_node *t;
+ int i;
+
+ for (i = 0; i < message->len; i++) {
+ t = xfs_node_find (&xfs[fd], &message->handle[i]);
+ if (t == NULL)
+ continue;
+
+ gc_vnode(XNODE_TO_VNODE(t), p);
+ }
+ }
+
+ return 0;
+}
+
+#else /* !__osf__ */
+
+/*
+ * Try to clean out nodes for the userland daemon
+ */
+
+static void
+gc_vnode (struct vnode *vp,
+ struct proc *p)
+{
+ simple_lock(&vp->v_interlock);
+
+ /* This node is on the freelist */
+ if (vp->v_usecount <= 0) {
+#if __FreeBSD__
+ vm_object_t obj;
+
+ obj = vp->v_object;
+
+ if (obj != NULL
+ && (obj->ref_count != 0
+#ifdef OBJ_MIGHTBEDIRTY
+ || (obj->flags & OBJ_MIGHTBEDIRTY) != 0
+#endif
+ )) {
+ simple_unlock (&vp->v_interlock);
+ return;
+ }
+#endif /* __FreeBSD__ */
+
+ /* DIAGNOSTIC */
+ if (vp->v_usecount < 0 || vp->v_writecount != 0) {
+ vprint("vrele: bad ref count", vp);
+ panic("vrele: ref cnt");
+ }
+
+ XFSDEB(XDEBMSG, ("xfs_message_gc: success\n"));
+
+#ifdef HAVE_KERNEL_FUNC_VGONEL
+ vgonel (vp, p);
+#else
+ simple_unlock(&vp->v_interlock);
+ vgone (vp);
+#endif
+
+ } else {
+ simple_unlock(&vp->v_interlock);
+ XFSDEB(XDEBMSG, ("xfs_message_gc: used\n"));
+ }
+
+}
+
+int
+xfs_message_gc_nodes(int fd,
+ struct xfs_message_gc_nodes *message,
+ u_int size,
+ struct proc *p)
+{
+ XFSDEB(XDEBMSG, ("xfs_message_gc\n"));
+
+ if (message->len == 0) {
+ struct vnode *vp, *next;
+
+ /* XXX see comment in xfs_node_find */
+ /* XXXSMP do gone[l] need to get mntvnode_slock ? */
+
+ for(vp = XFS_TO_VFS(&xfs[fd])->mnt_vnodelist.lh_first;
+ vp != NULL;
+ vp = next) {
+
+ next = vp->v_mntvnodes.le_next;
+ gc_vnode (vp, p);
+ }
+ } else {
+ struct xfs_node *t;
+ int i;
+
+ for (i = 0; i < message->len; i++) {
+ t = xfs_node_find (&xfs[fd], &message->handle[i]);
+ if (t == NULL)
+ continue;
+
+ gc_vnode(XNODE_TO_VNODE(t), p);
+ }
+ }
+
+ return 0;
+}
+
+
+#endif
+
+/*
+ * Probe what version of xfs this support
+ */
+
+int
+xfs_message_version(int fd,
+ struct xfs_message_version *message,
+ u_int size,
+ struct proc *p)
+{
+ struct xfs_message_wakeup msg;
+ int ret;
+
+ ret = XFS_VERSION;
+
+ msg.header.opcode = XFS_MSG_WAKEUP;
+ msg.sleepers_sequence_num = message->header.sequence_num;
+ msg.error = ret;
+
+ return xfs_message_send(fd, (struct xfs_message_header *) &msg, sizeof(msg));
+}
diff --git a/sys/xfs/xfs_message.h b/sys/xfs/xfs_message.h
index 16e1ca71a1f..c8cb4584b7d 100644
--- a/sys/xfs/xfs_message.h
+++ b/sys/xfs/xfs_message.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_message.h,v 1.3 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,12 +36,31 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_message.h,v 1.4 2000/09/11 14:26:52 art Exp $ */
#ifndef _xmsg_h
#define _xmsg_h
-#if !defined(__LINUX__) && !defined(HAVE_GLIBC)
+/* bump this for any incompatible changes */
+
+#define XFS_VERSION 17
+
+#if defined(WIN32)
+#ifdef i386
+#ifndef __CYGWIN__
+typedef int int32_t;
+typedef unsigned int u_int32_t;
+typedef short int16_t;
+typedef unsigned char u_char;
+#endif
+#else
+#error not a i386
+#endif
+#elif !defined(__LINUX__) && !defined(HAVE_GLIBC)
#include <sys/types.h>
+#if !defined(__OpenBSD__) && defined(_KERNEL)
+#include <atypes.h>
+#endif
#include <sys/param.h>
#else
#include <linux/types.h>
@@ -54,18 +72,18 @@
/* Temporary hack? */
#define MAX_XMSG_SIZE (1024*64)
-typedef u_int32_t pag_t;
+typedef u_int32_t xfs_pag_t;
/*
* The xfs_cred, if pag == 0, use uid
*/
typedef struct xfs_cred {
- __kernel_uid_t uid;
- pag_t pag;
+ u_int32_t uid;
+ xfs_pag_t pag;
} xfs_cred;
-typedef unsigned long xfs_locktype_t;
-typedef unsigned long xfs_lockid_t;
+typedef u_int32_t xfs_locktype_t;
+typedef u_int32_t xfs_lockid_t;
#define MAXHANDLE (4*4)
@@ -74,7 +92,7 @@ typedef unsigned long xfs_lockid_t;
#define XFS_ANONYMOUSID 32766
typedef struct xfs_handle {
- u_int a, b, c, d;
+ u_int32_t a, b, c, d;
} xfs_handle;
#define xfs_handle_eq(p, q) \
@@ -120,6 +138,7 @@ typedef struct xfs_cache_handle {
/* xfs_node.flags */
#define XFS_DATA_DIRTY 0x0001
#define XFS_ATTR_DIRTY 0x0002
+#define XFS_AFSDIR 0x0004
/* Are necessary tokens available? */
#define XFS_TOKEN_GOT(xn, tok) ((xn)->tokens & (tok))
@@ -133,26 +152,34 @@ typedef struct xfs_cache_handle {
struct xfs_msg_node {
xfs_handle handle;
- u_int tokens;
+ u_int32_t tokens;
+ u_int32_t pad1;
struct xfs_attr attr;
- pag_t id[MAXRIGHTS];
+ xfs_pag_t id[MAXRIGHTS];
u_char rights[MAXRIGHTS];
u_char anonrights;
+ u_int16_t pad2;
+ u_int32_t pad3;
};
/*
* Messages passed through the xfs_dev.
*/
struct xfs_message_header {
- u_int size;
- u_int opcode;
- u_int sequence_num; /* Private */
+ u_int32_t size;
+ u_int32_t opcode;
+ u_int32_t sequence_num; /* Private */
+ u_int32_t pad1;
};
/*
* Used by putdata flag
*/
-enum { XFS_READ = 1, XFS_WRITE = 2, XFS_NONBLOCK = 4, XFS_APPEND = 8};
+enum { XFS_READ = 0x01,
+ XFS_WRITE = 0x02,
+ XFS_NONBLOCK = 0x04,
+ XFS_APPEND = 0x08,
+ XFS_FSYNC = 0x10};
/*
* Flags for inactivenode
@@ -163,7 +190,7 @@ enum { XFS_NOREFS = 1, XFS_DELETE = 2 };
* Flags for installdata
*/
-enum { XFS_INVALID_DNLC = 1 };
+enum { XFS_ID_INVALID_DNLC = 0x01, XFS_ID_AFSDIR = 0x02 };
/*
* Defined message types and their opcodes.
@@ -210,13 +237,21 @@ enum { XFS_INVALID_DNLC = 1 };
#define XFS_MSG_ADVLOCK 25
-#define XFS_MSG_COUNT 26
+#define XFS_MSG_GC_NODES 26
+
+#define XFS_MSG_COUNT 27
+
+/* XFS_MESSAGE_VERSION */
+struct xfs_message_version {
+ struct xfs_message_header header;
+ u_int32_t ret;
+};
/* XFS_MESSAGE_WAKEUP */
struct xfs_message_wakeup {
struct xfs_message_header header;
- int sleepers_sequence_num; /* Where to send wakeup */
- int error; /* Return value */
+ u_int32_t sleepers_sequence_num; /* Where to send wakeup */
+ u_int32_t error; /* Return value */
};
/* XFS_MESSAGE_GETROOT */
@@ -265,7 +300,8 @@ struct xfs_message_getdata {
struct xfs_message_header header;
struct xfs_cred cred;
xfs_handle handle;
- u_int tokens;
+ u_int32_t tokens;
+ u_int32_t pad1;
};
/* XFS_MESSAGE_INSTALLDATA */
@@ -274,14 +310,16 @@ struct xfs_message_installdata {
struct xfs_msg_node node;
char cache_name[256]; /* XXX */
struct xfs_cache_handle cache_handle;
- u_int flag;
+ u_int32_t flag;
+ u_int32_t pad1;
};
/* XFS_MSG_INACTIVENODE */
struct xfs_message_inactivenode {
struct xfs_message_header header;
xfs_handle handle;
- u_int flag;
+ u_int32_t flag;
+ u_int32_t pad1;
};
/* XFS_MSG_INVALIDNODE */
@@ -295,7 +333,8 @@ struct xfs_message_open {
struct xfs_message_header header;
struct xfs_cred cred;
xfs_handle handle;
- u_int tokens;
+ u_int32_t tokens;
+ u_int32_t pad1;
};
/* XFS_MSG_PUTDATA */
@@ -304,7 +343,8 @@ struct xfs_message_putdata {
xfs_handle handle;
struct xfs_attr attr; /* XXX ??? */
struct xfs_cred cred;
- u_int flag;
+ u_int32_t flag;
+ u_int32_t pad1;
};
/* XFS_MSG_PUTATTR */
@@ -321,7 +361,8 @@ struct xfs_message_create {
xfs_handle parent_handle;
char name[256]; /* XXX */
struct xfs_attr attr;
- int mode;
+ u_int32_t mode;
+ u_int32_t pad1;
struct xfs_cred cred;
};
@@ -382,10 +423,11 @@ struct xfs_message_rename {
/* XFS_MSG_PIOCTL */
struct xfs_message_pioctl {
struct xfs_message_header header;
- int opcode ;
+ u_int32_t opcode ;
+ u_int32_t pad1;
xfs_cred cred;
- int insize;
- int outsize;
+ u_int32_t insize;
+ u_int32_t outsize;
char msg[2048] ; /* XXX */
xfs_handle handle;
};
@@ -394,9 +436,10 @@ struct xfs_message_pioctl {
/* XFS_MESSAGE_WAKEUP_DATA */
struct xfs_message_wakeup_data {
struct xfs_message_header header;
- int sleepers_sequence_num; /* Where to send wakeup */
- int error; /* Return value */
- int len;
+ u_int32_t sleepers_sequence_num; /* Where to send wakeup */
+ u_int32_t error; /* Return value */
+ u_int32_t len;
+ u_int32_t pad1;
char msg[2048] ; /* XXX */
};
@@ -420,4 +463,12 @@ struct xfs_message_advlock {
xfs_lockid_t lockid;
};
+/* XFS_MESSAGE_GC_NODES */
+struct xfs_message_gc_nodes {
+ struct xfs_message_header header;
+#define XFS_GC_NODES_MAX_HANDLE 50
+ u_int32_t len;
+ u_int32_t pad1;
+ xfs_handle handle[XFS_GC_NODES_MAX_HANDLE];
+};
#endif /* _xmsg_h */
diff --git a/sys/xfs/xfs_msg_locl.h b/sys/xfs/xfs_msg_locl.h
index 30abc31337d..907b668ad3a 100644
--- a/sys/xfs/xfs_msg_locl.h
+++ b/sys/xfs/xfs_msg_locl.h
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_msg_locl.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_msg_locl.h,v 1.5 2000/09/11 14:26:52 art Exp $ */
#ifndef _xfs_msg_locl_h
#define _xfs_msg_locl_h
@@ -77,4 +77,16 @@ xfs_message_updatefid(int fd,
u_int size,
struct proc *p);
+int
+xfs_message_gc_nodes(int fd,
+ struct xfs_message_gc_nodes * message,
+ u_int size,
+ struct proc *p);
+
+int
+xfs_message_version(int fd,
+ struct xfs_message_version *message,
+ u_int size,
+ struct proc *p);
+
#endif /* _xfs_msg_locl_h */
diff --git a/sys/xfs/xfs_node-bsd.c b/sys/xfs/xfs_node-bsd.c
index 7205fd5e1b1..31bd69d4260 100644
--- a/sys/xfs/xfs_node-bsd.c
+++ b/sys/xfs/xfs_node-bsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_node-bsd.c,v 1.2 2000/03/03 00:54:58 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -42,11 +40,16 @@
#include <xfs/xfs_common.h>
#include <xfs/xfs_fs.h>
#include <xfs/xfs_deb.h>
+#include <xfs/xfs_vnodeops.h>
-RCSID("$OpenBSD: xfs_node-bsd.c,v 1.2 2000/03/03 00:54:58 todd Exp $");
+RCSID("$Id: xfs_node-bsd.c,v 1.3 2000/09/11 14:26:53 art Exp $");
extern vop_t **xfs_vnodeop_p;
+#ifndef LK_NOPAUSE
+#define LK_NOPAUSE 0
+#endif
+
/*
* Allocate a new vnode with handle `handle' in `mp' and return it in
* `vpp'. Return 0 or error.
@@ -72,10 +75,14 @@ xfs_getnewvnode(struct mount *mp, struct vnode **vpp,
result->handle = *handle;
result->flags = 0;
result->tokens = 0;
+#if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR)
+ lockinit (&result->lock, PVFS, "xfs_lock", 0, LK_NOPAUSE);
+#else
result->vnlocks = 0;
-
+#endif
result->anonrights = 0;
-
+ result->cred = NULL;
+
return 0;
}
@@ -92,18 +99,17 @@ new_xfs_node(struct xfs *xfsp,
struct xfs_node **xpp,
struct proc *p)
{
- int do_vget = 0;
struct xfs_node *result;
- XFSDEB(XDEBNODE, ("new_xfs_node %d.%d.%d.%d\n",
+ XFSDEB(XDEBNODE, ("new_xfs_node (%d,%d,%d,%d)\n",
node->handle.a,
node->handle.b,
node->handle.c,
node->handle.d));
- again:
+
+retry:
/* Does not allow duplicates */
result = xfs_node_find(xfsp, &node->handle);
-
if (result == 0) {
int error;
struct vnode *v;
@@ -118,10 +124,8 @@ new_xfs_node(struct xfs *xfsp,
xfsp->nnodes++;
} else {
/* Node is already cached */
-#ifdef HAVE_LK_INTERLOCK
- simple_lock(&(XNODE_TO_VNODE(result)->v_interlock));
-#endif
- do_vget = 1;
+ if(xfs_do_vget(XNODE_TO_VNODE(result), 0, p))
+ goto retry;
}
/* Init other fields */
@@ -131,17 +135,6 @@ new_xfs_node(struct xfs *xfsp,
bcopy(node->id, result->id, sizeof(result->id));
bcopy(node->rights, result->rights, sizeof(result->rights));
- /*
- * We need to postpone this until here because (on FreeBSD) vget
- * tries to install a pager on the vnode and for that it wants to
- * retrieve the size with getattr.
- */
-
- if (do_vget) {
- if (xfs_do_vget(XNODE_TO_VNODE(result), LK_INTERLOCK, p))
- goto again;
- }
-
*xpp = result;
XFSDEB(XDEBNODE, ("return: new_xfs_node\n"));
return 0;
@@ -152,7 +145,12 @@ free_xfs_node(struct xfs_node *node)
{
struct xfs *xfsp = XFS_FROM_XNODE(node);
- XFSDEB(XDEBNODE, ("free_xfs_node starting: node = %p\n", node));
+ XFSDEB(XDEBNODE, ("free_xfs_node(%lx) (%d,%d,%d,%d)\n",
+ (unsigned long)node,
+ node->handle.a,
+ node->handle.b,
+ node->handle.c,
+ node->handle.d));
/* XXX Really need to put back dirty data first. */
@@ -162,6 +160,11 @@ free_xfs_node(struct xfs_node *node)
}
xfsp->nnodes--;
XNODE_TO_VNODE(node)->v_data = NULL;
+ if (node->cred) {
+ crfree (node->cred);
+ node->cred = NULL;
+ }
+
xfs_free(node, sizeof(*node));
XFSDEB(XDEBNODE, ("free_xfs_node done\n"));
@@ -218,8 +221,25 @@ xfs_node_find(struct xfs *xfsp, xfs_handle *handlep)
struct vnode *t;
struct xfs_node *xn = NULL;
- XFSDEB(XDEBNODE, ("xfs_node_find: xfsp = %p handlep = %p\n",
- xfsp, handlep));
+ XFSDEB(XDEBNODE, ("xfs_node_find: xfsp = %lx "
+ " handlep = (%d,%d,%d,%d)\n",
+ (unsigned long)xfsp,
+ handlep->a,
+ handlep->b,
+ handlep->c,
+ handlep->d));
+
+ /*
+ * XXXSMP - the vnodes on mnt_vnodelist are invalid unless we hold
+ * mntvnode_slock (same on Open,Free and Net - current).
+ * XXX - Another problem here is that the data in the vnode doesn't
+ * have to be correct unless we do a vget first (if usecount on
+ * vnode == 0). This should only be a problem when someone uses
+ * revoke, when unmounting or when arlad dies or on systems
+ * with a shortage of vnodes.
+ * We might want to vget here, but that was a problem
+ * on FreeBSD once.
+ */
for(t = XFS_TO_VFS(xfsp)->mnt_vnodelist.lh_first;
t != NULL;
@@ -399,17 +419,21 @@ tbl_enter (size_t len, const char *name, struct vnode *dvp, struct vnode *vp)
}
/*
- * Lookup in tbl
+ * Lookup in tbl (`dvp', `name', `len') and return result in `res'.
+ * Return -1 if succesful, otherwise 0.
*/
static int
-tbl_lookup (size_t len, const char *name, struct vnode *dvp, struct vnode **res)
+tbl_lookup (struct componentname *cnp,
+ struct vnode *dvp,
+ struct vnode **res)
{
if (tbl.dvp == dvp
- && tbl.len == len
- && strncmp(tbl.name, name, len) == 0
+ && tbl.len == cnp->cn_namelen
+ && strncmp(tbl.name, cnp->cn_nameptr, tbl.len) == 0
&& tbl.dvpid == tbl.dvp->v_id
&& tbl.vpid == tbl.vp->v_id) {
+
*res = tbl.vp;
return -1;
} else
@@ -425,13 +449,18 @@ xfs_dnlc_enter(struct vnode *dvp,
xfs_componentname *cnp,
struct vnode *vp)
{
- XFSDEB(XDEBDNLC, ("xfs_dnlc_enter_cnp(%p, %p, %p)\n", dvp, cnp, vp));
+ XFSDEB(XDEBDNLC, ("xfs_dnlc_enter_cnp(%lx, %lx, %lx)\n",
+ (unsigned long)dvp,
+ (unsigned long)cnp,
+ (unsigned long)vp));
XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: v_id = %ld\n", dvp->v_id));
XFSDEB(XDEBDNLC, ("xfs_dnlc_enter: calling cache_enter:"
- "dvp = %p, vp = %p, cnp = (%s, %ld, %lu), "
+ "dvp = %lx, vp = %lx, cnp = (%s, %ld), "
"nameiop = %lu, flags = %lx\n",
- dvp, vp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_hash,
+ (unsigned long)dvp,
+ (unsigned long)vp,
+ cnp->cn_nameptr, cnp->cn_namelen,
cnp->cn_nameiop, cnp->cn_flags));
#ifdef NCHNAMLEN
@@ -442,17 +471,35 @@ xfs_dnlc_enter(struct vnode *dvp,
* This is to make sure there's no negative entry already in the dnlc
*/
u_long save_nameiop;
+ u_long save_flags;
struct vnode *dummy;
- save_nameiop = cnp->cn_nameiop;
+ save_nameiop = cnp->cn_nameiop;
+ save_flags = cnp->cn_flags;
cnp->cn_nameiop = CREATE;
+ cnp->cn_flags &= ~MAKEENTRY;
+/*
+ * The version number here is not entirely correct, but it's conservative.
+ * The real change is sys/kern/vfs_cache:1.20
+ */
+
+#if __NetBSD_Version__ >= 104120000
+ if (cache_lookup(dvp, &dummy, cnp) != -1) {
+ VOP_UNLOCK(dummy, 0);
+ printf ("XFS PANIC WARNING! xfs_dnlc_enter: %s already in cache\n",
+ cnp->cn_nameptr);
+ }
+#else
if (cache_lookup(dvp, &dummy, cnp) != 0) {
printf ("XFS PANIC WARNING! xfs_dnlc_enter: %s already in cache\n",
cnp->cn_nameptr);
}
+#endif
+
cnp->cn_nameiop = save_nameiop;
+ cnp->cn_flags = save_flags;
cache_enter(dvp, vp, cnp);
}
@@ -463,21 +510,31 @@ xfs_dnlc_enter(struct vnode *dvp,
}
-void
+static void
xfs_cnp_init (struct componentname *cn,
- const char *name, struct vnode *vp, struct vnode *dvp,
+ const char *name,
struct proc *proc, struct ucred *cred,
int nameiop)
{
- char *p ;
+ const unsigned char *p;
bzero(cn, sizeof(*cn));
cn->cn_nameptr = (char *)name;
cn->cn_namelen = strlen(name);
cn->cn_flags = 0;
+#if __APPLE__
+ {
+ int i;
+
+ cn->cn_hash = 0;
+ for (p = cn->cn_nameptr, i = 1; *p; ++p, ++i)
+ cn->cn_hash += *p * i;
+ }
+#elif defined(HAVE_STRUCT_COMPONENTNAME_CN_HASH)
cn->cn_hash = 0;
for (p = cn->cn_nameptr; *p; ++p)
cn->cn_hash += *p;
+#endif
cn->cn_nameiop = nameiop;
cn->cn_proc = proc;
cn->cn_cred = cred;
@@ -494,59 +551,148 @@ xfs_dnlc_enter_name(struct vnode *dvp,
struct vnode *vp)
{
struct componentname cn;
- const char *p;
-
- XFSDEB(XDEBDNLC, ("xfs_dnlc_enter_name(%p, \"%s\", %p)\n", dvp, name, vp));
- cn.cn_nameiop = LOOKUP;
- cn.cn_flags = 0;
- cn.cn_namelen = strlen(name);
- cn.cn_nameptr = (char *)name;
- cn.cn_hash = 0;
- for (p = cn.cn_nameptr; *p; ++p)
- cn.cn_hash += *p;
+ XFSDEB(XDEBDNLC, ("xfs_dnlc_enter_name(%lx, \"%s\", %lx)\n",
+ (unsigned long)dvp,
+ name,
+ (unsigned long)vp));
+ xfs_cnp_init (&cn, name, NULL, NULL, LOOKUP);
return xfs_dnlc_enter (dvp, &cn, vp);
}
/*
* Lookup (dvp, cnp) in the DNLC and return the result in `res'.
- * Return -1 if succesful, 0 if not and ENOENT if we're sure it doesn't exist.
+ * Return the result from cache_lookup.
*/
-int
-xfs_dnlc_lookup(struct vnode *dvp,
- xfs_componentname *cnp,
- struct vnode **res)
+static int
+xfs_dnlc_lookup_int(struct vnode *dvp,
+ xfs_componentname *cnp,
+ struct vnode **res)
{
int error;
u_long saved_flags;
- XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup(%p, \"%s\")\n", dvp, cnp->cn_nameptr));
+ XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup(%lx, \"%s\")\n",
+ (unsigned long)dvp, cnp->cn_nameptr));
XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: v_id = %ld\n", dvp->v_id));
XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: calling cache_lookup:"
- "dvp = %p, cnp = (%s, %ld, %lu), flags = %lx\n",
- dvp, cnp->cn_nameptr, cnp->cn_namelen, cnp->cn_hash,
+ "dvp = %lx, cnp = (%s, %ld), flags = %lx\n",
+ (unsigned long)dvp,
+ cnp->cn_nameptr, cnp->cn_namelen,
cnp->cn_flags));
saved_flags = cnp->cn_flags;
- cnp->cn_flags |= MAKEENTRY;
+ cnp->cn_flags |= MAKEENTRY | LOCKPARENT | ISLASTCN;
error = cache_lookup(dvp, res, cnp);
cnp->cn_flags = saved_flags;
XFSDEB(XDEBDNLC, ("xfs_dnlc_lookup: cache_lookup returned. "
- "error = %d, *res = %p\n", error, *res));
+ "error = %d, *res = %lx\n", error,
+ (unsigned long)*res));
+ return error;
+}
+
+/*
+ * do the last (and locking protocol) portion of xnlc_lookup
+ *
+ * return:
+ * -1 for succesful
+ * 0 for failed
+ */
+
+static int
+xfs_dnlc_lock(struct vnode *dvp,
+ xfs_componentname *cnp,
+ struct vnode **res)
+{
+ int error = 0;
+
+ /*
+ * Try to handle the (complex) BSD locking protocol.
+ */
+
+ if (*res == dvp) { /* "." */
+ VREF(dvp);
+ } else if (cnp->cn_flags & ISDOTDOT) { /* ".." */
+ u_long vpid = dvp->v_id;
+
+ xfs_vfs_unlock(dvp, xfs_cnp_to_proc(cnp));
+ error = xfs_do_vget(*res, LK_EXCLUSIVE, xfs_cnp_to_proc(cnp));
+ xfs_vfs_writelock(dvp, xfs_cnp_to_proc(cnp));
+
+ if (error == 0 && dvp->v_id != vpid) {
+ vput(*res);
+ return 0;
+ }
+ } else {
+ error = xfs_do_vget(*res, LK_EXCLUSIVE, xfs_cnp_to_proc(cnp));
+ }
+
+ if (error == 0)
+ return -1;
+ else
+ return 0;
+}
+
+/*
+ * Lookup (`dvp', `cnp') in the DNLC (and the local cache).
+ *
+ * Return -1 if succesful, 0 if not and ENOENT if the entry is known
+ * not to exist.
+ *
+ * On modern NetBSD, cache_lookup has been changed to return 0 for
+ * succesful and -1 for not.
+ * (see the comment above for version information).
+ */
- if (error == -1 || error == ENOENT)
+#if __NetBSD_Version__ >= 104120000
+
+int
+xfs_dnlc_lookup(struct vnode *dvp,
+ xfs_componentname *cnp,
+ struct vnode **res)
+{
+ int error = xfs_dnlc_lookup_int (dvp, cnp, res);
+
+ if (error == 0)
+ return -1;
+ else if (error == ENOENT)
+ return error;
+
+ error = tbl_lookup (cnp, dvp, res);
+
+ if (error != -1)
+ return error;
+
+ return xfs_dnlc_lock (dvp, cnp, res);
+}
+
+#else /* ! __NetBSD_Version__ >= 104120000 */
+
+int
+xfs_dnlc_lookup(struct vnode *dvp,
+ xfs_componentname *cnp,
+ struct vnode **res)
+{
+ int error = xfs_dnlc_lookup_int (dvp, cnp, res);
+
+ if (error == 0)
+ error = tbl_lookup (cnp, dvp, res);
+
+ if (error != -1)
return error;
- return tbl_lookup (cnp->cn_namelen, cnp->cn_nameptr, dvp, res);
+ return xfs_dnlc_lock (dvp, cnp, res);
}
+#endif /* __NetBSD_Version__ >= 104120000 */
+
/*
* Remove one entry from the DNLC
*/
@@ -580,7 +726,7 @@ xfs_dnlc_purge_mp(struct mount *mp)
*/
int
-xfs_has_pag(const struct xfs_node *xn, pag_t pag)
+xfs_has_pag(const struct xfs_node *xn, xfs_pag_t pag)
{
int i;
diff --git a/sys/xfs/xfs_node.h b/sys/xfs/xfs_node.h
index dec3b0acc19..ba9561e5154 100644
--- a/sys/xfs/xfs_node.h
+++ b/sys/xfs/xfs_node.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_node.h,v 1.5 2000/03/03 00:54:58 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_node.h,v 1.6 2000/09/11 14:26:53 art Exp $ */
#ifndef _xfs_xnode_h
#define _xfs_xnode_h
@@ -53,6 +53,12 @@
#include <xfs/xfs_attr.h>
#include <xfs/xfs_message.h>
+#ifdef __APPLE__
+typedef struct lock__bsd__ xfs_vnode_lock;
+#else
+typedef struct lock xfs_vnode_lock;
+#endif
+
struct xfs_node {
struct vnode *vn;
struct vnode *data;
@@ -60,13 +66,18 @@ struct xfs_node {
u_int flags;
u_int tokens;
xfs_handle handle;
- pag_t id[MAXRIGHTS];
+ xfs_pag_t id[MAXRIGHTS];
u_char rights[MAXRIGHTS];
u_char anonrights;
+#if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR)
+ xfs_vnode_lock lock;
+#else
int vnlocks;
+#endif
#ifdef __NetBSD__
struct lockf *i_lockf;
#endif
+ struct ucred *cred;
};
int xfs_getnewvnode(struct mount *mp, struct vnode **vpp,
@@ -80,12 +91,14 @@ int xfs_getnewvnode(struct mount *mp, struct vnode **vpp,
#define XNODE_TO_VNODE(xp) ((xp)->vn)
#define VNODE_TO_XNODE(vp) ((struct xfs_node *) (vp)->v_data)
-#if defined(HAVE_THREE_ARGUMENT_VGET)
-#define xfs_do_vget(vp, lockflag, proc) vget((vp), (lockflag), (proc))
-#elif !defined(__osf__)
+#if defined(HAVE_ONE_ARGUMENT_VGET)
+#define xfs_do_vget(vp, lockflag, proc) vget((vp))
+#elif defined(HAVE_TWO_ARGUMENT_VGET)
#define xfs_do_vget(vp, lockflag, proc) vget((vp), (lockflag))
+#elif defined(HAVE_THREE_ARGUMENT_VGET)
+#define xfs_do_vget(vp, lockflag, proc) vget((vp), (lockflag), (proc))
#else
-#define xfs_do_vget(vp, lockflag, proc) vget((vp))
+#error what kind of vget
#endif
#ifndef HAVE_VOP_T
diff --git a/sys/xfs/xfs_pioctl.h b/sys/xfs/xfs_pioctl.h
index ee2d499df0b..bbee423b4a5 100644
--- a/sys/xfs/xfs_pioctl.h
+++ b/sys/xfs/xfs_pioctl.h
@@ -1,6 +1,6 @@
-/* $OpenBSD: xfs_pioctl.h,v 1.3 1999/04/30 01:59:01 art Exp $ */
+/* $OpenBSD: xfs_pioctl.h,v 1.4 2000/09/11 14:26:53 art Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -126,6 +126,10 @@
#define VIOC_XFSDEBUG_PRINT _VICEIOCTL(57)
+#define VIOC_CALCULATE_CACHE _VICEIOCTL(58)
+
+#define VIOC_BREAKCALLBACK _VICEIOCTL(59)
+
/*
* GETCELLSTATUS flags
*/
diff --git a/sys/xfs/xfs_syscalls-common.c b/sys/xfs/xfs_syscalls-common.c
index ce26bf82d87..a9d52a8468c 100644
--- a/sys/xfs/xfs_syscalls-common.c
+++ b/sys/xfs/xfs_syscalls-common.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_syscalls-common.c,v 1.2 2000/03/03 00:54:58 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -40,7 +38,7 @@
#include <xfs/xfs_locl.h>
-RCSID("$OpenBSD: xfs_syscalls-common.c,v 1.2 2000/03/03 00:54:58 todd Exp $");
+RCSID("$Id: xfs_syscalls-common.c,v 1.3 2000/09/11 14:26:53 art Exp $");
/*
* XFS system calls.
@@ -60,16 +58,33 @@ RCSID("$OpenBSD: xfs_syscalls-common.c,v 1.2 2000/03/03 00:54:58 todd Exp $");
#elif defined(HAVE_SYS_IOCTL_H)
#include <sys/ioctl.h>
#endif
+/*
+ * XXX - horrible kludge. If we're built without HAVE_CONFIG_H we assume that
+ * we're built inside the kernel on OpenBSD.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kafs.h>
+#else
#include <xfs/xfs_pioctl.h>
+#endif
/*
* the syscall entry point
*/
+#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__)
+int
+xfspioctl(struct proc *proc, void *varg, register_t *return_value)
+#else
int
sys_xfspioctl(struct proc *proc, void *varg, register_t *return_value)
+#endif
{
+#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__)
struct sys_pioctl_args *arg = (struct sys_pioctl_args *) varg;
+#else
+ struct sys_xfspioctl_args *arg = (struct sys_xfspioctl_args *) varg;
+#endif
int error = EINVAL;
switch (SCARG(arg, operation)) {
@@ -126,7 +141,7 @@ xfs_is_pag(struct ucred *cred)
* Return the pag used by `cred'
*/
-pag_t
+xfs_pag_t
xfs_get_pag(struct ucred *cred)
{
if (xfs_is_pag(cred)) {
@@ -139,44 +154,113 @@ xfs_get_pag(struct ucred *cred)
}
/*
- * Acquire a new pag in `ret_cred'
+ * Set the pag in `ret_cred' and return a new cred.
*/
-int
-xfs_setpag_call(struct ucred **ret_cred)
+static int
+store_pag (struct ucred **ret_cred, gid_t part1, gid_t part2)
{
struct ucred *cred = *ret_cred;
- int i;
- if (!xfs_is_pag(cred)) {
+ if (!xfs_is_pag (cred)) {
+ int i;
- /* Check if it fits */
if (cred->cr_ngroups + 2 >= NGROUPS)
- return E2BIG; /* XXX Hmmm, better error ? */
+ return E2BIG;
cred = crcopy (cred);
- /* Copy the groups */
for (i = cred->cr_ngroups - 1; i > 0; i--) {
cred->cr_groups[i + 2] = cred->cr_groups[i];
}
cred->cr_ngroups += 2;
+ } else {
+ cred = crcopy (cred);
+ }
+ cred->cr_groups[1] = part1;
+ cred->cr_groups[2] = part2;
+ *ret_cred = cred;
- } else
- cred = crcopy(cred);
+ return 0;
+}
- cred->cr_groups[1] = pag_part_one;
- cred->cr_groups[2] = pag_part_two++;
+/*
+ * Acquire a new pag in `ret_cred'
+ */
+
+int
+xfs_setpag_call(struct ucred **ret_cred)
+{
+ int ret;
+
+ ret = store_pag (ret_cred, pag_part_one, pag_part_two++);
+ if (ret)
+ return ret;
if (pag_part_two > XFS_PAG2_ULIM) {
pag_part_one++;
pag_part_two = XFS_PAG2_LLIM;
}
- *ret_cred = cred;
+ return 0;
+}
+
+#if defined(_LKM) || defined(KLD_MODULE) || defined(__osf__)
+/*
+ * remove a pag
+ */
+
+static int
+xfs_unpag (struct ucred *cred)
+{
+ while (xfs_is_pag (cred)) {
+ int i;
+
+ for (i = 0; i < cred->cr_ngroups - 2; ++i)
+ cred->cr_groups[i] = cred->cr_groups[i+2];
+ cred->cr_ngroups -= 2;
+ }
return 0;
}
/*
+ * A wrapper around setgroups that preserves the pag.
+ */
+
+int
+xfs_setgroups (struct proc *p,
+ void *varg)
+{
+ struct xfs_setgroups_args *uap = (struct xfs_setgroups_args *)varg;
+ struct ucred **cred = &xfs_proc_to_cred(p);
+
+ if (xfs_is_pag (*cred)) {
+ gid_t part1, part2;
+ int ret;
+
+ if (SCARG(uap,gidsetsize) + 2 > NGROUPS)
+ return EINVAL;
+
+ part1 = (*cred)->cr_groups[1];
+ part2 = (*cred)->cr_groups[2];
+ ret = (*old_setgroups_func) (p, uap);
+ if (ret)
+ return ret;
+ return store_pag (cred, part1, part2);
+ } else {
+ int ret;
+
+ ret = (*old_setgroups_func) (p, uap);
+ /* don't support setting a PAG */
+ if (xfs_is_pag (*cred)) {
+ xfs_unpag (*cred);
+ return EINVAL;
+ }
+ return ret;
+ }
+}
+#endif
+
+/*
* Return the vnode corresponding to `pathptr'
*/
@@ -194,14 +278,13 @@ lookup_node (const char *pathptr,
struct nameidata nd, *ndp = &nd;
#endif
struct vnode *vp;
- size_t done;
- XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %p\n", pathptr));
+ XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %lx\n",
+ (unsigned long)pathptr));
- error = copyinstr(pathptr, path, MAXPATHLEN, &done);
+ error = copyinstr((char *) pathptr, path, MAXPATHLEN, NULL);
- XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %s len: %lu error: %d\n",
- path, (unsigned long)done, error));
+ XFSDEB(XDEBSYS, ("xfs_syscall: looking up: %s, error: %d\n", path, error));
if (error)
return error;
@@ -233,25 +316,46 @@ fhget_call (struct proc *p,
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 = suser (xfs_proc_to_cred(p), NULL);
+ error = xfs_suser (p);
if (error)
return error;
-#ifdef __osf__
- VOP_GETATTR(vp, &vattr, p->p_rcred, 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 = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+ 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;
@@ -261,21 +365,25 @@ fhget_call (struct proc *p,
SCARG(&fh_args, fileid) = vattr.va_fileid;
SCARG(&fh_args, gen) = vattr.va_gen;
- len = sizeof(fh_args);
+ xfs_handle.len = sizeof(fh_args);
+ memcpy (xfs_handle.fhdata, &fh_args, sizeof(fh_args));
+ len = sizeof(xfs_handle);
if (vice_ioctl->out_size < len) {
error = EINVAL;
goto out;
}
- error = copyout (&fh_args, vice_ioctl->out, len);
+ error = copyout (&xfs_handle, vice_ioctl->out, len);
if (error) {
XFSDEB(XDEBSYS, ("fhget_call: copyout failed: %d\n", error));
}
-
-out:
+
+ out:
vrele (vp);
return error;
+#endif /* HAVE_GETFH && HAVE_FHOPEN */
+
}
/*
@@ -289,8 +397,6 @@ fhopen_call (struct proc *p,
int flags,
register_t *retval)
{
- int error;
- struct xfs_fh_args fh_args;
XFSDEB(XDEBSYS, ("fhopen_call: flags = %d\n", flags));
@@ -299,19 +405,8 @@ fhopen_call (struct proc *p,
return EINVAL;
}
- if (vice_ioctl->in_size < sizeof(fh_args))
- return EINVAL;
-
- error = copyin (vice_ioctl->in,
- &fh_args,
- sizeof(fh_args));
- if (error)
- return error;
-
return xfs_fhopen (p,
- SCARG(&fh_args, fsid),
- SCARG(&fh_args, fileid),
- SCARG(&fh_args, gen),
+ (struct xfs_fhandle_t *)vice_ioctl->in,
flags,
retval);
}
@@ -364,21 +459,16 @@ remote_pioctl (struct proc *p,
msg.insize = vice_ioctl->in_size;
msg.outsize = vice_ioctl->out_size;
-#ifdef __osf__
- msg.cred.uid = p->p_ruid;
- msg.cred.pag = xfs_get_pag(p->p_rcred);
-#else
- msg.cred.uid = p->p_cred->p_ruid;
- msg.cred.pag = xfs_get_pag(p->p_ucred);
-#endif
+ msg.cred.uid = xfs_proc_to_ruid(p);
+ msg.cred.pag = xfs_get_pag(xfs_proc_to_cred(p));
error = xfs_message_rpc(0, &msg.header, sizeof(msg)); /* XXX */
msg2 = (struct xfs_message_wakeup_data *) &msg;
if (error == 0)
error = msg2->error;
- else
- error = EINVAL; /* return EINVAL to not confuse applications */
+ if (error == ENODEV)
+ error = EINVAL;
if (error == 0 && msg2->header.opcode == XFS_MSG_WAKEUP_DATA)
error = copyout(msg2->msg, vice_ioctl->out,
@@ -397,7 +487,7 @@ xfs_debug (struct proc *p,
if (vice_ioctl->in_size < sizeof(int32_t))
return EINVAL;
- error = suser (xfs_proc_to_cred(p), NULL);
+ error = xfs_suser (p);
if (error)
return error;
@@ -439,11 +529,11 @@ xfs_pioctl_call(struct proc *proc,
char *pathptr;
struct vnode *vp = NULL;
- XFSDEB(XDEBSYS, ("xfs_syscall(%d, %p, %d, %p, %d)\n",
+ XFSDEB(XDEBSYS, ("xfs_syscall(%d, %lx, %d, %lx, %d)\n",
SCARG(arg, operation),
- SCARG(arg, a_pathP),
+ (unsigned long)SCARG(arg, a_pathP),
SCARG(arg, a_opcode),
- SCARG(arg, a_paramsP),
+ (unsigned long)SCARG(arg, a_paramsP),
SCARG(arg, a_followSymlinks)));
/* Copy in the data structure for us */
diff --git a/sys/xfs/xfs_syscalls.h b/sys/xfs/xfs_syscalls.h
index 4b5470c635d..dabebd3b4cc 100644
--- a/sys/xfs/xfs_syscalls.h
+++ b/sys/xfs/xfs_syscalls.h
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_syscalls.h,v 1.4 2000/03/03 00:54:58 todd Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -37,32 +36,13 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_syscalls.h,v 1.5 2000/09/11 14:26:53 art Exp $ */
#ifndef __xfs_syscalls
#define __xfs_syscalls
#include <xfs/xfs_common.h>
#include <xfs/xfs_message.h>
-#ifdef HAVE_SYS_SYSCALLARGS_H
-#include <sys/syscallargs.h>
-#endif
-
-/*
- * XXX
- */
-
-#ifndef SCARG
-#define SCARG(a, b) ((a)->b.datum)
-#define syscallarg(x) union { x datum; register_t pad; }
-#endif
-
-#ifndef syscallarg
-#define syscallarg(x) x
-#endif
-
-#ifndef HAVE_REGISTER_T
-typedef int register_t;
-#endif
struct sys_pioctl_args {
syscallarg(int) operation;
@@ -72,6 +52,14 @@ struct sys_pioctl_args {
syscallarg(int) a_followSymlinks;
};
+#define XFS_FHMAXDATA 40
+
+struct xfs_fhandle_t {
+ u_short len;
+ u_short pad;
+ char fhdata[XFS_FHMAXDATA];
+};
+
struct xfs_fh_args {
syscallarg(fsid_t) fsid;
syscallarg(long) fileid;
@@ -81,13 +69,28 @@ struct xfs_fh_args {
int xfs_install_syscalls(void);
int xfs_uninstall_syscalls(void);
int xfs_stat_syscalls(void);
-pag_t xfs_get_pag(struct ucred *);
+xfs_pag_t xfs_get_pag(struct ucred *);
int xfs_setpag_call(struct ucred **ret_cred);
int xfs_pioctl_call(struct proc *proc,
struct sys_pioctl_args *args,
register_t *return_value);
-int sys_xfspioctl(struct proc *proc, void *varg, register_t *retval);
+int xfspioctl(struct proc *proc, void *varg, register_t *retval);
+
+int xfs_setgroups (struct proc *p,
+ void *varg);
+
+extern int (*old_setgroups_func)(struct proc *, void *);
+extern int xfs_syscall_num; /* The old syscall number */
+
+
+#ifndef HAVE_KERNEL_SYS_LKMNOSYS
+#define sys_lkmnosys nosys
+#endif
+
+#ifndef SYS_MAXSYSCALL
+#define SYS_MAXSYSCALL nsysent
+#endif
#endif /* __xfs_syscalls */
diff --git a/sys/xfs/xfs_vfsops-bsd.c b/sys/xfs/xfs_vfsops-bsd.c
index e35ccb4f790..153d5df539d 100644
--- a/sys/xfs/xfs_vfsops-bsd.c
+++ b/sys/xfs/xfs_vfsops-bsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_vfsops-bsd.c,v 1.4 2000/03/03 00:54:59 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -40,7 +38,7 @@
#include <xfs/xfs_locl.h>
-RCSID("$OpenBSD: xfs_vfsops-bsd.c,v 1.4 2000/03/03 00:54:59 todd Exp $");
+RCSID("$Id: xfs_vfsops-bsd.c,v 1.5 2000/09/11 14:26:53 art Exp $");
/*
* XFS vfs operations.
@@ -68,8 +66,8 @@ xfs_mount(struct mount *mp,
int
xfs_start(struct mount * mp, int flags, struct proc * p)
{
- XFSDEB(XDEBVFOPS, ("xfs_start mp = %p, flags = %d, proc = %p\n",
- mp, flags, p));
+ XFSDEB(XDEBVFOPS, ("xfs_start mp = %lx, flags = %d, proc = %lx\n",
+ (unsigned long)mp, flags, (unsigned long)p));
return 0;
}
@@ -77,32 +75,35 @@ xfs_start(struct mount * mp, int flags, struct proc * p)
int
xfs_unmount(struct mount * mp, int mntflags, struct proc *p)
{
- XFSDEB(XDEBVFOPS, ("xfs_umount: mp = %p, mntflags = %d, proc = %p\n",
- mp, mntflags, p));
+ XFSDEB(XDEBVFOPS, ("xfs_umount: mp = %lx, mntflags = %d, proc = %lx\n",
+ (unsigned long)mp, mntflags, (unsigned long)p));
return xfs_unmount_common(mp, mntflags);
}
int
xfs_root(struct mount *mp, struct vnode **vpp)
{
- XFSDEB(XDEBVFOPS, ("xfs_root mp = %p\n", mp));
- return xfs_root_common(mp, vpp, curproc, curproc->p_ucred);
+ XFSDEB(XDEBVFOPS, ("xfs_root mp = %lx\n", (unsigned long)mp));
+ return xfs_root_common(mp, vpp, xfs_curproc(), xfs_curproc()->p_ucred);
}
int
xfs_quotactl(struct mount *mp, int cmd, uid_t uid, caddr_t arg, struct proc *p)
{
- XFSDEB(XDEBVFOPS, ("xfs_quotactl: mp = %p, cmd = %d, uid = %u, "
- "arg = %p, proc = %p\n",
- mp, cmd, uid, arg, p));
+ XFSDEB(XDEBVFOPS, ("xfs_quotactl: mp = %lx, cmd = %d, uid = %u, "
+ "arg = %lx, proc = %lx\n",
+ (unsigned long)mp, cmd, uid,
+ (unsigned long)arg, (unsigned long)p));
return EOPNOTSUPP;
}
int
xfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
{
- XFSDEB(XDEBVFOPS, ("xfs_statfs: mp = %p, sbp = %p, proc = %p\n",
- mp, sbp, p));
+ XFSDEB(XDEBVFOPS, ("xfs_statfs: mp = %lx, sbp = %lx, proc = %lx\n",
+ (unsigned long)mp,
+ (unsigned long)sbp,
+ (unsigned long)p));
bcopy(&mp->mnt_stat, sbp, sizeof(*sbp));
return 0;
}
@@ -110,25 +111,42 @@ xfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
int
xfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct proc *p)
{
- XFSDEB(XDEBVFOPS, ("xfs_sync: mp = %p, waitfor = %d, "
- "cred = %p, proc = %p\n",
- mp, waitfor, cred, p));
+ XFSDEB(XDEBVFOPS, ("xfs_sync: mp = %lx, waitfor = %d, "
+ "cred = %lx, proc = %lx\n",
+ (unsigned long)mp,
+ waitfor,
+ (unsigned long)cred,
+ (unsigned long)p));
return 0;
}
int
xfs_vget(struct mount * mp,
+#ifdef __APPLE__
+ void *ino,
+#else
ino_t ino,
+#endif
struct vnode ** vpp)
{
XFSDEB(XDEBVFOPS, ("xfs_vget\n"));
return EOPNOTSUPP;
}
+#ifdef HAVE_STRUCT_VFSOPS_VFS_CHECKEXP
int
xfs_fhtovp(struct mount * mp,
struct fid * fhp,
struct vnode ** vpp)
+#else
+int
+xfs_fhtovp(struct mount * mp,
+ struct fid * fhp,
+ struct mbuf * nam,
+ struct vnode ** vpp,
+ int *exflagsp,
+ struct ucred ** credanonp)
+#endif
{
#ifdef ARLA_KNFS
static struct ucred fhtovpcred;
@@ -166,7 +184,7 @@ xfs_fhtovp(struct mount * mp,
if (error)
return error;
- xfs_do_vget(vp, 0, current);
+ xfs_do_vget(vp, 0, curproc);
} else {
/* XXX access ? */
@@ -174,7 +192,7 @@ xfs_fhtovp(struct mount * mp,
/* XXX wrong ? (we tell arla below) */
if (vp->v_usecount <= 0)
- xfs_do_vget(vp, 0, current);
+ xfs_do_vget(vp, 0, curproc);
else
VREF(vp);
error = 0;
@@ -186,6 +204,12 @@ xfs_fhtovp(struct mount * mp,
fhtovpcred.cr_ngroups = 0;
*vpp = vp;
+#ifdef MNT_EXPUBLIC
+ *exflagsp = MNT_EXPUBLIC;
+#else
+ *exflagsp = 0;
+#endif
+ *credanonp = &fhtovpcred;
XFSDEB(XDEBVFOPS, ("xfs_fhtovp done\n"));
@@ -194,7 +218,7 @@ xfs_fhtovp(struct mount * mp,
* There need to be code in xfs_write too.
*/
} else
- XFSDEB(XDEBVFOPS, ("xfs_fhtovp failed (%d);", error));
+ XFSDEB(XDEBVFOPS, ("xfs_fhtovp failed (%d)\n", error));
return error;
#else
@@ -203,6 +227,20 @@ xfs_fhtovp(struct mount * mp,
}
int
+xfs_checkexp (struct mount *mp,
+#ifdef __FreeBSD__
+ struct sockaddr *nam,
+#else
+ struct mbuf *nam,
+#endif
+ int *exflagsp,
+ struct ucred **credanonp)
+{
+ XFSDEB(XDEBVFOPS, ("xfs_checkexp\n"));
+ return EOPNOTSUPP;
+}
+
+int
xfs_vptofh(struct vnode * vp,
struct fid * fhp)
{
@@ -257,32 +295,40 @@ xfs_dead_lookup(struct vop_lookup_args * ap)
int
xfs_fhlookup (struct proc *proc,
- fsid_t fsid,
- long fileid,
- long gen,
+ struct xfs_fhandle_t *fhp,
struct vnode **vpp)
{
int error;
struct mount *mp;
+#if !(defined(HAVE_GETFH) && defined(HAVE_FHOPEN))
struct ucred *cred = proc->p_ucred;
struct vattr vattr;
+ fsid_t fsid;
+ struct xfs_fh_args *fh_args = (struct xfs_fh_args *)fhp->fhdata;
- XFSDEB(XDEBVFOPS, ("xfs_fhlookup: fileid = %ld\n",
- fileid));
+ XFSDEB(XDEBVFOPS, ("xfs_fhlookup (xfs)\n"));
- error = suser (cred, NULL);
+ error = xfs_suser (proc);
if (error)
return EPERM;
-#ifdef HAVE_KERNEL_VFS_GETVFS
- mp = vfs_getvfs (&fsid);
-#else
- mp = getvfs (&fsid);
-#endif
+ if (fhp->len < sizeof(struct xfs_fh_args))
+ return EINVAL;
+
+ fsid = SCARG(fh_args, fsid);
+
+ mp = xfs_vfs_getvfs (&fsid);
if (mp == NULL)
return ENXIO;
- error = VFS_VGET(mp, fileid, vpp);
+#ifdef __APPLE__
+ {
+ u_int32_t ino = SCARG(fh_args, fileid);
+ error = VFS_VGET(mp, &ino, vpp);
+ }
+#else
+ error = VFS_VGET(mp, SCARG(fh_args, fileid), vpp);
+#endif
if (error)
return error;
@@ -293,33 +339,50 @@ xfs_fhlookup (struct proc *proc,
return error;
}
- if (vattr.va_gen != gen) {
+ if (vattr.va_gen != SCARG(fh_args, gen)) {
vput(*vpp);
return ENOENT;
}
+#else /* HAVE_GETFH && HAVE_FHOPEN */
+ {
+ fhandle_t *fh = (fhandle_t *) fhp;
+
+ XFSDEB(XDEBVFOPS, ("xfs_fhlookup (native)\n"));
+
+ mp = xfs_vfs_getvfs (&fh->fh_fsid);
+ if (mp == NULL)
+ return ESTALE;
+
+ if ((error = VFS_FHTOVP(mp, &fh->fh_fid, vpp)) != 0) {
+ *vpp = NULL;
+ return error;
+ }
+ }
+#endif /* HAVE_GETFH && HAVE_FHOPEN */
#ifdef HAVE_KERNEL_VFS_OBJECT_CREATE
if ((*vpp)->v_type == VREG && (*vpp)->v_object == NULL)
-#if HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE
- vfs_object_create (*vpp, proc, proc->p_ucred, TRUE);
-#else
- vfs_object_create (*vpp, proc, proc->p_ucred);
-#endif
+ 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);
#endif
return 0;
}
+
+
/*
- * Perform an open operation on the vnode identified by (fsid, fileid,
- * gen) (see xfs_fhlookup) with flags `user_flags'. Returns 0 or
+ * Perform an open operation on the vnode identified by a `xfs_fhandle_t'
+ * (see xfs_fhlookup) with flags `user_flags'. Returns 0 or
* error. If succsesful, the file descriptor is returned in `retval'.
*/
+extern struct fileops vnops; /* sometimes declared in <file.h> */
+
int
xfs_fhopen (struct proc *proc,
- fsid_t fsid,
- long fileid,
- long gen,
+ struct xfs_fhandle_t *fhp,
int user_flags,
register_t *retval)
{
@@ -329,14 +392,60 @@ xfs_fhopen (struct proc *proc,
int flags = FFLAGS(user_flags);
int index;
struct file *fp;
+ int mode;
+ struct xfs_fhandle_t fh;
+
+ XFSDEB(XDEBVFOPS, ("xfs_fhopen: flags = %d\n", user_flags));
- XFSDEB(XDEBVFOPS, ("xfs_fhopen: fileid = %ld, flags = %d\n",
- fileid, user_flags));
+ error = copyin (fhp, &fh, sizeof(fh));
+ if (error)
+ return error;
- error = xfs_fhlookup (proc, fsid, fileid, gen, &vp);
+ error = xfs_fhlookup (proc, &fh, &vp);
+ XFSDEB(XDEBVFOPS, ("xfs_fhlookup returned %d\n", error));
if (error)
return error;
+ switch (vp->v_type) {
+ case VDIR :
+ case VREG :
+ break;
+ case VLNK :
+ error = EMLINK;
+ goto out;
+ default :
+ error = EOPNOTSUPP;
+ break;
+ }
+
+ mode = 0;
+ if (flags & FWRITE) {
+ switch (vp->v_type) {
+ case VREG :
+ break;
+ case VDIR :
+ error = EISDIR;
+ goto out;
+ default :
+ error = EOPNOTSUPP;
+ break;
+ }
+
+ error = vn_writechk (vp);
+ if (error)
+ goto out;
+
+ mode |= VWRITE;
+ }
+ if (flags & FREAD)
+ mode |= VREAD;
+
+ if (mode) {
+ error = VOP_ACCESS(vp, mode, cred, proc);
+ if (error)
+ goto out;
+ }
+
error = VOP_OPEN(vp, flags, cred, proc);
if (error)
goto out;
@@ -348,13 +457,9 @@ xfs_fhopen (struct proc *proc,
if (flags & FWRITE)
vp->v_writecount++;
-#if __FreeBSD_version >= 300000
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 300000
if (vp->v_type == VREG) {
-#if HAVE_FOUR_ARGUMENT_VFS_OBJECT_CREATE
- error = vfs_object_create(vp, proc, proc->p_cred->pc_ucred, 1);
-#else
- error = vfs_object_create(vp, proc, proc->p_cred->pc_ucred);
-#endif
+ error = xfs_vfs_object_create(vp, proc, proc->p_cred->pc_ucred);
if (error)
goto out;
}
@@ -366,8 +471,15 @@ xfs_fhopen (struct proc *proc,
fp->f_data = (caddr_t)vp;
xfs_vfs_unlock(vp, proc);
*retval = index;
+#ifdef FILE_UNUSE
+ FILE_UNUSE(fp, proc);
+#endif
+#ifdef __APPLE__
+ *fdflags(proc, index) &= ~UF_RESERVED;
+#endif
return 0;
out:
+ XFSDEB(XDEBVFOPS, ("xfs_fhopen: error = %d\n", error));
vput(vp);
return error;
}
diff --git a/sys/xfs/xfs_vfsops-bsd.h b/sys/xfs/xfs_vfsops-bsd.h
index 401a2a82075..e37f463cd2a 100644
--- a/sys/xfs/xfs_vfsops-bsd.h
+++ b/sys/xfs/xfs_vfsops-bsd.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_vfsops-bsd.h,v 1.3 2000/03/03 00:54:59 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_vfsops-bsd.h,v 1.4 2000/09/11 14:26:53 art Exp $ */
#ifndef _xfs_vfsops_bsd_h
#define _xfs_vfsops_bsd_h
@@ -68,13 +68,38 @@ xfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct proc *p);
int
xfs_vget(struct mount * mp,
+#ifdef __APPLE__
+ void *ino,
+#else
ino_t ino,
+#endif
struct vnode ** vpp);
+#ifdef HAVE_STRUCT_VFSOPS_VFS_CHECKEXP
int
xfs_fhtovp(struct mount * mp,
struct fid * fhp,
struct vnode ** vpp);
+#else
+int
+xfs_fhtovp(struct mount * mp,
+ struct fid * fhp,
+ struct mbuf * nam,
+ struct vnode ** vpp,
+ int *exflagsp,
+ struct ucred ** credanonp);
+#endif
+
+struct mbuf;
+int
+xfs_checkexp (struct mount *mp,
+#ifdef __FreeBSD__
+ struct sockaddr *nam,
+#else
+ struct mbuf *nam,
+#endif
+ int *exflagsp,
+ struct ucred **credanonp);
int
xfs_vptofh(struct vnode * vp,
diff --git a/sys/xfs/xfs_vfsops-common.c b/sys/xfs/xfs_vfsops-common.c
index e7727c7da60..0dd136dff64 100644
--- a/sys/xfs/xfs_vfsops-common.c
+++ b/sys/xfs/xfs_vfsops-common.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_vfsops-common.c,v 1.2 2000/03/03 00:54:59 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -40,7 +38,7 @@
#include <xfs/xfs_locl.h>
-RCSID("$OpenBSD: xfs_vfsops-common.c,v 1.2 2000/03/03 00:54:59 todd Exp $");
+RCSID("$Id: xfs_vfsops-common.c,v 1.3 2000/09/11 14:26:53 art Exp $");
/*
* XFS vfs operations.
@@ -54,6 +52,13 @@ RCSID("$OpenBSD: xfs_vfsops-common.c,v 1.2 2000/03/03 00:54:59 todd Exp $");
#include <xfs/xfs_syscalls.h>
#include <xfs/xfs_vfsops.h>
+#ifdef HAVE_KERNEL_UDEV2DEV
+#define VA_RDEV_TO_DEV(x) udev2dev(x, 0) /* XXX what is the 0 */
+#else
+#define VA_RDEV_TO_DEV(x) x
+#endif
+
+
struct xfs xfs[NXFS];
int
@@ -69,19 +74,18 @@ xfs_mount_common(struct mount *mp,
struct vattr vat;
char path[MAXPATHLEN];
char data[MAXPATHLEN];
- size_t len;
- error = copyinstr(user_path, path, MAXPATHLEN, &len);
+ error = copyinstr(user_path, path, MAXPATHLEN, NULL);
if (error)
return error;
- error = copyinstr(user_data, data, MAXPATHLEN, &len);
+ error = copyinstr(user_data, data, MAXPATHLEN, NULL);
if (error)
return error;
XFSDEB(XDEBVFOPS, ("xfs_mount: "
- "struct mount mp = %p path = '%s' data = '%s'\n",
- mp, path, data));
+ "struct mount mp = %lx path = '%s' data = '%s'\n",
+ (unsigned long)mp, path, data));
#ifdef ARLA_KNFS
XFSDEB(XDEBVFOPS, ("xfs_mount: mount flags = %x\n", mp->mnt_flag));
@@ -124,28 +128,16 @@ xfs_mount_common(struct mount *mp,
XFSDEB(XDEBVFOPS, ("VOP_GETATTR failed, error = %d\n", error));
return error;
}
- dev = vat.va_rdev;
+
+ dev = VA_RDEV_TO_DEV(vat.va_rdev);
+
XFSDEB(XDEBVFOPS, ("dev = %d.%d\n", major(dev), minor(dev)));
- /* Check that this device really is an xfs_dev */
- if (major(dev) < 0 || major(dev) > nchrdev) {
- XFSDEB(XDEBVFOPS, ("major out of range (0 < %d < %d)\n",
- major(dev), nchrdev));
- return ENXIO;
- }
- if (minor(dev) < 0 || NXFS < minor(dev)) {
- XFSDEB(XDEBVFOPS, ("minor out of range (0 < %d < %d)\n",
- minor(dev), NXFS));
+ if (!xfs_is_xfs_dev (dev)) {
+ XFSDEB(XDEBVFOPS, ("%s is not a xfs device\n",
+ data));
return ENXIO;
}
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- if(!xfs_func_is_devopen(cdevsw[major(dev)].d_open))
- return ENXIO;
-#elif defined(__FreeBSD__)
- if (cdevsw[major(dev)] == NULL
- || !xfs_func_is_devopen(cdevsw[major(dev)]->d_open))
- return ENXIO;
-#endif
if (xfs[minor(dev)].status & XFS_MOUNTED)
return EBUSY;
@@ -157,18 +149,11 @@ 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
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
- getnewfsid(mp, makefstype(MOUNT_AFS));
-#elif defined(__FreeBSD__)
- getnewfsid(mp, MOUNT_AFS);
- mp->mnt_stat.f_type = MOUNT_AFS;
-#endif
mp->mnt_stat.f_bsize = DEV_BSIZE;
#ifndef __osf__
@@ -202,16 +187,18 @@ xfs_mount_common(struct mount *mp,
"arla",
sizeof(mp->mnt_stat.f_mntfromname));
-#if defined(__NetBSD__) || defined(__OpenBSD__)
strncpy(mp->mnt_stat.f_fstypename,
"xfs",
sizeof(mp->mnt_stat.f_fstypename));
-#endif
#endif /* __osf__ */
return 0;
}
+#ifdef HAVE_KERNEL_DOFORCE
+extern int doforce;
+#endif
+
int
xfs_unmount_common(struct mount *mp, int mntflags)
{
@@ -221,7 +208,6 @@ xfs_unmount_common(struct mount *mp, int mntflags)
if (mntflags & MNT_FORCE) {
#ifdef HAVE_KERNEL_DOFORCE
- extern int doforce;
if (!doforce)
return EINVAL;
#endif
@@ -248,7 +234,7 @@ xfs_root_common(struct mount *mp, struct vnode **vpp,
do {
if (xfsp->root != NULL) {
*vpp = XNODE_TO_VNODE(xfsp->root);
- xfs_do_vget(*vpp, LK_INTERLOCK|LK_EXCLUSIVE, proc);
+ xfs_do_vget(*vpp, LK_EXCLUSIVE, proc);
return 0;
}
msg.header.opcode = XFS_MSG_GETROOT;
diff --git a/sys/xfs/xfs_vfsops-openbsd.c b/sys/xfs/xfs_vfsops-openbsd.c
index 1da0cb180ab..b13f8b5c818 100644
--- a/sys/xfs/xfs_vfsops-openbsd.c
+++ b/sys/xfs/xfs_vfsops-openbsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_vfsops-openbsd.c,v 1.3 2000/03/03 00:54:59 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -40,7 +38,7 @@
#include <xfs/xfs_locl.h>
-RCSID("$OpenBSD: xfs_vfsops-openbsd.c,v 1.3 2000/03/03 00:54:59 todd Exp $");
+RCSID("$Id: xfs_vfsops-openbsd.c,v 1.4 2000/09/11 14:26:53 art Exp $");
#include <xfs/xfs_common.h>
#include <xfs/xfs_message.h>
@@ -56,7 +54,8 @@ static vop_t **xfs_dead_vnodeop_p;
int
make_dead_vnode(struct mount *mp, struct vnode **vpp)
{
- XFSDEB(XDEBNODE, ("make_dead_vnode mp = %p\n", mp));
+ XFSDEB(XDEBNODE, ("make_dead_vnode mp = %lx\n",
+ (unsigned long)mp));
return getnewvnode(VT_NON, mp, xfs_dead_vnodeop_p, vpp);
}
@@ -65,6 +64,9 @@ static struct vnodeopv_entry_desc xfs_dead_vnodeop_entries[] = {
{&vop_default_desc, (vop_t *) xfs_eopnotsupp},
{&vop_lookup_desc, (vop_t *) xfs_dead_lookup},
{&vop_reclaim_desc, (vop_t *) xfs_returnzero},
+ {&vop_lock_desc, (vop_t *) vop_generic_lock},
+ {&vop_unlock_desc, (vop_t *) vop_generic_unlock},
+ {&vop_islocked_desc,(vop_t *) vop_generic_islocked},
{NULL, NULL}};
static struct vnodeopv_desc xfs_dead_vnodeop_opv_desc =
@@ -83,22 +85,6 @@ xfs_init(struct vfsconf *vfs)
return 0;
}
-static int
-xfs_sysctl (int *name, u_int namelen, void *oldp, size_t *oldlenp,
- void *newp, size_t newlen, struct proc *p)
-{
- XFSDEB(XDEBVFOPS, ("xfs_sysctl\n"));
- return EOPNOTSUPP;
-}
-
-static int
-xfs_checkexp(struct mount *mp, struct mbuf *nam, int *exflagsp,
- struct ucred **credanonp)
-{
- XFSDEB(XDEBVFOPS, ("xfs_checkexp\n"));
- return (EOPNOTSUPP);
-}
-
struct vfsops xfs_vfsops = {
xfs_mount,
xfs_start,
@@ -111,8 +97,10 @@ struct vfsops xfs_vfsops = {
xfs_fhtovp,
xfs_vptofh,
xfs_init,
- xfs_sysctl,
- xfs_checkexp
+ NULL,
+#ifdef HAVE_STRUCT_VFSOPS_VFS_CHECKEXP
+ xfs_checkexp, /* checkexp */
+#endif
};
static struct vfsconf xfs_vfc = {
diff --git a/sys/xfs/xfs_vfsops.h b/sys/xfs/xfs_vfsops.h
index 35c2f2b4b0d..ed745766a1c 100644
--- a/sys/xfs/xfs_vfsops.h
+++ b/sys/xfs/xfs_vfsops.h
@@ -1,4 +1,3 @@
-/* $OpenBSD: xfs_vfsops.h,v 1.2 2000/03/03 00:54:59 todd Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_vfsops.h,v 1.3 2000/09/11 14:26:54 art Exp $ */
#ifndef _xfs_vfsops_h
#define _xfs_vfsops_h
@@ -59,16 +59,12 @@ xfs_root_common(struct mount *mp,
int
xfs_fhlookup (struct proc *proc,
- fsid_t fsid,
- long fileid,
- long gen,
+ struct xfs_fhandle_t *fhp,
struct vnode **vpp);
int
xfs_fhopen (struct proc *proc,
- fsid_t fsid,
- long fileid,
- long gen,
+ struct xfs_fhandle_t *fhp,
int flags,
register_t *retval);
diff --git a/sys/xfs/xfs_vnodeops-bsd.c b/sys/xfs/xfs_vnodeops-bsd.c
index d4495d04321..c730fb318d2 100644
--- a/sys/xfs/xfs_vnodeops-bsd.c
+++ b/sys/xfs/xfs_vnodeops-bsd.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_vnodeops-bsd.c,v 1.2 2000/03/03 00:54:59 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -50,10 +48,11 @@
#include <xfs/xfs_deb.h>
#include <xfs/xfs_syscalls.h>
#include <xfs/xfs_vnodeops.h>
-#include <vm/vm.h>
+#ifdef HAVE_VM_VNODE_PAGER_H
#include <vm/vnode_pager.h>
+#endif
-RCSID("$OpenBSD: xfs_vnodeops-bsd.c,v 1.2 2000/03/03 00:54:59 todd Exp $");
+RCSID("$Id: xfs_vnodeops-bsd.c,v 1.3 2000/09/11 14:26:54 art Exp $");
/*
* vnode functions
@@ -70,12 +69,7 @@ xfs_open(struct vop_open_args * ap)
struct proc *p;
}; */
{
- XFSDEB(XDEBVNOPS, ("xfs_open\n"));
-
- if (ap->a_mode & FWRITE)
- return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NW);
- else
- return xfs_open_valid(ap->a_vp, ap->a_cred, XFS_OPEN_NR);
+ return xfs_open_common (ap->a_vp, ap->a_mode, ap->a_cred, ap->a_p);
}
#endif /* HAVE_VOP_OPEN */
@@ -205,22 +199,23 @@ static int
xfs_getattr(struct vop_getattr_args * ap)
/* struct vnode *vp,
struct vattr *vap,
- struct ucred *cred) */
+ struct ucred *cred,
+ struct proc *p) */
{
- return xfs_getattr_common(ap->a_vp, ap->a_vap, ap->a_cred);
+ return xfs_getattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_p);
}
#endif /* HAVE_VOP_GETATTR */
#ifdef HAVE_VOP_SETATTR
static int
xfs_setattr(struct vop_setattr_args * ap)
- /*
-struct vnode *vp,
+ /* struct vnode *vp,
struct vattr *vap,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
*/
{
- return xfs_setattr_common(ap->a_vp, ap->a_vap, ap->a_cred);
+ return xfs_setattr_common(ap->a_vp, ap->a_vap, ap->a_cred, ap->a_p);
}
#endif /* HAVE_VOP_SETATTR */
@@ -230,10 +225,11 @@ xfs_access(struct vop_access_args * ap)
/*
struct vnode *vp,
int mode,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
*/
{
- return xfs_access_common(ap->a_vp, ap->a_mode, ap->a_cred);
+ return xfs_access_common(ap->a_vp, ap->a_mode, ap->a_cred, ap->a_p);
}
#endif /* HAVE_VOP_ACCESS */
@@ -249,6 +245,8 @@ xfs_lookup(struct vop_lookup_args * ap)
{
struct componentname *cnp = ap->a_cnp;
int error;
+ int lockparent = (cnp->cn_flags & (LOCKPARENT | ISLASTCN))
+ == (LOCKPARENT | ISLASTCN);
XFSDEB(XDEBVNOPS, ("xfs_lookup: (%s, %ld), nameiop = %lu, flags = %lu\n",
cnp->cn_nameptr,
@@ -264,6 +262,15 @@ 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;
@@ -283,34 +290,50 @@ xfs_cachedlookup(struct vop_cachedlookup_args * ap)
struct componentname *a_cnp;
}; */
{
- return xfs_lookup(ap);
+ return xfs_lookup((struct vop_lookup_args *)ap);
}
#endif /* HAVE_VOP_CACHEDLOOKUP */
+/*
+ * whatever clean-ups are needed for a componentname.
+ */
+
+static void
+cleanup_cnp (struct componentname *cnp, int error)
+{
+ if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) {
+#ifdef HAVE_KERNEL_ZFREEI
+ zfreei(namei_zone, cnp->cn_pnbuf);
+ cnp->cn_flags &= ~HASBUF;
+#elif defined(FREE_ZONE)
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
+#else
+ FREE (cnp->cn_pnbuf, M_NAMEI);
+#endif
+ }
+}
+
#ifdef HAVE_VOP_CREATE
static int
-xfs_create(struct vop_create_args * ap)
+xfs_create(struct vop_create_args *ap)
{
struct vnode *dvp = ap->a_dvp;
struct componentname *cnp = ap->a_cnp;
const char *name = cnp->cn_nameptr;
struct ucred *cred = cnp->cn_cred;
+ struct proc *p = xfs_cnp_to_proc(cnp);
int error;
- error = xfs_create_common(dvp,
- name,
- ap->a_vap,
- cred);
+ error = xfs_create_common(dvp, name, ap->a_vap, cred, p);
- if (error == 0)
- error = xfs_lookup_name(dvp, name, xfs_cnp_to_proc(cnp),
- cred, ap->a_vpp);
+ if (error == 0) {
+ error = xfs_lookup_common(dvp, cnp, ap->a_vpp);
+ }
- if (error != 0 || (ap->a_cnp->cn_flags & SAVESTART) == 0)
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, ap->a_cnp->cn_pnbuf);
-#else
- free (ap->a_cnp->cn_pnbuf, M_NAMEI);
+ cleanup_cnp (cnp, error);
+
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+ vput (dvp);
#endif
XFSDEB(XDEBVNOPS, ("xfs_create: error = %d\n", error));
@@ -328,15 +351,9 @@ xfs_remove(struct vop_remove_args * ap)
{
struct componentname *cnp = ap->a_cnp;
int error = xfs_remove_common(ap->a_dvp, ap->a_vp, cnp->cn_nameptr,
- cnp->cn_cred);
-
- if (error != 0 || (cnp->cn_flags & SAVESTART) == 0)
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, cnp->cn_pnbuf);
-#else
- free (cnp->cn_pnbuf, M_NAMEI);
-#endif
+ cnp->cn_cred, xfs_cnp_to_proc(cnp));
+ cleanup_cnp (cnp, error);
return error;
}
#endif /* HAVE_VOP_REMOVE */
@@ -364,7 +381,8 @@ xfs_rename(struct vop_rename_args * ap)
tdvp,
tvp,
ap->a_tcnp->cn_nameptr,
- ap->a_tcnp->cn_cred);
+ ap->a_tcnp->cn_cred,
+ xfs_cnp_to_proc (ap->a_fcnp));
if(tdvp == tvp)
vrele(tdvp);
else
@@ -390,30 +408,21 @@ xfs_mkdir(struct vop_mkdir_args * ap)
struct componentname *cnp = ap->a_cnp;
const char *name = cnp->cn_nameptr;
struct ucred *cred = cnp->cn_cred;
+ struct proc *p = xfs_cnp_to_proc(cnp);
int error;
- error = xfs_mkdir_common(dvp,
- name,
- ap->a_vap,
- cred);
+ error = xfs_mkdir_common(dvp, name, ap->a_vap, cred, p);
if (error == 0)
- error = xfs_lookup_name(dvp, name, xfs_cnp_to_proc(cnp),
- cred, ap->a_vpp);
+ error = xfs_lookup_common(dvp, cnp, ap->a_vpp);
- if (error != 0 || (ap->a_cnp->cn_flags & SAVESTART) == 0) {
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, ap->a_cnp->cn_pnbuf);
-#else
- free (ap->a_cnp->cn_pnbuf, M_NAMEI);
-#endif
- }
+ cleanup_cnp (cnp, error);
-#if defined(__OpenBSD__)
- vput(ap->a_dvp);
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+ vput(dvp);
#endif
- XFSDEB(XDEBVNOPS, ("xfs_create: error = %d\n", error));
+ XFSDEB(XDEBVNOPS, ("xfs_mkdir: error = %d\n", error));
return error;
}
@@ -428,20 +437,25 @@ xfs_rmdir(struct vop_rmdir_args * ap)
{
struct componentname *cnp = ap->a_cnp;
int error = xfs_rmdir_common(ap->a_dvp, ap->a_vp,
- cnp->cn_nameptr, cnp->cn_cred);
-
- if (error != 0 || (cnp->cn_flags & SAVESTART) == 0)
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, cnp->cn_pnbuf);
-#else
- free (cnp->cn_pnbuf, M_NAMEI);
-#endif
+ cnp->cn_nameptr,
+ cnp->cn_cred,
+ xfs_cnp_to_proc(cnp));
+ cleanup_cnp (cnp, error);
return error;
}
#endif /* HAVE_VOP_RMDIR */
#ifdef HAVE_VOP_READDIR
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+typedef u_long xfs_cookie_t;
+#elif defined(__NetBSD__)
+typedef off_t xfs_cookie_t;
+#else
+#error dunno want kind of cookies you have
+#endif
+
static int
xfs_readdir(struct vop_readdir_args * ap)
/* struct vnode *vp,
@@ -451,54 +465,39 @@ xfs_readdir(struct vop_readdir_args * ap)
int error;
off_t off;
- off = ap->a_uio->uio_offset;
+ off = ap->a_uio->uio_offset;
error = xfs_readdir_common(ap->a_vp, ap->a_uio, ap->a_cred,
- ap->a_eofflag);
+ xfs_uio_to_proc (ap->a_uio),
+ ap->a_eofflag);
if (!error && ap->a_ncookies != NULL) {
struct uio *uio = ap->a_uio;
- struct dirent* dp;
+ const struct dirent *dp, *dp_start, *dp_end;
int ncookies;
-#if defined(__FreeBSD__) || defined (__OpenBSD__)
- u_long *cookies;
- struct dirent* dpStart;
- struct dirent* dpEnd;
- u_long *cookiep;
-#else
- off_t *cookies;
- cookies = ap->a_cookies;
- ncookies = ap->a_ncookies;
-#endif
+ xfs_cookie_t *cookies, *cookiep;
+
if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
panic("xfs_readdir: mail arla-drinkers and tell them to bake burned cookies");
- dp = (struct dirent *)
- (uio->uio_iov->iov_base - (uio->uio_offset - off));
-#if defined(__FreeBSD__) || defined (__OpenBSD__)
- dpEnd = (struct dirent *) uio->uio_iov->iov_base;
- for (dpStart = dp, ncookies = 0;
- dp < dpEnd;
- dp = (struct dirent *)((caddr_t) dp + dp->d_reclen))
+ dp = (const struct dirent *)
+ ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off));
+
+ 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))
ncookies++;
- MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
- M_TEMP, M_WAITOK);
- for (dp = dpStart, cookiep = cookies;
- dp < dpEnd;
- dp = (struct dirent *)((caddr_t) dp + dp->d_reclen)) {
+
+ 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)) {
off += dp->d_reclen;
- *cookiep++ = (u_int) off;
+ *cookiep++ = off;
}
*ap->a_cookies = cookies;
*ap->a_ncookies = ncookies;
-#else /* __NetBSD__ */
- while (ncookies-- && off < uio->uio_offset) {
- if (dp->d_reclen == 0)
- break;
- off += dp->d_reclen;
- *(cookies++) = off;
- dp = (struct dirent *)((caddr_t)dp + dp->d_reclen);
- }
-#endif
}
return error;
}
@@ -514,21 +513,55 @@ xfs_link(struct vop_link_args * ap)
*/
{
struct componentname *cnp = ap->a_cnp;
- int error = xfs_link_common(
+ struct vnode *vp = ap->a_vp;
+ struct vnode *dvp;
+ struct proc *p = cnp->cn_proc;
+ int error;
+
#if defined (__OpenBSD__) || defined(__NetBSD__)
- ap->a_dvp,
-#elif defined(__FreeBSD__)
- ap->a_tdvp,
+ dvp = ap->a_dvp;
+#elif defined(__FreeBSD__) || defined(__APPLE__)
+ dvp = ap->a_tdvp;
+#else
+#error what kind of BSD is this?
+#endif
+
+ if (vp->v_type == VDIR) {
+#ifdef HAVE_VOP_ABORTOP
+ VOP_ABORTOP(dvp, cnp);
+#endif
+ error = EPERM;
+ goto out;
+ }
+ if (dvp->v_mount != vp->v_mount) {
+#ifdef HAVE_VOP_ABORTOP
+ VOP_ABORTOP(dvp, cnp);
+#endif
+ error = EXDEV;
+ goto out;
+ }
+ if (dvp != vp && (error = xfs_vfs_writelock(vp, p))) {
+#ifdef HAVE_VOP_ABORTOP
+ VOP_ABORTOP(dvp, cnp);
#endif
- ap->a_vp,
+ goto out;
+ }
+
+ error = xfs_link_common(
+ dvp,
+ vp,
cnp->cn_nameptr,
- cnp->cn_cred);
+ cnp->cn_cred,
+ xfs_cnp_to_proc (cnp));
- if (error != 0 || (cnp->cn_flags & SAVESTART) == 0)
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, cnp->cn_pnbuf);
-#else
- free (cnp->cn_pnbuf, M_NAMEI);
+ cleanup_cnp (cnp, error);
+
+ if (dvp != vp)
+ xfs_vfs_unlock(vp, p);
+
+out:
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+ vput(dvp);
#endif
return error;
@@ -549,19 +582,11 @@ xfs_symlink(struct vop_symlink_args * ap)
struct componentname *cnp = ap->a_cnp;
int error = xfs_symlink_common(ap->a_dvp,
ap->a_vpp,
- cnp->cn_nameptr,
- xfs_cnp_to_proc(cnp),
- cnp->cn_cred,
+ cnp,
ap->a_vap,
ap->a_target);
- if (error != 0 || (cnp->cn_flags & SAVESTART) == 0) {
-#ifdef HAVE_KERNEL_ZFREEI
- zfreei(namei_zone, cnp->cn_pnbuf);
-#else
- free (cnp->cn_pnbuf, M_NAMEI);
-#endif
- }
+ cleanup_cnp (cnp, error);
return error;
}
#endif /* HAVE_VOP_SYMLINK */
@@ -584,15 +609,7 @@ xfs_inactive(struct vop_inactive_args * ap)
/*struct vnode *vp,
struct ucred *cred)*/
{
-#if 0
- /*
- * This break freebsd 2.2.x
- */
-
return xfs_inactive_common(ap->a_vp, xfs_curproc());
-#else
- return 0;
-#endif
}
#endif /* HAVE_VOP_INACTICE */
@@ -604,53 +621,137 @@ xfs_reclaim(struct vop_reclaim_args * ap)
struct vnode *a_vp;
};*/
{
- return xfs_reclaim_common(ap->a_vp);
+ struct vnode *vp = ap->a_vp;
+ int ret;
+
+ ret = xfs_reclaim_common(vp);
+ vp->v_data = NULL;
+ return ret;
}
#endif /* HAVE_VOP_RECLAIM */
/*
- * The lock, unlock, islocked vnode operations.
- *
- * This should be done with the generic locking function for the
- * appropriate dialect of BSD (vop_nolock, genfs_nolock, ...). But,
- * most of these functions are commented out and don't work enough to
- * allow xfs_islocked to figure if the vnode is locked or not, which
- * other parts of the kernel depend on.
- *
- * We try do locking the folling way:
- * If we have LK_INTERLOCK & co:
- * Do no locking with (we should use lockmgr)
- * else
- * When VXLOCK is set loop
+ * Do lock, unlock, and islocked with lockmgr if we have it.
*/
+#if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR)
+
#ifdef HAVE_VOP_LOCK
static int
xfs_lock(struct vop_lock_args * ap)
+{
+ struct vnode *vp = ap->a_vp;
+ struct xfs_node *xn = VNODE_TO_XNODE(vp);
+ xfs_vnode_lock *l = &xn->lock;
+ int flags = ap->a_flags;
+ int ret;
+
+ XFSDEB(XDEBVNOPS, ("xfs_lock: %lx, flags 0x%x\n",
+ (unsigned long)vp, flags));
+
+ if (l == NULL)
+ panic("xfs_lock: lock NULL");
+
+ XFSDEB(XDEBVNOPS, ("xfs_lock before: lk flags: %d share: %d "
+ "wait: %d excl: %d holder: %d\n",
+ l->lk_flags, l->lk_sharecount, l->lk_waitcount,
+ l->lk_exclusivecount, l->lk_lockholder));
+
+#ifndef DEBUG_LOCKS
+#ifdef HAVE_FOUR_ARGUMENT_LOCKMGR
+ ret = lockmgr(l, flags, &vp->v_interlock, ap->a_p);
+#else
+ ret = lockmgr(l, flags, &vp->v_interlock);
+#endif
+#else
+ ret = debuglockmgr(l, flags, &vp->v_interlock, ap->a_p,
+ "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
+#endif
+ XFSDEB(XDEBVNOPS, ("xfs_lock: lk flags: %d share: %d "
+ "wait: %d excl: %d holder: %d\n",
+ l->lk_flags, l->lk_sharecount, l->lk_waitcount,
+ l->lk_exclusivecount, l->lk_lockholder));
+ return ret;
+}
+#endif /* HAVE_VOP_LOCK */
+
+#ifdef HAVE_VOP_UNLOCK
+static int
+xfs_unlock(struct vop_unlock_args * ap)
{
struct vnode *vp = ap->a_vp;
struct xfs_node *xn = VNODE_TO_XNODE(vp);
+ xfs_vnode_lock *l = &xn->lock;
+ int flags = ap->a_flags;
+ int ret;
- XFSDEB(XDEBVNOPS, ("xfs_lock: %p, %d\n", vp, xn->vnlocks));
+ if (l == NULL)
+ panic("xfs_unlock: lock NULL");
+
+ XFSDEB(XDEBVNOPS,
+ ("xfs_unlock: %lx, flags 0x%x, l %lx, ap %lx\n",
+ (unsigned long)vp, flags,
+ (unsigned long)l,
+ (unsigned long)ap));
+
+ XFSDEB(XDEBVNOPS, ("xfs_unlock: lk flags: %d share: %d "
+ "wait: %d excl: %d holder: %d\n",
+ l->lk_flags, l->lk_sharecount, l->lk_waitcount,
+ l->lk_exclusivecount, l->lk_lockholder));
+#ifndef DEBUG_LOCKS
+#ifdef HAVE_FOUR_ARGUMENT_LOCKMGR
+ ret = lockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_p);
+#else
+ ret = lockmgr (l, flags | LK_RELEASE, &vp->v_interlock);
+#endif
+#else
+ ret = debuglockmgr (l, flags | LK_RELEASE, &vp->v_interlock, ap->a_p,
+ "xfs_lock", ap->a_vp->filename, ap->a_vp->line);
+#endif
+ XFSDEB(XDEBVNOPS, ("xfs_unlock: return %d\n", ret));
+ return ret;
+}
+#endif /* HAVE_VOP_UNLOCK */
-#if defined(HAVE_LK_INTERLOCK) && !defined(HAVE_ONE_ARGUMENT_VOP_LOCK)
- {
- int flags = ap->a_flags;
+#ifdef HAVE_VOP_ISLOCKED
+static int
+xfs_islocked (struct vop_islocked_args *ap)
+{
+ struct vnode *vp = ap->a_vp;
+ struct xfs_node *xn = VNODE_TO_XNODE(vp);
+ xfs_vnode_lock *l = &xn->lock;
- if (flags & LK_INTERLOCK)
- simple_unlock(&vp->v_interlock);
+ XFSDEB(XDEBVNOPS, ("xfs_islocked: %lx\n",
+ (unsigned long)vp));
- if (!(flags & LK_TYPE_MASK))
- return 0;
- }
+#if defined(HAVE_TWO_ARGUMENT_LOCKSTATUS)
+ return lockstatus (l, ap->a_p);
+#elif defined(HAVE_ONE_ARGUMENT_LOCKSTATUS)
+ return lockstatus (l);
#else
+#error what lockstatus?
+#endif
+}
+#endif /* HAVE_VOP_ISLOCKED */
+
+#else /* !HAVE_KERNEL_LOCKMGR && !HAVE_KERNEL_DEBUGLOCKMGR */
+
+#ifdef HAVE_VOP_LOCK
+static int
+xfs_lock(struct vop_lock_args * ap)
+{
+ struct vnode *vp = ap->a_vp;
+ struct xfs_node *xn = VNODE_TO_XNODE(vp);
+
+ XFSDEB(XDEBVNOPS, ("xfs_lock: %lx, %d\n",
+ (unsigned long)vp, xn->vnlocks));
+
while (vp->v_flag & VXLOCK) {
vp->v_flag |= VXWANT;
(void) tsleep((caddr_t)vp, PINOD, "xfs_vnlock", 0);
}
if (vp->v_tag == VT_NON)
return (ENOENT);
-#endif
++xn->vnlocks;
return 0;
}
@@ -662,23 +763,17 @@ xfs_unlock(struct vop_unlock_args * ap)
{
struct vnode *vp = ap->a_vp;
struct xfs_node *xn = VNODE_TO_XNODE(vp);
- XFSDEB(XDEBVNOPS, ("xfs_unlock: %p, %d\n", vp, xn->vnlocks));
-
-#if defined(HAVE_LK_INTERLOCK) && !defined(HAVE_ONE_ARGUMENT_VOP_LOCK)
- {
- int flags = ap->a_flags;
+ XFSDEB(XDEBVNOPS, ("xfs_unlock: %lx, %d\n",
+ (unsigned long)vp, xn->vnlocks));
- if (flags & LK_INTERLOCK)
- simple_unlock(&vp->v_interlock);
- if (!(flags & LK_TYPE_MASK))
- return 0;
- }
-#endif
--xn->vnlocks;
if (xn->vnlocks < 0) {
printf ("PANIC: xfs_unlock: unlocking unlocked\n");
xn->vnlocks = 0;
}
+ XFSDEB(XDEBVNOPS, ("xfs_unlock: lock = %x\n",
+ vp->v_interlock.lock_data));
+
return 0;
}
#endif /* HAVE_VOP_UNLOCK */
@@ -690,11 +785,13 @@ xfs_islocked (struct vop_islocked_args *ap)
struct vnode *vp = ap->a_vp;
struct xfs_node *xn = VNODE_TO_XNODE(vp);
- XFSDEB(XDEBVNOPS, ("xfs_islocked: %p, %d\n", vp, xn->vnlocks));
+ XFSDEB(XDEBVNOPS, ("xfs_islocked: %lx, %d\n",
+ (unsigned long)vp, xn->vnlocks));
return xn->vnlocks;
}
#endif /* HAVE_VOP_ISLOCKED */
+#endif /* !HAVE_KERNEL_LOCKMGR */
#ifdef HAVE_VOP_ABORTOP
static int
@@ -707,6 +804,9 @@ xfs_abortop (struct vop_abortop_args *ap)
if ((cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
#ifdef HAVE_KERNEL_ZFREEI
zfreei(namei_zone, cnp->cn_pnbuf);
+ ap->a_cnp->cn_flags &= ~HASBUF;
+#elif defined(FREE_ZONE)
+ FREE_ZONE(cnp->cn_pnbuf, cnp->cn_pnlen, M_NAMEI);
#else
FREE(cnp->cn_pnbuf, M_NAMEI);
#endif
@@ -783,14 +883,17 @@ xfs_putpages (struct vop_putpages_args *ap)
IN vm_ooffset_t offset;
*/
{
+ struct vnode *vp = ap->a_vp;
+ struct xfs_node *xn = VNODE_TO_XNODE(vp);
+ struct vnode *t = DATA_FROM_XNODE(xn);
+ int error;
+
XFSDEB(XDEBVNOPS, ("xfs_putpages\n"));
-#if HAVE_KERNEL_VNODE_PAGER_GENERIC_PUTPAGES
- return vnode_pager_generic_putpages (ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
-#else
- return EOPNOTSUPP;
-#endif
+ xn->flags |= XFS_DATA_DIRTY;
+
+ return VOP_PUTPAGES(t, ap->a_m, ap->a_count, ap->a_sync, ap->a_rtvals,
+ ap->a_offset);
}
#endif /* HAVE_VOP_PUTPAGES */
@@ -889,19 +992,36 @@ xfs_revoke(void *v)
}
#endif /* HAVE_VOP_REVOKE */
+#ifdef HAVE_VOP_PAGEIN
+static int
+xfs_pagein(struct vop_pagein_args *ap)
+{
+ return (VOP_READ(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred));
+}
+
+#endif
+
+#ifdef HAVE_VOP_PAGEOUT
+static int
+xfs_pageout(struct vop_pageout_args *ap)
+{
+ return (VOP_WRITE(ap->a_vp, ap->a_uio, ap->a_ioflag, ap->a_cred));
+}
+#endif
+
vop_t **xfs_vnodeop_p;
int
-xfs_eopnotsupp (void *v)
+xfs_eopnotsupp (struct vop_generic_args *ap)
{
- XFSDEB(XDEBVNOPS, ("xfs_eopnotsupp\n"));
+ XFSDEB(XDEBVNOPS, ("xfs_eopnotsupp %s\n", ap->a_desc->vdesc_name));
return EOPNOTSUPP;
}
int
-xfs_returnzero (void *v)
+xfs_returnzero (struct vop_generic_args *ap)
{
- XFSDEB(XDEBVNOPS, ("xfs_returnzero\n"));
+ XFSDEB(XDEBVNOPS, ("xfs_returnzero %s\n", ap->a_desc->vdesc_name));
return 0;
}
@@ -1021,6 +1141,12 @@ static struct vnodeopv_entry_desc xfs_vnodeop_entries[] = {
{&vop_advlock_desc, (vop_t *) xfs_advlock },
#endif
#endif
+#ifdef HAVE_VOP_PAGEIN
+ {&vop_pagein_desc, (vop_t *) xfs_pagein },
+#endif
+#ifdef HAVE_VOP_PAGEOUT
+ {&vop_pageout_desc, (vop_t *) xfs_pageout },
+#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 0fae847867d..ed102ad1205 100644
--- a/sys/xfs/xfs_vnodeops-common.c
+++ b/sys/xfs/xfs_vnodeops-common.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: xfs_vnodeops-common.c,v 1.3 2000/03/03 00:54:59 todd Exp $ */
-
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -51,10 +49,11 @@
#include <xfs/xfs_syscalls.h>
#include <xfs/xfs_vnodeops.h>
-RCSID("$OpenBSD: xfs_vnodeops-common.c,v 1.3 2000/03/03 00:54:59 todd Exp $");
+RCSID("$Id: xfs_vnodeops-common.c,v 1.4 2000/09/11 14:26:54 art Exp $");
int
-xfs_open_valid(struct vnode * vp, struct ucred * cred, u_int tok)
+xfs_open_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok)
{
struct xfs *xfsp = XFS_FROM_VNODE(vp);
struct xfs_node *xn = VNODE_TO_XNODE(vp);
@@ -71,7 +70,9 @@ xfs_open_valid(struct vnode * vp, struct ucred * cred, u_int tok)
msg.cred.pag = xfs_get_pag(cred);
msg.handle = xn->handle;
msg.tokens = tok;
+
error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
+
if (error == 0)
error = ((struct xfs_message_wakeup *) & msg)->error;
} else {
@@ -86,12 +87,13 @@ done:
}
int
-xfs_attr_valid(struct vnode * vp, struct ucred * cred, u_int tok)
+xfs_attr_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok)
{
struct xfs *xfsp = XFS_FROM_VNODE(vp);
struct xfs_node *xn = VNODE_TO_XNODE(vp);
int error = 0;
- pag_t pag = xfs_get_pag(cred);
+ xfs_pag_t pag = xfs_get_pag(cred);
do {
if (!XFS_TOKEN_GOT(xn, tok)) {
@@ -114,13 +116,13 @@ done:
}
int
-xfs_fetch_rights(struct vnode * vp, struct ucred * cred)
+xfs_fetch_rights(struct vnode *vp, struct ucred *cred, struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(vp);
struct xfs_node *xn = VNODE_TO_XNODE(vp);
int error = 0;
- pag_t pag = xfs_get_pag(cred);
+ xfs_pag_t pag = xfs_get_pag(cred);
do {
if (!xfs_has_pag(xn, pag)) {
@@ -144,7 +146,8 @@ done:
}
int
-xfs_data_valid(struct vnode * vp, struct ucred * cred, u_int tok)
+xfs_data_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok)
{
struct xfs *xfsp = XFS_FROM_VNODE(vp);
struct xfs_node *xn = VNODE_TO_XNODE(vp);
@@ -159,7 +162,9 @@ xfs_data_valid(struct vnode * vp, struct ucred * cred, u_int tok)
msg.cred.pag = xfs_get_pag(cred);
msg.handle = xn->handle;
msg.tokens = tok;
+
error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
+
if (error == 0)
error = ((struct xfs_message_wakeup *) & msg)->error;
} else {
@@ -171,14 +176,46 @@ done:
return error;
}
+int
+xfs_open_common(struct vnode *vp,
+ int mode,
+ struct ucred *cred,
+ struct proc *p)
+{
+ struct xfs_node *xn = VNODE_TO_XNODE(vp);
+
+ XFSDEB(XDEBVNOPS, ("xfs_open\n"));
+
+ if (mode & FWRITE) {
+ if (xn->cred)
+ crfree (xn->cred);
+ crhold (cred);
+ xn->cred = cred;
+ return xfs_open_valid(vp, cred, p, XFS_OPEN_NW);
+ } else {
+ return xfs_open_valid(vp, cred, p, XFS_OPEN_NR);
+ }
+}
+
static int
-do_fsync(struct xfs * xfsp,
- struct xfs_node * xn,
- struct ucred * cred,
+do_fsync(struct xfs *xfsp,
+ struct xfs_node *xn,
+ struct ucred *cred,
+ struct proc *p,
u_int flag)
{
int error;
struct xfs_message_putdata msg;
+#if 0
+ struct vnode *vp = XNODE_TO_VNODE(xn);
+ struct vnode *t = DATA_FROM_XNODE(xn);
+
+ vinvalbuf (vp, V_SAVE, cred, p, 0, 0);
+
+ xfs_vfs_writelock(t, p);
+ vinvalbuf(t, V_SAVE, cred, p, 0, 0);
+ xfs_vfs_unlock(t, p);
+#endif
msg.header.opcode = XFS_MSG_PUTDATA;
if (cred != NOCRED) {
@@ -193,6 +230,7 @@ do_fsync(struct xfs * xfsp,
msg.flag = flag;
error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
+
if (error == 0)
error = ((struct xfs_message_wakeup *) & msg)->error;
@@ -210,7 +248,7 @@ xfs_fsync_common(struct vnode *vp, struct ucred *cred,
struct xfs_node *xn = VNODE_TO_XNODE(vp);
int error = 0;
- XFSDEB(XDEBVNOPS, ("xfs_fsync: %p\n", vp));
+ XFSDEB(XDEBVNOPS, ("xfs_fsync: %lx\n", (unsigned long)vp));
/*
* It seems that fsync is sometimes called after reclaiming a node.
@@ -222,8 +260,17 @@ xfs_fsync_common(struct vnode *vp, struct ucred *cred,
return 0;
}
- if (xn->flags & XFS_DATA_DIRTY)
- error = do_fsync(xfsp, xn, cred, XFS_WRITE);
+ if (xn->flags & XFS_DATA_DIRTY) {
+#ifdef FSYNC_RECLAIM
+ /* writing back the data from this vnode failed */
+ if (waitfor & FSYNC_RECLAIM) {
+ printf("xfs_fsync: data lost, failed to write back\n");
+ xn->flags &= ~XFS_DATA_DIRTY;
+ return 0;
+ }
+#endif
+ error = do_fsync(xfsp, xn, cred, proc, XFS_WRITE | XFS_FSYNC);
+ }
return error;
}
@@ -236,45 +283,62 @@ xfs_close_common(struct vnode *vp, int fflag,
struct xfs_node *xn = VNODE_TO_XNODE(vp);
int error = 0;
- XFSDEB(XDEBVNOPS, ("xfs_close cred = %p\n", cred));
+ XFSDEB(XDEBVNOPS,
+ ("xfs_close cred = %lx, fflag = %x, xn->flags = %x\n",
+ (unsigned long)cred, fflag, xn->flags));
if (fflag & FWRITE && xn->flags & XFS_DATA_DIRTY)
- error = do_fsync(xfsp, xn, cred, XFS_WRITE);
+ error = do_fsync(xfsp, xn, cred, proc, XFS_WRITE);
return error;
}
int
-xfs_read_common(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
+xfs_read_common(struct vnode *vp, struct uio *uio, int ioflag,
+ struct ucred *cred)
{
int error = 0;
+ int i;
XFSDEB(XDEBVNOPS, ("xfs_read\n"));
- error = xfs_data_valid(vp, cred, XFS_DATA_R);
+ error = xfs_data_valid(vp, cred, xfs_uio_to_proc(uio), XFS_DATA_R);
+
+ XFSDEB(XDEBVNOPS, ("xfs_read: iovcnt: %d\n", uio->uio_iovcnt));
+ for (i = 0; i < uio->uio_iovcnt; i++)
+ XFSDEB(XDEBVNOPS, (" base: %lx len: %d\n",
+ (unsigned long)uio->uio_iov[i].iov_base,
+ uio->uio_iov[i].iov_len));
if (error == 0) {
struct vnode *t = DATA_FROM_VNODE(vp);
xfs_vfs_readlock(t, xfs_uio_to_proc(uio));
-#ifdef __osf__
- VOP_READ(t, uio, ioflag, cred, error);
-#else /* __osf__ */
- error = VOP_READ(t, uio, ioflag, cred);
-#endif /* __osf__ */
+ 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",
+ (unsigned long)uio->uio_offset,
+ uio->uio_resid));
+ XFSDEB(XDEBVNOPS, ("xfs_read error: %d\n", error));
+
return error;
}
int
-xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag, struct ucred *cred)
+xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag,
+ struct ucred *cred)
{
int error = 0;
XFSDEB(XDEBVNOPS, ("xfs_write\n"));
- error = xfs_data_valid(vp, cred, XFS_DATA_W);
+ error = xfs_data_valid(vp, cred, xfs_uio_to_proc(uiop), XFS_DATA_W);
if (error == 0) {
struct xfs_node *xn = VNODE_TO_XNODE(vp);
@@ -283,26 +347,14 @@ xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag, struct ucred *c
int error2 = 0;
xfs_vfs_writelock(t, xfs_uio_to_proc(uiop));
-#ifdef __osf__
- VOP_WRITE(t, uiop, ioflag, cred, error);
- VNODE_TO_XNODE(vp)->flags |= XFS_DATA_DIRTY;
- VOP_GETATTR(t, &sub_attr, cred, error2);
-#else /* __osf__ */
- error = VOP_WRITE(t, uiop, ioflag, cred);
+ xfs_vop_write(t, uiop, ioflag, cred, error);
VNODE_TO_XNODE(vp)->flags |= XFS_DATA_DIRTY;
- error2 = VOP_GETATTR(t, &sub_attr, cred, uiop->uio_procp);
-#endif /* __osf__ */
+ xfs_vop_getattr(t, &sub_attr, cred, xfs_uio_to_proc(uiop), error2);
if (error2 == 0) {
xn->attr.va_size = sub_attr.va_size;
xn->attr.va_mtime = sub_attr.va_mtime;
-#ifdef UVM
- uvm_vnp_setsize(vp, sub_attr.va_size);
-#else
-#ifdef HAVE_KERNEL_VNODE_PAGER_SETSIZE
- vnode_pager_setsize(vp, sub_attr.va_size);
-#endif
-#endif
+ xfs_set_vp_size(vp, sub_attr.va_size);
}
xfs_vfs_unlock(t, xfs_uio_to_proc(uiop));
}
@@ -311,7 +363,8 @@ xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag, struct ucred *c
}
int
-xfs_getattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred)
+xfs_getattr_common(struct vnode *vp, struct vattr *vap,
+ struct ucred *cred, struct proc *p)
{
int error = 0;
@@ -319,14 +372,15 @@ xfs_getattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred)
XFSDEB(XDEBVNOPS, ("xfs_getattr\n"));
- error = xfs_attr_valid(vp, cred, XFS_ATTR_R);
+ error = xfs_attr_valid(vp, cred, p, XFS_ATTR_R);
if (error == 0)
*vap = xn->attr;
return error;
}
int
-xfs_setattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred)
+xfs_setattr_common(struct vnode *vp, struct vattr *vap,
+ struct ucred *cred, struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(vp);
struct xfs_node *xn = VNODE_TO_XNODE(vp);
@@ -336,13 +390,13 @@ xfs_setattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred)
#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,) &&
- CHECK_XFSATTR(va_size,) &&
- CHECK_XFSATTR(va_uid,) &&
- CHECK_XFSATTR(va_gid,) &&
- CHECK_XFSATTR(va_mtime.tv_sec,) &&
- CHECK_XFSATTR(va_fileid,) &&
- CHECK_XFSATTR(va_type,))
+ CHECK_XFSATTR(va_nlink,(short)) &&
+ CHECK_XFSATTR(va_size,(u_quad_t)) &&
+ CHECK_XFSATTR(va_uid,(uid_t)) &&
+ CHECK_XFSATTR(va_gid,(gid_t)) &&
+ CHECK_XFSATTR(va_mtime.tv_sec,(unsigned int)) &&
+ CHECK_XFSATTR(va_fileid,(long)) &&
+ CHECK_XFSATTR(va_type,(enum vtype)))
return 0; /* Nothing to do */
#undef CHECK_XFSATTR
@@ -364,6 +418,18 @@ xfs_setattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred)
}
msg.handle = xn->handle;
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)
+ XA_SET_SIZE(&msg.attr, vap->va_size);
+ else
+ XA_SET_SIZE(&msg.attr, xn->attr.va_size);
+ }
+ if (vap->va_mtime.tv_sec != (unsigned int)VNOVAL)
+ XA_SET_MTIME(&msg.attr, vap->va_mtime.tv_sec);
+ else
+ XA_SET_MTIME(&msg.attr, xn->attr.va_mtime.tv_sec);
+ }
XFS_TOKEN_CLEAR(xn, XFS_ATTR_VALID, XFS_ATTR_MASK);
error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
@@ -393,14 +459,15 @@ check_rights (u_char rights, int mode)
}
int
-xfs_access_common(struct vnode *vp, int mode, struct ucred *cred)
+xfs_access_common(struct vnode *vp, int mode, struct ucred *cred,
+ struct proc *p)
{
int error = 0;
- pag_t pag = xfs_get_pag(cred);
+ xfs_pag_t pag = xfs_get_pag(cred);
XFSDEB(XDEBVNOPS, ("xfs_access mode = 0%o\n", mode));
- error = xfs_attr_valid(vp, cred, XFS_ATTR_R);
+ error = xfs_attr_valid(vp, cred, p, XFS_ATTR_R);
if (error == 0) {
struct xfs_node *xn = VNODE_TO_XNODE(vp);
int i;
@@ -412,7 +479,7 @@ xfs_access_common(struct vnode *vp, int mode, struct ucred *cred)
XFSDEB(XDEBVNOPS, ("xfs_access anonaccess failed\n"));
- xfs_fetch_rights(vp, cred); /* ignore error */
+ xfs_fetch_rights(vp, cred, p); /* ignore error */
error = EACCES; /* default to EACCES if pag isn't in xn->id */
@@ -445,15 +512,15 @@ xfs_lookup_common(struct vnode *dvp,
if (dvp->v_type != VDIR)
return ENOTDIR;
-
- again:
+ if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
+ *vpp = dvp;
+ VREF(*vpp);
+ return 0;
+ }
+
do {
-#ifdef __osf__
- VOP_ACCESS(dvp, VEXEC, cred, error);
-#else
- error = VOP_ACCESS(dvp, VEXEC, cred, xfs_cnp_to_proc(cnp));
-#endif
+ xfs_vop_access(dvp, VEXEC, cred, proc, error);
if (error != 0)
goto done;
@@ -490,14 +557,12 @@ xfs_lookup_common(struct vnode *dvp,
if (error == 0)
error = ((struct xfs_message_wakeup *) & msg)->error;
if(error == ENOENT && cnp->cn_nameiop != CREATE) {
- XFSDEB(XDEBVNOPS, ("xfs_lookup: neg cache %p (%s, %ld)\n",
- dvp,
+ XFSDEB(XDEBVNOPS, ("xfs_lookup: neg cache %lx (%s, %ld)\n",
+ (unsigned long)dvp,
cnp->cn_nameptr, cnp->cn_namelen));
xfs_dnlc_enter (dvp, cnp, NULL);
}
} else if (error == -1) {
- if (xfs_do_vget(*vpp, LK_EXCLUSIVE, xfs_cnp_to_proc(cnp)))
- goto again;
error = 0;
goto done;
}
@@ -508,29 +573,18 @@ done:
}
int
-xfs_lookup_name(struct vnode *dvp,
- const char *name,
- struct proc *proc,
- struct ucred *cred,
- struct vnode **vpp)
-{
- xfs_componentname cn;
-
- xfs_cnp_init (&cn, name, NULL, dvp, proc, cred, CREATE);
- return xfs_lookup_common (dvp, &cn, vpp);
-}
-
-int
xfs_create_common(struct vnode *dvp,
const char *name,
struct vattr *vap,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
int error = 0;
- XFSDEB(XDEBVNOPS, ("xfs_create: (%s)\n", name));
+ XFSDEB(XDEBVNOPS, ("xfs_create: (%lx, %s)\n",
+ (unsigned long)dvp, name));
{
struct xfs_message_create msg;
@@ -548,7 +602,9 @@ xfs_create_common(struct vnode *dvp,
msg.cred.pag = XFS_ANONYMOUSID;
}
+
error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
+
if (error == 0)
error = ((struct xfs_message_wakeup *) & msg)->error;
}
@@ -565,7 +621,8 @@ int
xfs_remove_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
@@ -579,6 +636,7 @@ xfs_remove_common(struct vnode *dvp,
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 (error == 0)
error = ((struct xfs_message_wakeup *) &msg)->error;
@@ -604,7 +662,8 @@ xfs_rename_common(struct vnode *fdvp,
struct vnode *tdvp,
struct vnode *tvp,
const char *tname,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(fdvp);
int error;
@@ -641,7 +700,8 @@ int
xfs_mkdir_common(struct vnode *dvp,
const char *name,
struct vattr *vap,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
@@ -674,7 +734,8 @@ int
xfs_rmdir_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
@@ -703,6 +764,8 @@ xfs_rmdir_common(struct vnode *dvp,
vput(dvp);
#endif
+ XFSDEB(XDEBVNOPS, ("xfs_rmdir error: %d\n", error));
+
return error;
}
@@ -710,6 +773,7 @@ int
xfs_readdir_common(struct vnode *vp,
struct uio *uiop,
struct ucred *cred,
+ struct proc *p,
int *eofflag)
{
int error = 0;
@@ -718,18 +782,20 @@ xfs_readdir_common(struct vnode *vp,
if(eofflag)
*eofflag = 0;
- error = xfs_data_valid(vp, cred, XFS_DATA_R);
+ error = xfs_data_valid(vp, cred, xfs_uio_to_proc(uiop), XFS_DATA_R);
if (error == 0) {
struct vnode *t = DATA_FROM_VNODE(vp);
xfs_vfs_readlock(t, xfs_uio_to_proc(uiop));
-#ifdef __osf__
- VOP_READ(t, uiop, 0, cred, error);
-#else
- error = VOP_READ(t, uiop, 0, cred);
-#endif
- if(eofflag)
- *eofflag = VNODE_TO_XNODE(vp)->attr.va_size <= uiop->uio_offset;
+ xfs_vop_read(t, uiop, 0, cred, error);
+ if (eofflag) {
+ struct vattr t_attr;
+ int error2;
+
+ xfs_vop_getattr(t, &t_attr, cred, xfs_uio_to_proc(uiop), error2);
+ if (error2 == 0)
+ *eofflag = t_attr.va_size <= uiop->uio_offset;
+ }
xfs_vfs_unlock(t, xfs_uio_to_proc(uiop));
}
return error;
@@ -739,7 +805,8 @@ int
xfs_link_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred)
+ struct ucred *cred,
+ struct proc *p)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
@@ -766,15 +833,16 @@ xfs_link_common(struct vnode *dvp,
int
xfs_symlink_common(struct vnode *dvp,
struct vnode **vpp,
- const char *name,
- struct proc *proc,
- struct ucred *cred,
+ xfs_componentname *cnp,
struct vattr *vap,
char *target)
{
struct xfs *xfsp = XFS_FROM_VNODE(dvp);
struct xfs_node *xn = VNODE_TO_XNODE(dvp);
+ struct proc *proc = xfs_cnp_to_proc(cnp);
+ struct ucred *cred = xfs_proc_to_cred(proc);
struct xfs_message_symlink msg;
+ const char *name = cnp->cn_nameptr;
int error = 0;
XFSDEB(XDEBVNOPS, ("xfs_symlink: %s\n", name));
@@ -794,12 +862,14 @@ xfs_symlink_common(struct vnode *dvp,
error = ((struct xfs_message_wakeup *) & msg)->error;
if (error == 0) {
- error = xfs_lookup_name(dvp, name, proc, cred, vpp);
+ error = xfs_lookup_common(dvp, cnp, vpp);
+#if !defined(__FreeBSD__) || __FreeBSD_version < 400012
if (error == 0)
vput (*vpp);
+#endif
}
-#if !defined(__FreeBSD__) || __FreeBSD_version < 300000
+#if !defined(__FreeBSD__)
vput(dvp);
#endif
@@ -813,16 +883,12 @@ xfs_readlink_common(struct vnode *vp, struct uio *uiop, struct ucred *cred)
XFSDEB(XDEBVNOPS, ("xfs_readlink\n"));
- error = xfs_data_valid(vp, cred, XFS_DATA_R);
+ error = xfs_data_valid(vp, cred, xfs_uio_to_proc(uiop), XFS_DATA_R);
if (error == 0) {
struct vnode *t = DATA_FROM_VNODE(vp);
xfs_vfs_readlock(t, xfs_uio_to_proc(uiop));
-#ifdef __osf__
- VOP_READ(t, uiop, 0, cred, error);
-#else
- error = VOP_READ(t, uiop, 0, cred);
-#endif
+ xfs_vop_read(t, uiop, 0, cred, error);
xfs_vfs_unlock(t, xfs_uio_to_proc(uiop));
}
return error;
@@ -831,11 +897,11 @@ xfs_readlink_common(struct vnode *vp, struct uio *uiop, struct ucred *cred)
int
xfs_inactive_common(struct vnode *vp, struct proc *p)
{
- struct xfs_message_inactivenode msg;
- struct xfs *xfsp = XFS_FROM_VNODE(vp);
+ int error;
struct xfs_node *xn = VNODE_TO_XNODE(vp);
- XFSDEB(XDEBVNOPS, ("xfs_inactive, %p\n", vp));
+ XFSDEB(XDEBVNOPS, ("xfs_inactive, %lx\n",
+ (unsigned long)vp));
/*
* This seems rather bogus, but sometimes we get an already
@@ -847,14 +913,20 @@ xfs_inactive_common(struct vnode *vp, struct proc *p)
return 0;
}
- xn->tokens = 0;
- msg.header.opcode = XFS_MSG_INACTIVENODE;
- msg.handle = xn->handle;
- msg.flag = XFS_NOREFS;
- xfs_message_send(xfsp->fd, &msg.header, sizeof(msg));
+ /* xn->cred not set -> NOCRED */
+
+ error = xfs_fsync_common(vp, xn->cred, /* XXX */ 0, p);
+ if (error) {
+ printf ("xfs_inactive: failed writing back data: %d\n", error);
+ }
#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)) {
+ XFSDEB(XDEBVNOPS, ("xfs_inactive: vrecycle\n"));
+ vrecycle(vp, 0, p);
+ }
#else
/* XXX ? */
#endif
@@ -871,7 +943,18 @@ 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: %p\n", vp));
+ XFSDEB(XDEBVNOPS, ("xfs_reclaim: %lx",
+ (unsigned long)vp));
+
+ XFS_TOKEN_CLEAR(xn,
+ ~0,
+ XFS_OPEN_MASK | XFS_ATTR_MASK |
+ XFS_DATA_MASK | XFS_LOCK_MASK);
+ /* Release, data if we still have it. */
+ if (DATA_FROM_XNODE(xn) != 0) {
+ vrele(DATA_FROM_XNODE(xn));
+ DATA_FROM_XNODE(xn) = 0;
+ }
msg.header.opcode = XFS_MSG_INACTIVENODE;
msg.handle = xn->handle;
@@ -880,7 +963,6 @@ xfs_reclaim_common(struct vnode *vp)
xfs_dnlc_purge(vp);
free_xfs_node(xn);
-
return 0;
}
diff --git a/sys/xfs/xfs_vnodeops.h b/sys/xfs/xfs_vnodeops.h
index 1838fd388f8..7848ca28a54 100644
--- a/sys/xfs/xfs_vnodeops.h
+++ b/sys/xfs/xfs_vnodeops.h
@@ -1,6 +1,5 @@
-/* $OpenBSD: xfs_vnodeops.h,v 1.2 2000/03/03 00:54:59 todd Exp $ */
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -37,6 +36,7 @@
* SUCH DAMAGE.
*/
+/* $Id: xfs_vnodeops.h,v 1.3 2000/09/11 14:26:54 art Exp $ */
#ifndef _xfs_vnodeops_h
#define _xfs_vnodeops_h
@@ -53,37 +53,60 @@
#define xfs_vfs_writelock(vp, proc) VREF((vp))
#define xfs_vfs_unlock(vp, proc) vrele((vp))
+/* XXX - should this do anything? */
+
+#define xfs_vfs_vn_lock(vp, flags, proc) (0)
+
#elif defined(HAVE_TWO_ARGUMENT_VOP_LOCK)
#define xfs_vfs_readlock(vp, proc) vn_lock((vp), LK_SHARED | LK_RETRY)
#define xfs_vfs_writelock(vp, proc) vn_lock((vp), LK_EXCLUSIVE | LK_RETRY)
#define xfs_vfs_unlock(vp, proc) VOP_UNLOCK((vp), 0)
+#define xfs_vfs_vn_lock(vp, flags, proc) vn_lock((vp), (flags))
#elif defined(HAVE_THREE_ARGUMENT_VOP_LOCK)
#define xfs_vfs_readlock(vp, proc) vn_lock((vp), LK_SHARED | LK_RETRY, (proc))
#define xfs_vfs_writelock(vp, proc) vn_lock((vp), LK_EXCLUSIVE | LK_RETRY, (proc))
#define xfs_vfs_unlock(vp, proc) VOP_UNLOCK((vp), 0, (proc))
+#define xfs_vfs_vn_lock(vp, flags, proc) vn_lock((vp), (flags), (proc))
-#else
+#elif defined(HAVE_ONE_ARGUMENT_VOP_LOCK)
#define xfs_vfs_readlock(vp, proc) VOP_LOCK((vp))
#define xfs_vfs_writelock(vp, proc) VOP_LOCK((vp))
#define xfs_vfs_unlock(vp, proc) VOP_UNLOCK((vp))
+/* XXX - should this do anything? */
+
+#define xfs_vfs_vn_lock(vp, flags, proc) (0)
+
+#else
+
+#error what kind of VOP_LOCK?
+
#endif
int
-xfs_open_valid(struct vnode * vp, struct ucred * cred, u_int tok);
+xfs_open_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok);
int
-xfs_attr_valid(struct vnode * vp, struct ucred * cred, u_int tok);
+xfs_attr_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok);
int
-xfs_fetch_rights(struct vnode * vp, struct ucred * cred);
+xfs_fetch_rights(struct vnode *vp, struct ucred *cred, struct proc *p);
int
-xfs_data_valid(struct vnode * vp, struct ucred * cred, u_int tok);
+xfs_data_valid(struct vnode *vp, struct ucred *cred, struct proc *p,
+ u_int tok);
+
+int
+xfs_open_common(struct vnode *vp,
+ int mode,
+ struct ucred *cred,
+ struct proc *p);
int
xfs_fsync_common(struct vnode *vp, struct ucred *cred,
@@ -94,19 +117,24 @@ xfs_close_common(struct vnode *vp, int fflag,
struct proc *proc, struct ucred *cred);
int
-xfs_read_common(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred);
+xfs_read_common(struct vnode *vp, struct uio *uio, int ioflag,
+ struct ucred *cred);
int
-xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag, struct ucred *cred);
+xfs_write_common(struct vnode *vp, struct uio *uiop, int ioflag,
+ struct ucred *cred);
int
-xfs_getattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred);
+xfs_getattr_common(struct vnode *vp, struct vattr *vap,
+ struct ucred *cred, struct proc *p);
int
-xfs_setattr_common(struct vnode *vp, struct vattr *vap, struct ucred *cred);
+xfs_setattr_common(struct vnode *vp, struct vattr *vap,
+ struct ucred *cred, struct proc *p);
int
-xfs_access_common(struct vnode *vp, int mode, struct ucred *cred);
+xfs_access_common(struct vnode *vp, int mode,
+ struct ucred *cred, struct proc *p);
int
xfs_lookup_common(struct vnode *dvp,
@@ -114,23 +142,18 @@ xfs_lookup_common(struct vnode *dvp,
struct vnode **vpp);
int
-xfs_lookup_name(struct vnode *dvp,
- const char *name,
- struct proc *proc,
- struct ucred *cred,
- struct vnode **vpp);
-
-int
xfs_create_common(struct vnode *dvp,
const char *name,
struct vattr *vap,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_remove_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_rename_common(struct vnode *fdvp,
@@ -139,38 +162,41 @@ xfs_rename_common(struct vnode *fdvp,
struct vnode *tdvp,
struct vnode *tvp,
const char *tname,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_mkdir_common(struct vnode *dvp,
const char *name,
struct vattr *vap,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_rmdir_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_readdir_common(struct vnode *vp,
struct uio *uiop,
struct ucred *cred,
+ struct proc *p,
int *eofflag);
int
xfs_link_common(struct vnode *dvp,
struct vnode *vp,
const char *name,
- struct ucred *cred);
+ struct ucred *cred,
+ struct proc *p);
int
xfs_symlink_common(struct vnode *dvp,
struct vnode **vpp,
- const char *name,
- struct proc *proc,
- struct ucred *cred,
+ xfs_componentname *cnp,
struct vattr *vap,
char *target);
@@ -184,10 +210,10 @@ int
xfs_reclaim_common(struct vnode *vp);
int
-xfs_eopnotsupp (void *);
+xfs_eopnotsupp (struct vop_generic_args *ap);
int
-xfs_returnzero (void *v);
+xfs_returnzero (struct vop_generic_args *ap);
void
xfs_printnode_common (struct vnode *vp);
diff --git a/sys/xfs/xfs_vopdefs.h b/sys/xfs/xfs_vopdefs.h
index f0c3d2706ec..a094f511f99 100644
--- a/sys/xfs/xfs_vopdefs.h
+++ b/sys/xfs/xfs_vopdefs.h
@@ -41,3 +41,5 @@
#define HAVE_VOP_TRUNCATE 1
#define HAVE_VOP_UPDATE 1
#define HAVE_VOP_WHITEOUT 1
+#define HAVE_VOP_STRATEGY 1
+#define HAVE_VOP_BWRITE 1