Revision 508c7cb3 block.c

b/block.c
209 209
            filename[1] == ':');
210 210
}
211 211

  
212
static int is_windows_drive(const char *filename)
212
int is_windows_drive(const char *filename)
213 213
{
214 214
    if (is_windows_drive_prefix(filename) &&
215 215
        filename[2] == '\0')
......
253 253
 * Detect host devices. By convention, /dev/cdrom[N] is always
254 254
 * recognized as a host CDROM.
255 255
 */
256
#ifdef _WIN32
257
static BlockDriver *find_hdev_driver(const char *filename)
258
{
259
    if (strstart(filename, "/dev/cdrom", NULL))
260
        return bdrv_find_format("host_device");
261
    if (is_windows_drive(filename))
262
        return bdrv_find_format("host_device");
263
    return NULL;
264
}
265
#else
266 256
static BlockDriver *find_hdev_driver(const char *filename)
267 257
{
268
    struct stat st;
269

  
270
#ifdef __linux__
271
    if (strstart(filename, "/dev/fd", NULL))
272
        return bdrv_find_format("host_floppy");
273
    if (strstart(filename, "/dev/cd", NULL))
274
        return bdrv_find_format("host_cdrom");
275
#elif defined(__FreeBSD__)
276
    if (strstart(filename, "/dev/cd", NULL) ||
277
        strstart(filename, "/dev/acd", NULL)) {
278
        return bdrv_find_format("host_cdrom");
279
    }
280
#else
281
    if (strstart(filename, "/dev/cdrom", NULL))
282
        return bdrv_find_format("host_device");
283
#endif
258
    int score_max = 0, score;
259
    BlockDriver *drv = NULL, *d;
284 260

  
285
    if (stat(filename, &st) >= 0 &&
286
            (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
287
        return bdrv_find_format("host_device");
261
    for (d = first_drv; d; d = d->next) {
262
        if (d->bdrv_probe_device) {
263
            score = d->bdrv_probe_device(filename);
264
            if (score > score_max) {
265
                score_max = score;
266
                drv = d;
267
            }
268
        }
288 269
    }
289 270

  
290
    return NULL;
271
    return drv;
291 272
}
292
#endif
293 273

  
294 274
static BlockDriver *find_image_format(const char *filename)
295 275
{

Also available in: Unified diff