This source file includes following definitions.
- xfs_alloc
- xfs_free
- xfs_suser
- xfs_devtoname_r
- xfs_devtoname_r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
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
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
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