biosdisk.c (313355) | biosdisk.c (328889) |
---|---|
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/sys/boot/pc98/libpc98/biosdisk.c 313355 2017-02-06 22:03:07Z tsoome $"); | 28__FBSDID("$FreeBSD: stable/11/sys/boot/pc98/libpc98/biosdisk.c 328889 2018-02-05 17:01:18Z kevans $"); |
29 30/* 31 * BIOS disk device handling. 32 * 33 * Ideas and algorithms from: 34 * 35 * - NetBSD libi386/biosdisk.c 36 * - FreeBSD biosboot/disk.c --- 81 unchanged lines hidden (view full) --- 118 119static int bd_init(void); 120static int bd_strategy(void *devdata, int flag, daddr_t dblk, 121 size_t size, char *buf, size_t *rsize); 122static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, 123 size_t size, char *buf, size_t *rsize); 124static int bd_open(struct open_file *f, ...); 125static int bd_close(struct open_file *f); | 29 30/* 31 * BIOS disk device handling. 32 * 33 * Ideas and algorithms from: 34 * 35 * - NetBSD libi386/biosdisk.c 36 * - FreeBSD biosboot/disk.c --- 81 unchanged lines hidden (view full) --- 118 119static int bd_init(void); 120static int bd_strategy(void *devdata, int flag, daddr_t dblk, 121 size_t size, char *buf, size_t *rsize); 122static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, 123 size_t size, char *buf, size_t *rsize); 124static int bd_open(struct open_file *f, ...); 125static int bd_close(struct open_file *f); |
126static void bd_print(int verbose); | 126static int bd_print(int verbose); |
127 128struct devsw biosdisk = { 129 "disk", 130 DEVT_DISK, 131 bd_init, 132 bd_strategy, 133 bd_open, 134 bd_close, --- 109 unchanged lines hidden (view full) --- 244 } 245 } 246 return(0); 247} 248 249/* 250 * Print information about disks 251 */ | 127 128struct devsw biosdisk = { 129 "disk", 130 DEVT_DISK, 131 bd_init, 132 bd_strategy, 133 bd_open, 134 bd_close, --- 109 unchanged lines hidden (view full) --- 244 } 245 } 246 return(0); 247} 248 249/* 250 * Print information about disks 251 */ |
252static void | 252static int |
253bd_print(int verbose) 254{ | 253bd_print(int verbose) 254{ |
255 int i, j, done; | 255 int i, j, ret = 0; |
256 char line[80]; 257 struct i386_devdesc dev; 258 struct open_disk *od; 259 struct pc98_partition *dptr; 260 | 256 char line[80]; 257 struct i386_devdesc dev; 258 struct open_disk *od; 259 struct pc98_partition *dptr; 260 |
261 pager_open(); 262 done = 0; 263 for (i = 0; i < nbdinfo && !done; i++) { 264 sprintf(line, " disk%d: BIOS drive %c:\n", i, 'A' + i); 265 if (pager_output(line)) 266 break; | 261 if (nbdinfo == 0) 262 return (0); |
267 | 263 |
264 printf("%s devices:", biosdisk.dv_name); 265 if ((ret = pager_output("\n")) != 0) 266 return (ret); 267 268 for (i = 0; i < nbdinfo; i++) { 269 snprintf(line, sizeof(line), " disk%d: BIOS drive %c:\n", 270 i, 'A' + i); 271 if ((ret = pager_output(line)) != 0) 272 break; 273 |
|
268 /* try to open the whole disk */ 269 dev.d_unit = i; 270 dev.d_kind.biosdisk.slice = -1; 271 dev.d_kind.biosdisk.partition = -1; 272 273 if (!bd_opendisk(&od, &dev)) { 274 275 /* Do we have a partition table? */ 276 if (od->od_flags & BD_PARTTABOK) { 277 dptr = &od->od_slicetab[0]; 278 279 /* Check for a "dedicated" disk */ 280 for (j = 0; j < od->od_nslices; j++) { | 274 /* try to open the whole disk */ 275 dev.d_unit = i; 276 dev.d_kind.biosdisk.slice = -1; 277 dev.d_kind.biosdisk.partition = -1; 278 279 if (!bd_opendisk(&od, &dev)) { 280 281 /* Do we have a partition table? */ 282 if (od->od_flags & BD_PARTTABOK) { 283 dptr = &od->od_slicetab[0]; 284 285 /* Check for a "dedicated" disk */ 286 for (j = 0; j < od->od_nslices; j++) { |
281 sprintf(line, " disk%ds%d", i, j + 1); 282 if (bd_printslice(od, &dptr[j], line, verbose)) { 283 done = 1; 284 break; 285 } | 287 snprintf(line, sizeof(line), " disk%ds%d", i, j + 1); 288 if ((ret = bd_printslice(od, &dptr[j], line, verbose)) != 0) 289 break; |
286 } 287 } 288 bd_closedisk(od); | 290 } 291 } 292 bd_closedisk(od); |
293 if (ret != 0) 294 break; |
|
289 } 290 } | 295 } 296 } |
291 pager_close(); | 297 return (ret); |
292} 293 294/* Given a size in 512 byte sectors, convert it to a human-readable number. */ 295static char * 296display_size(uint64_t size) 297{ 298 static char buf[80]; 299 char unit; --- 815 unchanged lines hidden --- | 298} 299 300/* Given a size in 512 byte sectors, convert it to a human-readable number. */ 301static char * 302display_size(uint64_t size) 303{ 304 static char buf[80]; 305 char unit; --- 815 unchanged lines hidden --- |