[BACK]Return to xfs_common-bsd.c CVS log [TXT][DIR] Up to [local] / sys / xfs

Annotation of sys/xfs/xfs_common-bsd.c, Revision 1.1.1.1

1.1       nbrk        1: /*
                      2:  * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan
                      3:  * (Royal Institute of Technology, Stockholm, Sweden).
                      4:  * All rights reserved.
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  *
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  *
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  *
                     17:  * 3. Neither the name of the Institute nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  */
                     33:
                     34: #include <xfs/xfs_locl.h>
                     35: #include <xfs/xfs_common.h>
                     36: #include <xfs/xfs_deb.h>
                     37:
                     38: RCSID("$arla: xfs_common-bsd.c,v 1.25 2002/12/18 16:32:03 lha Exp $");
                     39:
                     40: #ifdef MALLOC_DEFINE
                     41: MALLOC_DEFINE(M_NNPFS, "xfs-misc", "xfs misc");
                     42: MALLOC_DEFINE(M_NNPFS_NODE, "xfs-node", "xfs node");
                     43: MALLOC_DEFINE(M_NNPFS_LINK, "xfs-link", "xfs link");
                     44: MALLOC_DEFINE(M_NNPFS_MSG, "xfs-msg", "xfs msg");
                     45: #endif
                     46:
                     47: #ifdef NNPFS_DEBUG
                     48: static u_int xfs_allocs;
                     49: static u_int xfs_frees;
                     50:
                     51: void *
                     52: xfs_alloc(u_int size, xfs_malloc_type type)
                     53: {
                     54:     void *ret;
                     55:
                     56:     xfs_allocs++;
                     57:     NNPFSDEB(XDEBMEM, ("xfs_alloc: xfs_allocs - xfs_frees %d\n",
                     58:                     xfs_allocs - xfs_frees));
                     59:
                     60:     MALLOC(ret, void *, size, type, M_WAITOK);
                     61:     return ret;
                     62: }
                     63:
                     64: void
                     65: xfs_free(void *ptr, u_int size, xfs_malloc_type type)
                     66: {
                     67:     xfs_frees++;
                     68:     FREE(ptr, type);
                     69: }
                     70:
                     71: #endif /* NNPFS_DEBUG */
                     72:
                     73: int
                     74: xfs_suser(d_thread_t *p)
                     75: {
                     76: #if defined(HAVE_TWO_ARGUMENT_SUSER)
                     77: #ifdef __OpenBSD__
                     78:     return suser (p, SUSER_NOACCT);
                     79: #else
                     80:     return suser (xfs_proc_to_cred(p), NULL);
                     81: #endif
                     82: #else
                     83:     return suser (p);
                     84: #endif
                     85: }
                     86:
                     87: /*
                     88:  * Print a `dev_t' in some readable format
                     89:  */
                     90:
                     91: #ifdef HAVE_KERNEL_DEVTONAME
                     92:
                     93: const char *
                     94: xfs_devtoname_r (dev_t dev, char *buf, size_t sz)
                     95: {
                     96:     return devtoname (dev);
                     97: }
                     98:
                     99: #else /* !HAVE_KERNEL_DEVTONAME */
                    100:
                    101: const char *
                    102: xfs_devtoname_r (dev_t dev, char *buf, size_t sz)
                    103: {
                    104: #ifdef HAVE_KERNEL_SNPRINTF
                    105:     snprintf (buf, sz, "%u/%u", major(dev), minor(dev));
                    106:     return buf;
                    107: #else
                    108:     return "<unknown device>";
                    109: #endif
                    110: }
                    111:
                    112: #endif /* HAVE_KERNEL_DEVTONAME */

CVSweb