Deleted Added
full compact
devicename.c (163897) devicename.c (172940)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/devicename.c 163897 2006-11-02 01:23:18Z marcel $");
28__FBSDID("$FreeBSD: head/sys/boot/i386/libi386/devicename.c 172940 2007-10-24 21:33:00Z jhb $");
29
30#include <stand.h>
31#include <string.h>
32#include <sys/disklabel.h>
33#include "bootstrap.h"
34#include "libi386.h"
35
36static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path);

--- 78 unchanged lines hidden (view full) ---

115 slice = -1;
116 partition = -1;
117 if (*np && (*np != ':')) {
118 unit = strtol(np, &cp, 10); /* next comes the unit number */
119 if (cp == np) {
120 err = EUNIT;
121 goto fail;
122 }
29
30#include <stand.h>
31#include <string.h>
32#include <sys/disklabel.h>
33#include "bootstrap.h"
34#include "libi386.h"
35
36static int i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path);

--- 78 unchanged lines hidden (view full) ---

115 slice = -1;
116 partition = -1;
117 if (*np && (*np != ':')) {
118 unit = strtol(np, &cp, 10); /* next comes the unit number */
119 if (cp == np) {
120 err = EUNIT;
121 goto fail;
122 }
123 if (*cp == 's') { /* got a slice number */
123 if (*cp == 'p') { /* got a GPT partition */
124 np = cp + 1;
125 slice = strtol(np, &cp, 10);
126 if (cp == np) {
127 err = ESLICE;
128 goto fail;
129 }
124 np = cp + 1;
125 slice = strtol(np, &cp, 10);
126 if (cp == np) {
127 err = ESLICE;
128 goto fail;
129 }
130 }
131 if (*cp && (*cp != ':')) {
132 partition = *cp - 'a'; /* get a partition number */
133 if ((partition < 0) || (partition >= MAXPARTITIONS)) {
134 err = EPART;
130 if (*cp && (*cp != ':')) {
131 err = EINVAL;
135 goto fail;
136 }
132 goto fail;
133 }
137 cp++;
134 partition = 0xff;
135 } else {
136 if (*cp == 's') { /* got a slice number */
137 np = cp + 1;
138 slice = strtol(np, &cp, 10);
139 if (cp == np) {
140 err = ESLICE;
141 goto fail;
142 }
143 }
144 if (*cp && (*cp != ':')) {
145 partition = *cp - 'a'; /* got a partition number */
146 if ((partition < 0) || (partition >= MAXPARTITIONS)) {
147 err = EPART;
148 goto fail;
149 }
150 cp++;
151 }
138 }
139 }
140 if (*cp && (*cp != ':')) {
141 err = EINVAL;
142 goto fail;
143 }
144
145 idev->d_unit = unit;

--- 57 unchanged lines hidden (view full) ---

203
204 case DEVT_CD:
205 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
206 break;
207
208 case DEVT_DISK:
209 cp = buf;
210 cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
152 }
153 }
154 if (*cp && (*cp != ':')) {
155 err = EINVAL;
156 goto fail;
157 }
158
159 idev->d_unit = unit;

--- 57 unchanged lines hidden (view full) ---

217
218 case DEVT_CD:
219 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
220 break;
221
222 case DEVT_DISK:
223 cp = buf;
224 cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit);
211 if (dev->d_kind.biosdisk.slice > 0)
212 cp += sprintf(cp, "s%d", dev->d_kind.biosdisk.slice);
213 if (dev->d_kind.biosdisk.partition >= 0)
214 cp += sprintf(cp, "%c", dev->d_kind.biosdisk.partition + 'a');
225 if (dev->d_kind.biosdisk.partition == 0xff) {
226 cp += sprintf(cp, "p%d", dev->d_kind.biosdisk.slice);
227 } else {
228 if (dev->d_kind.biosdisk.slice > 0)
229 cp += sprintf(cp, "s%d", dev->d_kind.biosdisk.slice);
230 if (dev->d_kind.biosdisk.partition >= 0)
231 cp += sprintf(cp, "%c", dev->d_kind.biosdisk.partition + 'a');
232 }
215 strcat(cp, ":");
216 break;
217
218 case DEVT_NET:
219 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
220 break;
221 }
222 return(buf);

--- 10 unchanged lines hidden (view full) ---

233 int rv;
234
235 if ((rv = i386_parsedev(&ncurr, value, NULL)) != 0)
236 return(rv);
237 free(ncurr);
238 env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
239 return(0);
240}
233 strcat(cp, ":");
234 break;
235
236 case DEVT_NET:
237 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
238 break;
239 }
240 return(buf);

--- 10 unchanged lines hidden (view full) ---

251 int rv;
252
253 if ((rv = i386_parsedev(&ncurr, value, NULL)) != 0)
254 return(rv);
255 free(ncurr);
256 env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
257 return(0);
258}
241