Revision 508c7cb3 block/raw-posix.c
b/block/raw-posix.c | ||
---|---|---|
953 | 953 |
|
954 | 954 |
#endif |
955 | 955 |
|
956 |
static int hdev_probe_device(const char *filename) |
|
957 |
{ |
|
958 |
struct stat st; |
|
959 |
|
|
960 |
/* allow a dedicated CD-ROM driver to match with a higher priority */ |
|
961 |
if (strstart(filename, "/dev/cdrom", NULL)) |
|
962 |
return 50; |
|
963 |
|
|
964 |
if (stat(filename, &st) >= 0 && |
|
965 |
(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) { |
|
966 |
return 100; |
|
967 |
} |
|
968 |
|
|
969 |
return 0; |
|
970 |
} |
|
971 |
|
|
956 | 972 |
static int hdev_open(BlockDriverState *bs, const char *filename, int flags) |
957 | 973 |
{ |
958 | 974 |
BDRVRawState *s = bs->opaque; |
... | ... | |
1152 | 1168 |
static BlockDriver bdrv_host_device = { |
1153 | 1169 |
.format_name = "host_device", |
1154 | 1170 |
.instance_size = sizeof(BDRVRawState), |
1171 |
.bdrv_probe_device = hdev_probe_device, |
|
1155 | 1172 |
.bdrv_open = hdev_open, |
1156 | 1173 |
.bdrv_close = raw_close, |
1157 | 1174 |
.bdrv_create = hdev_create, |
... | ... | |
1197 | 1214 |
return 0; |
1198 | 1215 |
} |
1199 | 1216 |
|
1217 |
static int floppy_probe_device(const char *filename) |
|
1218 |
{ |
|
1219 |
if (strstart(filename, "/dev/fd", NULL)) |
|
1220 |
return 100; |
|
1221 |
return 0; |
|
1222 |
} |
|
1223 |
|
|
1224 |
|
|
1200 | 1225 |
static int floppy_is_inserted(BlockDriverState *bs) |
1201 | 1226 |
{ |
1202 | 1227 |
return fd_open(bs) >= 0; |
... | ... | |
1242 | 1267 |
static BlockDriver bdrv_host_floppy = { |
1243 | 1268 |
.format_name = "host_floppy", |
1244 | 1269 |
.instance_size = sizeof(BDRVRawState), |
1270 |
.bdrv_probe_device = floppy_probe_device, |
|
1245 | 1271 |
.bdrv_open = floppy_open, |
1246 | 1272 |
.bdrv_close = raw_close, |
1247 | 1273 |
.bdrv_create = hdev_create, |
... | ... | |
1279 | 1305 |
return raw_open_common(bs, filename, flags); |
1280 | 1306 |
} |
1281 | 1307 |
|
1308 |
static int cdrom_probe_device(const char *filename) |
|
1309 |
{ |
|
1310 |
if (strstart(filename, "/dev/cd", NULL)) |
|
1311 |
return 100; |
|
1312 |
return 0; |
|
1313 |
} |
|
1314 |
|
|
1282 | 1315 |
static int cdrom_is_inserted(BlockDriverState *bs) |
1283 | 1316 |
{ |
1284 | 1317 |
BDRVRawState *s = bs->opaque; |
... | ... | |
1323 | 1356 |
static BlockDriver bdrv_host_cdrom = { |
1324 | 1357 |
.format_name = "host_cdrom", |
1325 | 1358 |
.instance_size = sizeof(BDRVRawState), |
1359 |
.bdrv_probe_device = cdrom_probe_device, |
|
1326 | 1360 |
.bdrv_open = cdrom_open, |
1327 | 1361 |
.bdrv_close = raw_close, |
1328 | 1362 |
.bdrv_create = hdev_create, |
... | ... | |
1367 | 1401 |
return 0; |
1368 | 1402 |
} |
1369 | 1403 |
|
1404 |
static int cdrom_probe_device(const char *filename) |
|
1405 |
{ |
|
1406 |
if (strstart(filename, "/dev/cd", NULL) || |
|
1407 |
strstart(filename, "/dev/acd", NULL)) |
|
1408 |
return 100; |
|
1409 |
return 0; |
|
1410 |
} |
|
1411 |
|
|
1370 | 1412 |
static int cdrom_reopen(BlockDriverState *bs) |
1371 | 1413 |
{ |
1372 | 1414 |
BDRVRawState *s = bs->opaque; |
... | ... | |
1437 | 1479 |
static BlockDriver bdrv_host_cdrom = { |
1438 | 1480 |
.format_name = "host_cdrom", |
1439 | 1481 |
.instance_size = sizeof(BDRVRawState), |
1482 |
.bdrv_probe_device = cdrom_probe_device, |
|
1440 | 1483 |
.bdrv_open = cdrom_open, |
1441 | 1484 |
.bdrv_close = raw_close, |
1442 | 1485 |
.bdrv_create = hdev_create, |
... | ... | |
1466 | 1509 |
|
1467 | 1510 |
static void bdrv_raw_init(void) |
1468 | 1511 |
{ |
1512 |
/* |
|
1513 |
* Register all the drivers. Note that order is important, the driver |
|
1514 |
* registered last will get probed first. |
|
1515 |
*/ |
|
1469 | 1516 |
bdrv_register(&bdrv_raw); |
1470 | 1517 |
bdrv_register(&bdrv_host_device); |
1471 | 1518 |
#ifdef __linux__ |
Also available in: Unified diff