dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / psm / promif / ieee1275 / common / prom_devname.c
blob32023c54845eec9f4935d46087c370eb5a47b8a3
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1991-1994, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
32 int
33 prom_devname_from_pathname(register char *pathname, register char *buffer)
35 register char *p;
37 if ((pathname == NULL) || (*pathname == '\0'))
38 return (-1);
40 p = prom_strrchr(pathname, '/');
41 if (p == 0)
42 return (-1);
44 p++;
45 while (*p != 0) {
46 *buffer++ = *p++;
47 if ((*p == '@') || (*p == ':'))
48 break;
50 *buffer = '\0';
52 return (0);
56 * Get base device name of stdin/stdout device into callers buffer.
57 * Return 0 if successful; -1 otherwise.
60 int
61 prom_stdin_devname(char *buffer)
63 return (prom_devname_from_pathname(prom_stdinpath(), buffer));
66 int
67 prom_stdout_devname(char *buffer)
69 return (prom_devname_from_pathname(prom_stdoutpath(), buffer));
73 * Return 1 if stdin/stdout are on the same device and subdevice.
74 * Return 0, otherwise.
77 int
78 prom_stdin_stdout_equivalence(void)
80 register char *s, *p;
82 s = prom_stdinpath();
83 p = prom_stdoutpath();
85 if ((s != NULL) && (p != NULL)) {
86 return (prom_strcmp(s, p) == 0 ? 1:0);
89 return (0);
93 * This just returns a pointer to the option's part of the
94 * last part of the string. Useful for determining which is
95 * the boot partition, tape file or channel of the DUART.
97 char *
98 prom_path_options(register char *path)
100 register char *p, *s;
102 s = prom_strrchr(path, '/');
103 if (s == NULL)
104 return (NULL);
105 p = prom_strrchr(s, ':');
106 if (p == NULL)
107 return (NULL);
108 return (p+1);