Deleted Added
full compact
biosdisk.c (313355) biosdisk.c (328889)
1/*-
2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
3 * Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

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

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: stable/11/sys/boot/i386/libi386/biosdisk.c 313355 2017-02-06 22:03:07Z tsoome $");
29__FBSDID("$FreeBSD: stable/11/sys/boot/i386/libi386/biosdisk.c 328889 2018-02-05 17:01:18Z kevans $");
30
31/*
32 * BIOS disk device handling.
33 *
34 * Ideas and algorithms from:
35 *
36 * - NetBSD libi386/biosdisk.c
37 * - FreeBSD biosboot/disk.c

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

130static int bd_init(void);
131static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
132 char *buf, size_t *rsize);
133static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size,
134 char *buf, size_t *rsize);
135static int bd_open(struct open_file *f, ...);
136static int bd_close(struct open_file *f);
137static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
30
31/*
32 * BIOS disk device handling.
33 *
34 * Ideas and algorithms from:
35 *
36 * - NetBSD libi386/biosdisk.c
37 * - FreeBSD biosboot/disk.c

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

130static int bd_init(void);
131static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size,
132 char *buf, size_t *rsize);
133static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size,
134 char *buf, size_t *rsize);
135static int bd_open(struct open_file *f, ...);
136static int bd_close(struct open_file *f);
137static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
138static void bd_print(int verbose);
138static int bd_print(int verbose);
139static void bd_cleanup(void);
140
141#ifdef LOADER_GELI_SUPPORT
142static enum isgeli {
143 ISGELI_UNKNOWN,
144 ISGELI_NO,
145 ISGELI_YES
146};

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

301 DEBUG("unit 0x%x flags %x, sectors %llu, sectorsize %u",
302 bd->bd_unit, bd->bd_flags, bd->bd_sectors, bd->bd_sectorsize);
303 return (1);
304}
305
306/*
307 * Print information about disks
308 */
139static void bd_cleanup(void);
140
141#ifdef LOADER_GELI_SUPPORT
142static enum isgeli {
143 ISGELI_UNKNOWN,
144 ISGELI_NO,
145 ISGELI_YES
146};

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

301 DEBUG("unit 0x%x flags %x, sectors %llu, sectorsize %u",
302 bd->bd_unit, bd->bd_flags, bd->bd_sectors, bd->bd_sectorsize);
303 return (1);
304}
305
306/*
307 * Print information about disks
308 */
309static void
309static int
310bd_print(int verbose)
311{
312 static char line[80];
313 struct disk_devdesc dev;
310bd_print(int verbose)
311{
312 static char line[80];
313 struct disk_devdesc dev;
314 int i;
314 int i, ret = 0;
315
315
316 pager_open();
316 if (nbdinfo == 0)
317 return (0);
318
319 printf("%s devices:", biosdisk.dv_name);
320 if ((ret = pager_output("\n")) != 0)
321 return (ret);
322
317 for (i = 0; i < nbdinfo; i++) {
323 for (i = 0; i < nbdinfo; i++) {
318 sprintf(line, " disk%d: BIOS drive %c (%ju X %u):\n", i,
324 snprintf(line, sizeof(line),
325 " disk%d: BIOS drive %c (%ju X %u):\n", i,
319 (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit):
320 ('C' + bdinfo[i].bd_unit - 0x80),
321 (uintmax_t)bdinfo[i].bd_sectors,
322 bdinfo[i].bd_sectorsize);
326 (bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit):
327 ('C' + bdinfo[i].bd_unit - 0x80),
328 (uintmax_t)bdinfo[i].bd_sectors,
329 bdinfo[i].bd_sectorsize);
323 if (pager_output(line))
330 if ((ret = pager_output(line)) != 0)
324 break;
325 dev.d_dev = &biosdisk;
326 dev.d_unit = i;
327 dev.d_slice = -1;
328 dev.d_partition = -1;
329 if (disk_open(&dev,
330 bdinfo[i].bd_sectorsize * bdinfo[i].bd_sectors,
331 bdinfo[i].bd_sectorsize,
332 (bdinfo[i].bd_flags & BD_FLOPPY) ?
333 DISK_F_NOCACHE: 0) == 0) {
331 break;
332 dev.d_dev = &biosdisk;
333 dev.d_unit = i;
334 dev.d_slice = -1;
335 dev.d_partition = -1;
336 if (disk_open(&dev,
337 bdinfo[i].bd_sectorsize * bdinfo[i].bd_sectors,
338 bdinfo[i].bd_sectorsize,
339 (bdinfo[i].bd_flags & BD_FLOPPY) ?
340 DISK_F_NOCACHE: 0) == 0) {
334 sprintf(line, " disk%d", i);
335 disk_print(&dev, line, verbose);
341 snprintf(line, sizeof(line), " disk%d", i);
342 ret = disk_print(&dev, line, verbose);
336 disk_close(&dev);
343 disk_close(&dev);
344 if (ret != 0)
345 return (ret);
337 }
338 }
346 }
347 }
339 pager_close();
348 return (ret);
340}
341
342/*
343 * Attempt to open the disk described by (dev) for use by (f).
344 *
345 * Note that the philosophy here is "give them exactly what
346 * they ask for". This is necessary because being too "smart"
347 * about what the user might want leads to complications.

--- 575 unchanged lines hidden ---
349}
350
351/*
352 * Attempt to open the disk described by (dev) for use by (f).
353 *
354 * Note that the philosophy here is "give them exactly what
355 * they ask for". This is necessary because being too "smart"
356 * about what the user might want leads to complications.

--- 575 unchanged lines hidden ---