summaryrefslogtreecommitdiff
path: root/sys/xfs/xfs_common-bsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/xfs/xfs_common-bsd.c')
-rw-r--r--sys/xfs/xfs_common-bsd.c66
1 files changed, 59 insertions, 7 deletions
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 */