2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Implementation of miscellaneous Irix routines.
13 #include <afsconfig.h>
14 #include "afs/param.h"
18 #include "afs/sysincludes.h" /* Standard vendor system headers */
19 #include "afsincludes.h" /* Afs-based standard headers */
20 #include "afs/afs_stats.h" /* statistics */
26 * various special purpose routines
29 afs_mpservice(void *a)
34 * make a semaphore name for use in <sys/sema.h>-type routines on
37 * \param[out] sname will contain the semaphore name and
38 * should point to an allocated string
39 * buffer of size METER_NAMSZ
40 * \param[in] prefix string with which to start the name
41 * \param[in] v_number vnode number to complete the name
43 * \post sname will point to the beginning of a NULL-terminated
44 * string to be used as a semaphore name with a maximum of
45 * (METER_NAMSZ-1) characters plus the NULL. The name is a
46 * concatenation of the string at 'prefix' and the ASCII
47 * representation of the number in 'v_number'. sname is
50 * \note Due to IRIX's use of uint64_t to represent vnumber_t and a
51 * maximum semaphore name length of 15 (METER_NAMSZ-1), this
52 * function cannot be guaranteed to produce a name which
53 * uniquely describes a vnode.
57 makesname(char *sname, const char *prefix, vnumber_t v_number)
59 char vnbuf[21]; /* max number of uint64 decimal digits + 1 */
64 * Note: IRIX doesn't have realloc() available in the
65 * kernel, so the openafs util implementation of snprintf is
66 * not usable. What follows is intended to reproduce the
68 * snprintf(sname, METER_NAMSZ, "%s%llu", prefix,
69 * (unsigned long long)v_number);
70 * Additionally, the kernel only provides a void sprintf(),
71 * making length checking slightly more difficult.
73 prlen = strlen(prefix);
74 if (prlen > METER_NAMSZ-1)
75 prlen = METER_NAMSZ-1;
76 strncpy(sname, prefix, prlen);
78 memset(vnbuf, 0, sizeof(vnbuf));
79 sprintf(vnbuf, "%llu", (unsigned long long)v_number);
80 vnlen = strlen(vnbuf);
81 if (vnlen+prlen > METER_NAMSZ-1)
82 vnlen = METER_NAMSZ-1-prlen;
84 strncpy(&(sname[prlen]), vnbuf, vnlen);
85 sname[vnlen+prlen] = '\0';
90 #ifdef AFS_SGI_VNODE_GLUE
91 #include <sys/invent.h>
92 extern mutex_t afs_init_kern_lock;
94 /* afs_init_kernel_config
96 * initialize vnode glue layer by testing for NUMA.
98 * 0 = no numa, 1 = has numa, -1 = test for numa.
101 afs_init_kernel_config(int flag)
103 static int afs_kern_inited = 0;
106 mutex_enter(&afs_init_kern_lock);
107 if (!afs_kern_inited) {
112 /* test for numa arch. */
113 /* Determine if thisis a NUMA platform. Currently, this is true
114 * only if it's an IP27 or IP35.
117 find_inventory((inventory_t *) NULL, INV_PROCESSOR,
118 INV_CPUBOARD, -1, -1, -1);
122 afs_is_numa_arch = ((pinv->inv_state == INV_IP27BOARD)
123 || (pinv->inv_state == INV_IP35BOARD))
126 afs_is_numa_arch = flag;
128 mutex_exit(&afs_init_kern_lock);
131 #endif /* AFS_SGI_VNODE_GLUE */
133 /* And just so we know what someone is _really_ running */
157 #endif /* AFS_SGI62_ENV */