block.c (dbffbdcfff69431b622866ac5ea78df74fdc02d4) block.c (53fec9d3fd3d3a4ded4b92dfa843436bf71380f1)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

533 /* this is the default */
534 } else {
535 return -1;
536 }
537
538 return 0;
539}
540
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

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

533 /* this is the default */
534 } else {
535 return -1;
536 }
537
538 return 0;
539}
540
541/**
542 * The copy-on-read flag is actually a reference count so multiple users may
543 * use the feature without worrying about clobbering its previous state.
544 * Copy-on-read stays enabled until all users have called to disable it.
545 */
546void bdrv_enable_copy_on_read(BlockDriverState *bs)
547{
548 bs->copy_on_read++;
549}
550
551void bdrv_disable_copy_on_read(BlockDriverState *bs)
552{
553 assert(bs->copy_on_read > 0);
554 bs->copy_on_read--;
555}
556
541/*
542 * Common part for opening disk images and files
543 */
544static int bdrv_open_common(BlockDriverState *bs, const char *filename,
545 int flags, BlockDriver *drv)
546{
547 int ret, open_flags;
548

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

554 bs->total_sectors = 0;
555 bs->encrypted = 0;
556 bs->valid_key = 0;
557 bs->sg = 0;
558 bs->open_flags = flags;
559 bs->growable = 0;
560 bs->buffer_alignment = 512;
561
557/*
558 * Common part for opening disk images and files
559 */
560static int bdrv_open_common(BlockDriverState *bs, const char *filename,
561 int flags, BlockDriver *drv)
562{
563 int ret, open_flags;
564

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

570 bs->total_sectors = 0;
571 bs->encrypted = 0;
572 bs->valid_key = 0;
573 bs->sg = 0;
574 bs->open_flags = flags;
575 bs->growable = 0;
576 bs->buffer_alignment = 512;
577
578 assert(bs->copy_on_read == 0); /* bdrv_new() and bdrv_close() make it so */
579 if ((flags & BDRV_O_RDWR) && (flags & BDRV_O_COPY_ON_READ)) {
580 bdrv_enable_copy_on_read(bs);
581 }
582
562 pstrcpy(bs->filename, sizeof(bs->filename), filename);
563 bs->backing_file[0] = '\0';
564
565 if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
566 return -ENOTSUP;
567 }
568
569 bs->drv = drv;

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

796 g_free(bs->opaque);
797#ifdef _WIN32
798 if (bs->is_temporary) {
799 unlink(bs->filename);
800 }
801#endif
802 bs->opaque = NULL;
803 bs->drv = NULL;
583 pstrcpy(bs->filename, sizeof(bs->filename), filename);
584 bs->backing_file[0] = '\0';
585
586 if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
587 return -ENOTSUP;
588 }
589
590 bs->drv = drv;

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

817 g_free(bs->opaque);
818#ifdef _WIN32
819 if (bs->is_temporary) {
820 unlink(bs->filename);
821 }
822#endif
823 bs->opaque = NULL;
824 bs->drv = NULL;
825 bs->copy_on_read = 0;
804
805 if (bs->file != NULL) {
806 bdrv_close(bs->file);
807 }
808
809 bdrv_dev_change_media_cb(bs, false);
810 }
811

--- 2859 unchanged lines hidden ---
826
827 if (bs->file != NULL) {
828 bdrv_close(bs->file);
829 }
830
831 bdrv_dev_change_media_cb(bs, false);
832 }
833

--- 2859 unchanged lines hidden ---