devicename.c (329145) | devicename.c (332154) |
---|---|
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: stable/11/stand/uboot/lib/devicename.c 240273 2012-09-09 11:32:06Z ae $"); | 28__FBSDID("$FreeBSD: stable/11/stand/uboot/lib/devicename.c 332154 2018-04-06 21:37:25Z kevans $"); |
29 30#include <stand.h> 31#include <string.h> 32 33#include "bootstrap.h" 34#include "disk.h" 35#include "libuboot.h" 36 --- 94 unchanged lines hidden (view full) --- 131 err = EUNIT; 132 goto fail; 133 } 134 } 135 if (*cp && (*cp != ':')) { 136 err = EINVAL; 137 goto fail; 138 } | 29 30#include <stand.h> 31#include <string.h> 32 33#include "bootstrap.h" 34#include "disk.h" 35#include "libuboot.h" 36 --- 94 unchanged lines hidden (view full) --- 131 err = EUNIT; 132 goto fail; 133 } 134 } 135 if (*cp && (*cp != ':')) { 136 err = EINVAL; 137 goto fail; 138 } |
139 idev->d_unit = unit; | 139 idev->dd.d_unit = unit; |
140 141 if (path != NULL) 142 *path = (*cp == 0) ? cp : cp + 1; 143 break; 144 145 default: 146 err = EINVAL; 147 goto fail; 148 } | 140 141 if (path != NULL) 142 *path = (*cp == 0) ? cp : cp + 1; 143 break; 144 145 default: 146 err = EINVAL; 147 goto fail; 148 } |
149 idev->d_dev = dv; 150 idev->d_type = dv->dv_type; | 149 idev->dd.d_dev = dv; |
151 if (dev == NULL) { 152 free(idev); 153 } else { 154 *dev = idev; 155 } 156 return (0); 157 158fail: 159 free(idev); 160 return (err); 161} 162 163 164char * 165uboot_fmtdev(void *vdev) 166{ 167 struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; 168 static char buf[128]; 169 | 150 if (dev == NULL) { 151 free(idev); 152 } else { 153 *dev = idev; 154 } 155 return (0); 156 157fail: 158 free(idev); 159 return (err); 160} 161 162 163char * 164uboot_fmtdev(void *vdev) 165{ 166 struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; 167 static char buf[128]; 168 |
170 switch(dev->d_type) { | 169 switch(dev->dd.d_dev->dv_type) { |
171 case DEVT_NONE: 172 strcpy(buf, "(no device)"); 173 break; 174 175 case DEVT_DISK: 176#ifdef LOADER_DISK_SUPPORT 177 return (disk_fmtdev(vdev)); 178#endif 179 180 case DEVT_NET: | 170 case DEVT_NONE: 171 strcpy(buf, "(no device)"); 172 break; 173 174 case DEVT_DISK: 175#ifdef LOADER_DISK_SUPPORT 176 return (disk_fmtdev(vdev)); 177#endif 178 179 case DEVT_NET: |
181 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | 180 sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); |
182 break; 183 } 184 return(buf); 185} 186 187/* 188 * Set currdev to suit the value being supplied in (value). 189 */ --- 12 unchanged lines hidden --- | 181 break; 182 } 183 return(buf); 184} 185 186/* 187 * Set currdev to suit the value being supplied in (value). 188 */ --- 12 unchanged lines hidden --- |