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/userboot/userboot/devicename.c 269741 2014-08-08 21:47:47Z sbruno $"); | 28__FBSDID("$FreeBSD: stable/11/stand/userboot/userboot/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 "libuserboot.h" 36 --- 97 unchanged lines hidden (view full) --- 134 } else { 135 cp = np; 136 } 137 if (*cp && (*cp != ':')) { 138 err = EINVAL; 139 goto fail; 140 } 141 | 29 30#include <stand.h> 31#include <string.h> 32 33#include "bootstrap.h" 34#include "disk.h" 35#include "libuserboot.h" 36 --- 97 unchanged lines hidden (view full) --- 134 } else { 135 cp = np; 136 } 137 if (*cp && (*cp != ':')) { 138 err = EINVAL; 139 goto fail; 140 } 141 |
142 idev->d_unit = unit; | 142 idev->dd.d_unit = unit; |
143 if (path != NULL) 144 *path = (*cp == 0) ? cp : cp + 1; 145 break; 146 147 case DEVT_ZFS: 148#if defined(USERBOOT_ZFS_SUPPORT) 149 err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); 150 if (err != 0) 151 goto fail; 152 break; 153#else 154 /* FALLTHROUGH */ 155#endif 156 157 default: 158 err = EINVAL; 159 goto fail; 160 } | 143 if (path != NULL) 144 *path = (*cp == 0) ? cp : cp + 1; 145 break; 146 147 case DEVT_ZFS: 148#if defined(USERBOOT_ZFS_SUPPORT) 149 err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); 150 if (err != 0) 151 goto fail; 152 break; 153#else 154 /* FALLTHROUGH */ 155#endif 156 157 default: 158 err = EINVAL; 159 goto fail; 160 } |
161 idev->d_dev = dv; 162 idev->d_type = dv->dv_type; | 161 idev->dd.d_dev = dv; |
163 if (dev == NULL) { 164 free(idev); 165 } else { 166 *dev = idev; 167 } 168 return(0); 169 170 fail: 171 free(idev); 172 return(err); 173} 174 175 176char * 177userboot_fmtdev(void *vdev) 178{ 179 struct disk_devdesc *dev = (struct disk_devdesc *)vdev; 180 static char buf[128]; /* XXX device length constant? */ 181 | 162 if (dev == NULL) { 163 free(idev); 164 } else { 165 *dev = idev; 166 } 167 return(0); 168 169 fail: 170 free(idev); 171 return(err); 172} 173 174 175char * 176userboot_fmtdev(void *vdev) 177{ 178 struct disk_devdesc *dev = (struct disk_devdesc *)vdev; 179 static char buf[128]; /* XXX device length constant? */ 180 |
182 switch(dev->d_type) { | 181 switch(dev->dd.d_dev->dv_type) { |
183 case DEVT_NONE: 184 strcpy(buf, "(no device)"); 185 break; 186 187 case DEVT_CD: | 182 case DEVT_NONE: 183 strcpy(buf, "(no device)"); 184 break; 185 186 case DEVT_CD: |
188 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | 187 sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); |
189 break; 190 191 case DEVT_DISK: 192 return (disk_fmtdev(vdev)); 193 194 case DEVT_NET: | 188 break; 189 190 case DEVT_DISK: 191 return (disk_fmtdev(vdev)); 192 193 case DEVT_NET: |
195 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | 194 sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); |
196 break; 197 198 case DEVT_ZFS: 199#if defined(USERBOOT_ZFS_SUPPORT) 200 return (zfs_fmtdev(vdev)); 201#else | 195 break; 196 197 case DEVT_ZFS: 198#if defined(USERBOOT_ZFS_SUPPORT) 199 return (zfs_fmtdev(vdev)); 200#else |
202 sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | 201 sprintf(buf, "%s%d:", dev->dd.d_dev->dv_name, dev->dd.d_unit); |
203#endif 204 break; 205 } 206 return(buf); 207} 208 209 210/* --- 14 unchanged lines hidden --- | 202#endif 203 break; 204 } 205 return(buf); 206} 207 208 209/* --- 14 unchanged lines hidden --- |