Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libtcg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton
libtcg
Commits
19a3da7f
Commit
19a3da7f
authored
15 years ago
by
Blue Swirl
Browse files
Options
Downloads
Patches
Plain Diff
Fix opening of read only raw images
Signed-off-by:
Blue Swirl
<
blauwirbel@gmail.com
>
parent
5c55ff99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
block/raw-posix.c
+15
-16
15 additions, 16 deletions
block/raw-posix.c
with
15 additions
and
16 deletions
block/raw-posix.c
+
15
−
16
View file @
19a3da7f
...
...
@@ -123,7 +123,7 @@ static int cdrom_reopen(BlockDriverState *bs);
#endif
static
int
raw_open_common
(
BlockDriverState
*
bs
,
const
char
*
filename
,
int
flags
)
int
bdrv_flags
,
int
open_
flags
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
int
fd
,
ret
;
...
...
@@ -132,9 +132,9 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
s
->
lseek_err_cnt
=
0
;
s
->
open_flags
|
=
O_BINARY
;
s
->
open_flags
=
open_flags
|
O_BINARY
;
s
->
open_flags
&=
~
O_ACCMODE
;
if
((
flags
&
BDRV_O_ACCESS
)
==
BDRV_O_RDWR
)
{
if
((
bdrv_
flags
&
BDRV_O_ACCESS
)
==
BDRV_O_RDWR
)
{
s
->
open_flags
|=
O_RDWR
;
}
else
{
s
->
open_flags
|=
O_RDONLY
;
...
...
@@ -143,9 +143,9 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
/* Use O_DSYNC for write-through caching, no flags for write-back caching,
* and O_DIRECT for no caching. */
if
((
flags
&
BDRV_O_NOCACHE
))
if
((
bdrv_
flags
&
BDRV_O_NOCACHE
))
s
->
open_flags
|=
O_DIRECT
;
else
if
(
!
(
flags
&
BDRV_O_CACHE_WB
))
else
if
(
!
(
bdrv_
flags
&
BDRV_O_CACHE_WB
))
s
->
open_flags
|=
O_DSYNC
;
s
->
fd
=
-
1
;
...
...
@@ -158,7 +158,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
}
s
->
fd
=
fd
;
s
->
aligned_buf
=
NULL
;
if
((
flags
&
BDRV_O_NOCACHE
))
{
if
((
bdrv_
flags
&
BDRV_O_NOCACHE
))
{
s
->
aligned_buf
=
qemu_blockalign
(
bs
,
ALIGNED_BUFFER_SIZE
);
if
(
s
->
aligned_buf
==
NULL
)
{
ret
=
-
errno
;
...
...
@@ -172,12 +172,13 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
static
int
raw_open
(
BlockDriverState
*
bs
,
const
char
*
filename
,
int
flags
)
{
BDRVRawState
*
s
=
bs
->
opaque
;
int
open_flags
=
0
;
s
->
type
=
FTYPE_FILE
;
if
(
flags
&
BDRV_O_CREAT
)
s
->
open_flags
|
=
O_CREAT
|
O_TRUNC
;
open_flags
=
O_CREAT
|
O_TRUNC
;
return
raw_open_common
(
bs
,
filename
,
flags
);
return
raw_open_common
(
bs
,
filename
,
flags
,
open_
flags
);
}
/* XXX: use host sector size if necessary with:
...
...
@@ -1008,7 +1009,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
}
#endif
return
raw_open_common
(
bs
,
filename
,
flags
);
return
raw_open_common
(
bs
,
filename
,
flags
,
0
);
}
#if defined(__linux__)
...
...
@@ -1186,10 +1187,9 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags)
posix_aio_init
();
s
->
type
=
FTYPE_FD
;
/* open will not fail even if no floppy is inserted */
s
->
open_flags
|=
O_NONBLOCK
;
ret
=
raw_open_common
(
bs
,
filename
,
flags
);
/* open will not fail even if no floppy is inserted, so add O_NONBLOCK */
ret
=
raw_open_common
(
bs
,
filename
,
flags
,
O_NONBLOCK
);
if
(
ret
)
return
ret
;
...
...
@@ -1279,11 +1279,10 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState
*
s
=
bs
->
opaque
;
/* open will not fail even if no CD is inserted */
s
->
open_flags
|=
O_NONBLOCK
;
s
->
type
=
FTYPE_CD
;
return
raw_open_common
(
bs
,
filename
,
flags
);
/* open will not fail even if no CD is inserted, so add O_NONBLOCK */
return
raw_open_common
(
bs
,
filename
,
flags
,
O_NONBLOCK
);
}
static
int
cdrom_probe_device
(
const
char
*
filename
)
...
...
@@ -1373,7 +1372,7 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)
s
->
type
=
FTYPE_CD
;
ret
=
raw_open_common
(
bs
,
filename
,
flags
);
ret
=
raw_open_common
(
bs
,
filename
,
flags
,
0
);
if
(
ret
)
return
ret
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment