Changeset View
Changeset View
Standalone View
Standalone View
stand/i386/libi386/biosdisk.c
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | |||||
static int bd_init(void); | static int bd_init(void); | ||||
static int cd_init(void); | static int cd_init(void); | ||||
static int fd_init(void); | static int fd_init(void); | ||||
static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, | static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, | ||||
char *buf, size_t *rsize); | char *buf, size_t *rsize); | ||||
static int bd_open(struct open_file *f, ...); | static int bd_open(struct open_file *f); | ||||
static int bd_close(struct open_file *f); | static int bd_close(struct open_file *f); | ||||
static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | static int bd_ioctl(struct open_file *f, u_long cmd, void *data); | ||||
static int bd_print(int verbose); | static int bd_print(int verbose); | ||||
static int cd_print(int verbose); | static int cd_print(int verbose); | ||||
static int fd_print(int verbose); | static int fd_print(int verbose); | ||||
static void bd_reset_disk(int); | static void bd_reset_disk(int); | ||||
static int bd_get_diskinfo_std(struct bdinfo *); | static int bd_get_diskinfo_std(struct bdinfo *); | ||||
▲ Show 20 Lines • Show All 673 Lines • ▼ Show 20 Lines | |||||
* Note that the philosophy here is "give them exactly what | * Note that the philosophy here is "give them exactly what | ||||
* they ask for". This is necessary because being too "smart" | * they ask for". This is necessary because being too "smart" | ||||
* about what the user might want leads to complications. | * about what the user might want leads to complications. | ||||
* (eg. given no slice or partition value, with a disk that is | * (eg. given no slice or partition value, with a disk that is | ||||
* sliced - are they after the first BSD slice, or the DOS | * sliced - are they after the first BSD slice, or the DOS | ||||
* slice before it?) | * slice before it?) | ||||
*/ | */ | ||||
static int | static int | ||||
bd_open(struct open_file *f, ...) | bd_open(struct open_file *f) | ||||
tsoome: f is unused... | |||||
{ | { | ||||
struct devdesc *dev; | |||||
bdinfo_t *bd; | bdinfo_t *bd; | ||||
struct disk_devdesc *dev; | |||||
va_list ap; | |||||
int rc; | int rc; | ||||
TSENTER(); | TSENTER(); | ||||
va_start(ap, f); | dev = f->f_devdata; | ||||
dev = va_arg(ap, struct disk_devdesc *); | bd = bd_get_bdinfo(dev); | ||||
va_end(ap); | |||||
bd = bd_get_bdinfo(&dev->dd); | |||||
if (bd == NULL) | if (bd == NULL) | ||||
return (EIO); | return (EIO); | ||||
if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) { | if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) { | ||||
if (!bd_int13probe(bd)) | if (!bd_int13probe(bd)) | ||||
return (EIO); | return (EIO); | ||||
if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) | if ((bd->bd_flags & BD_NO_MEDIA) == BD_NO_MEDIA) | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
if (bd->bd_bcache == NULL) | if (bd->bd_bcache == NULL) | ||||
bd->bd_bcache = bcache_allocate(); | bd->bd_bcache = bcache_allocate(); | ||||
if (bd->bd_open == 0) | if (bd->bd_open == 0) | ||||
bd->bd_sectors = bd_disk_get_sectors(dev); | bd->bd_sectors = bd_disk_get_sectors((struct disk_devdesc *)dev); | ||||
bd->bd_open++; | bd->bd_open++; | ||||
rc = 0; | rc = 0; | ||||
if (dev->dd.d_dev->dv_type == DEVT_DISK) { | if (dev->d_dev->dv_type == DEVT_DISK) { | ||||
rc = disk_open(dev, bd->bd_sectors * bd->bd_sectorsize, | rc = disk_open((struct disk_devdesc *)dev, | ||||
impUnsubmitted Not Done Inline ActionsNot for this commit, but all these casts suggest two things to me:
But maybe these are followup work. imp: Not for this commit, but all these casts suggest two things to me:
1. We might want to have a… | |||||
kevansAuthorUnsubmitted Done Inline ActionsGood points- dropping in some comments. kevans: Good points- dropping in some comments. | |||||
bd->bd_sectorsize); | bd->bd_sectors * bd->bd_sectorsize, bd->bd_sectorsize); | ||||
if (rc != 0) { | if (rc != 0) { | ||||
bd->bd_open--; | bd->bd_open--; | ||||
if (bd->bd_open == 0) { | if (bd->bd_open == 0) { | ||||
bcache_free(bd->bd_bcache); | bcache_free(bd->bd_bcache); | ||||
bd->bd_bcache = NULL; | bd->bd_bcache = NULL; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 490 Lines • Show Last 20 Lines |
f is unused...