Statistics
| Branch: | Revision:

root / block / vvfat.c @ 8c116b0e

History | View | Annotate | Download (84.7 kB)

# Date Author Comment
34b5d2c6 09/12/2013 11:12 am Max Reitz

block: Error parameter for open functions

Add an Error ** parameter to bdrv_open, bdrv_file_open and associated
functions to allow more specific error messages.

Signed-off-by: Max Reitz <>

cc84d90f 09/12/2013 11:12 am Max Reitz

block: Error parameter for create functions

Add an Error ** parameter to bdrv_create and its associated functions to
allow more specific error messages.

Signed-off-by: Max Reitz <>

015a1036 09/12/2013 11:12 am Max Reitz

bdrv: Use "Error" for opening images

Add an Error ** parameter to BlockDriver.bdrv_open and
BlockDriver.bdrv_file_open to allow more specific error messages.

Signed-off-by: Max Reitz <>

b6b8a333 09/06/2013 04:25 pm Paolo Bonzini

block: introduce bdrv_get_block_status API

For now, bdrv_get_block_status is just another name for bdrv_is_allocated.
The next patches will add more flags.

This also touches all block drivers with a mostly mechanical rename. The
sole exception is cow; because it calls cow_co_is_allocated from the read...

4bc74be9 09/06/2013 04:25 pm Paolo Bonzini

block: return get_block_status data and flags for formats

Reviewed-by: Eric Blake <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Stefan Hajnoczi <>

3d34c6cd 09/06/2013 04:25 pm Fam Zheng

vvfat: use bdrv_new() to allocate BlockDriverState

we need bdrv_new() to properly initialize BDS, don't allocate memory
manually.

Signed-off-by: Fam Zheng <>
Signed-off-by: Stefan Hajnoczi <>

4f6fd349 09/06/2013 04:25 pm Fam Zheng

block: make bdrv_delete() static

Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is no
longer public and should be called by bdrv_unref() if refcnt is
decreased to 0.

This is an identical change because effectively, there's no multiple
reference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...

78f27bd0 07/19/2013 07:29 am Fam Zheng

block: fix vvfat error path for enable_write_target

s->qcow and s->qcow_filename are allocated but not freed on error. Fix the
possible leaks, remove unnecessary check for bdrv_new(), propagate ret code of
bdrv_create() and also the one of enable_write_target()....

56d1b4d2 04/22/2013 12:34 pm Kevin Wolf

block: Remove filename parameter from .bdrv_file_open()

It is unused now in all block drivers.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>

7ad9be64 04/22/2013 11:27 am Kevin Wolf

vvfat: Use bdrv_open options instead of filename

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>

787e4a85 03/22/2013 06:51 pm Kevin Wolf

block: Add options QDict to bdrv_file_open() prototypes

The new parameter is unused yet.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>

de9c0cec 03/15/2013 05:07 pm Kevin Wolf

block: Add options QDict to bdrv_open() prototype

It doesn't do anything yet except storing the options QDict in the
BlockDriverState.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>
Reviewed-by: Stefan Hajnoczi <>...

eb7ff6fb 01/11/2013 10:44 am Stefan Weil

Replace remaining gmtime, localtime by gmtime_r, localtime_r

This allows removing of MinGW specific code and improves
reentrancy for POSIX hosts.

[Removed unused ret variable in qemu_get_timedate() to fix warning:
vl.c: In function ‘qemu_get_timedate’:
vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]...

1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

caf71f86 12/19/2012 09:31 am Paolo Bonzini

migration: move include files to include/migration/

Signed-off-by: Paolo Bonzini <>

737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

6165f4d8 08/15/2012 11:48 am Corey Bryant

block: Convert open calls to qemu_open

This patch converts all block layer open calls to qemu_open.

Note that this adds the O_CLOEXEC flag to the changed open paths
when the O_CLOEXEC macro is defined.

Signed-off-by: Corey Bryant <>...

2e1e79da 08/15/2012 11:48 am Corey Bryant

block: Convert close calls to qemu_close

This patch converts all block layer close calls, that correspond
to qemu_open calls, to qemu_close.

Signed-off-by: Corey Bryant <>
Signed-off-by: Kevin Wolf <>

f91cbefe 07/17/2012 05:48 pm Markus Armbruster

vvfat: Fix partition table

Unless parameter ":floppy:" is given, vvfat creates a virtual image
with DOS MBR defining a single partition which holds the FAT file
system. The size of the virtual image depends on the width of the
FAT: 32 MiB (CHS 64, 16, 63) for 12 bit FAT, 504 MiB (CHS 1024, 16,...

4480e0f9 07/17/2012 05:48 pm Markus Armbruster

vvfat: Do not clobber the user's geometry

vvfat creates a virtual VFAT filesystem with a certain logical
geometry that depends on its options. It sets the "geometry hint" to
this geometry. It is the only block driver to do this.

The geometry hint is about about physical geometry, and used only by...

eba25057 05/30/2012 09:48 am Jim Meyering

block: prevent snapshot mode $TMPDIR symlink attack

In snapshot mode, bdrv_open creates an empty temporary file without
checking for mkstemp or close failure, and ignoring the possibility
of a buffer overrun given a surprisingly long $TMPDIR.
Change the get_tmp_filename function to return int (not void),...

e023b2e2 05/10/2012 11:32 am Paolo Bonzini

block: fix snapshot on QED

QED's opaque data includes a pointer back to the BlockDriverState.
This breaks when bdrv_append shuffles data between bs_new and bs_top.
To avoid this, add a "rebind" function that tells the driver about
the new relationship between the BlockDriverState and its opaque....

8d987346 01/13/2012 12:36 pm Stefan Hajnoczi

vvfat: avoid leaking file descriptor in commit_one_file()

Reported-by: Dr David Alan Gilbert <>
Signed-off-by: Stefan Hajnoczi <>

73f703ca 12/05/2011 03:51 pm Stefan Hajnoczi

vvfat: convert to .bdrv_co_is_allocated()

It is trivial to switch from the synchronous .bdrv_is_allocated()
interface to .bdrv_co_is_allocated() since vvfat_is_allocated() does not
block.

Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

3397f0cb 11/23/2011 06:04 pm Kevin Wolf

vvfat: Add migration blocker

vvfat caches more or less everything when in writable mode. For migration
to work, it would have to be invalidated. Block migration for now when
in writable mode (default is readonly).

Signed-off-by: Kevin Wolf <>

7704df98 11/11/2011 03:02 pm Kevin Wolf

vvfat: Fix read-write mode

vvfat used to directly call into the qcow2 block driver instead of using the
block.c wrappers. With the coroutine conversion, this stopped working.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Paolo Bonzini <>

273e4e03 11/04/2011 06:32 pm Paolo Bonzini

vvfat: reorganize computation of disk geometry

First determine FAT12/16/32, then compute geometry from that for both
FDD and HDD. For 1.44MB floppies, and 2.88MB floppies using FAT16,
change to 1 sector/cluster. The default remains 2.88MB with FAT12
and 2 sectors/cluster. Both DOS and mkdosfs by default format a 2.88MB...

d71cff42 11/04/2011 05:36 pm Paolo Bonzini

vvfat: do not hardcode sector counts in error message

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

5a742b55 11/04/2011 05:27 pm Paolo Bonzini

vvfat: unify and correct computation of sector count

The sector count is stored in the partition and hence must not include the
sectors before its start. At the same time, remove the useless special
casing for 1.44 MB floppies. This fixes fsck on VVFAT hard disks,...

aad37c06 11/04/2011 05:23 pm Paolo Bonzini

vvfat: need to use first_sectors_number to distinguish fdd/hdd

This is consistent with what "real" floppies have, so file(1)
now actually recognizes the VVFAT image as a 1.44 MB floppy.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

e654bfe4 11/04/2011 04:55 pm Paolo Bonzini

vvfat: do not fail if the disk has spare sectors

If the number of "faked sectors" + the number of sectors that are
part of a cluster does not sum up to the total number of sectors,
qemu-img convert fails. Read these spare sectors as all zeros.

Signed-off-by: Paolo Bonzini <>...

2b6a43a8 11/04/2011 04:42 pm Paolo Bonzini

vvfat: fix out of bounds array_get usage

When reading the address of the first free entry, you cannot
use array_get without first marking all entries as occupied.

This is visible if you change the sectors per cluster on a
floppy from 2 to 1.

Signed-off-by: Paolo Bonzini <>...

2914caa0 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_read implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_read implementations to take the mutex.

Drivers that implement bdrv_read rather than bdrv_co_readv can
then benefit from asynchronous operation (at least if the underlying...

e183ef75 10/21/2011 06:34 pm Paolo Bonzini

block: take lock around bdrv_write implementations

This does the first part of the conversion to coroutines, by
wrapping bdrv_write implementations to take the mutex.

Drivers that implement bdrv_write rather than bdrv_co_writev can
then benefit from asynchronous operation (at least if the underlying...

848c66e8 10/21/2011 06:34 pm Paolo Bonzini

block: add a CoMutex to synchronous read drivers

The big conversion of bdrv_read/write to coroutines caused the two
homonymous callbacks in BlockDriver to become reentrant. It goes
like this:

1) bdrv_read is now called in a coroutine, and calls bdrv_read or...

0d460d6f 10/11/2011 10:42 am Kevin Wolf

vvfat: Fix potential buffer overflow

path2[PATH_MAX] can be used for the null termination, so make the array big
enough to allow this.

Signed-off-by: Kevin Wolf <>

ce137829 10/11/2011 10:42 am Stefan Weil

block/vvfat: Fix potential memory leaks and other memory errors

cppcheck reported memory leaks and mismatched g_malloc() with free()
instead of g_free().

Fix these errors.

Cc: Kevin Wolf <>
Signed-off-by: Stefan Weil <>...

7ef6d3dc 10/11/2011 10:42 am Stefan Weil

block/vvfat: Remove unused code

The unused code was detected using cppcheck.

Cc: Kevin Wolf <>
Signed-off-by: Stefan Weil <>
Signed-off-by: Kevin Wolf <>

b2bedb21 09/16/2011 04:25 pm Stefan Weil

Remove blanks before \n in output strings

Those blanks violate the coding conventions, see
scripts/checkpatch.pl.

Blanks missing after colons in the changed lines were added.

This patch does not try to fix tabs, long lines and other
problems in the changed lines, therefore checkpatch.pl reports...

541dc0d4 09/03/2011 01:45 pm Stefan Weil

Use new macro QEMU_PACKED for packed structures

Most changes were made using these commands:

git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'
git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

08089edc 01/12/2011 09:48 pm Blue Swirl

vvfat: fix a file descriptor leak

Fix a file descriptor leak, reported by cppcheck:
[/src/qemu/block/vvfat.c:759]: (error) Resource leak: dir

Signed-off-by: Blue Swirl <>

d523d5d6 10/03/2010 09:40 am Stefan Weil

block/vvfat: Fix compiler warning in debug code

Fix this compiler warning:
./block/vvfat.c:2285: error: comparison of unsigned expression >= 0 is always true

Cc: Blue Swirl <>
Cc: Kevin Wolf <>
Signed-off-by: Stefan Weil <>...

ac48e389 09/21/2010 04:39 pm Kevin Wolf

vvfat: Fix segfault on write to read-only disk

vvfat tries to set the readonly flag in its open function, but nowadays
this is overwritted with the readonly=... command line option. Check in
bdrv_write if the vvfat was opened read-only and return an error in this...

9217e26f 09/21/2010 04:39 pm Kevin Wolf

vvfat: Fix double free for opening the image rw

Allocation and deallocation of bs->opaque is not in the control of a
block driver. Therefore it should not set bs->opaque to a data structure
used by another bs, or closing the image will lead to a double free....

a655211a 09/21/2010 04:39 pm Kevin Wolf

vvfat: Use cache=unsafe

The qcow file used for write support in vvfat is a temporary file,
so we can use cache=unsafe there. Without this, write support is just
too slow to be of any use.

Signed-off-by: Kevin Wolf <>

2aa326be 08/30/2010 07:29 pm Loïc Minier

vvfat: fat_chksum(): fix access above array bounds

Signed-off-by: Loïc Minier <>
Signed-off-by: Kevin Wolf <>

792b45b1 05/21/2010 12:49 pm Riccardo Magliocchetti

vvfat: Fix compilation with DEBUG defined

gcc does not like passing a NULL where an int value is expected:

block/vvfat.c: In function ‘checkpoint’:
block/vvfat.c:2868: error: passing argument 2 of ‘remove_mapping’ makes
integer from pointer without a cast...

3e89cb04 05/21/2010 12:49 pm Kevin Wolf

vvfat: More build fixes with DEBUG

Casting a pointer to an int doesn't work on 64 bit platforms. Use the %p printf
conversion specifier instead.

Signed-off-by: Kevin Wolf <>

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

88bf7950 04/25/2010 06:27 pm Blue Swirl

Fix dead initialization, spotted by clang analyzer

Fix clang warnings:
/src/qemu/block/vvfat.c:1102:9: warning: Value stored to 'index3' during its initialization is never read
int index3=index1+1;
/src/qemu/cmd.c:290:15: warning: Value stored to 'p' during its initialization is never read...

d6e9098e 04/23/2010 05:08 pm Kevin Wolf

Replace calls of old bdrv_open

What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the...

43dc2a64 03/18/2010 08:41 pm Blue Swirl

Replace assert(0) with abort() or cpu_abort()

When building with -DNDEBUG, assert(0) will not stop execution
so it must not be used for abnormal termination.

Use cpu_abort() when in CPU context, abort() otherwise.

Signed-off-by: Blue Swirl <>

a6c6f76c 03/13/2010 04:18 pm Blue Swirl

Fix build with -DNDEBUG in CFLAGS

Signed-off-by: Blue Swirl <>

6265eb26 02/10/2010 10:00 pm Jim Meyering

don't dereference NULL after failed strdup

Most of these are obvious NULL-deref bug fixes, for example,
the ones in these files:

block/curl.c
net.c
slirp/misc.c

and the first one in block/vvfat.c.
The others in block/vvfat.c may not lead to an immediate segfault, but I...

058fc8c7 01/26/2010 11:42 pm Naphtali Sprei

Ask for read-write permissions when opening files

Found some places that seems needs this explicitly, now that
read-write is not the default.

Signed-off-by: Naphtali Sprei <>
Signed-off-by: Anthony Liguori <>

2dedf83e 01/26/2010 10:59 pm Kirill A. Shutemov

block/vvfat.c: fix warnings with _FORTIFY_SOURCE

CC block/vvfat.o
cc1: warnings being treated as errors
block/vvfat.c: In function 'commit_one_file':
block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result...

c227f099 10/02/2009 12:12 am Anthony Liguori

Revert "Get rid of _t suffix"

In the very least, a change like this requires discussion on the list.

The naming convention is goofy and it causes a massive merge problem. Something
like this must be presented on the list first so people can provide input...

99a0949b 10/01/2009 09:45 pm malc

Get rid of _t suffix

Some not so obvious bits, slirp and Xen were left alone for the time
being.

Signed-off-by: malc <>

6ab00cee 09/30/2009 09:45 pm Michael S. Tsirkin

vvfat: fix coding style nit

Put space between = and & when taking a pointer,
to avoid confusion with old-style "&=".

Signed-off-by: Michael S. Tsirkin <>
Signed-off-by: Blue Swirl <>

f9e96436 05/28/2009 10:14 am Christoph Hellwig

vvfat: one more missing BlockDriver C99 initializer conversion

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>

91a073a9 05/27/2009 05:45 pm Kevin Wolf

Drop bdrv_create2

This patch converts the remaining users of bdrv_create2 to bdrv_create and
removes the now unused function.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

0e7e1989 05/22/2009 06:50 pm Kevin Wolf

Convert all block drivers to new bdrv_create

Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself....

019d6b8f 05/15/2009 12:13 am Anthony Liguori

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>