Added access() check before detecting image mode to get an accurate panic
message in case of failure.
This commit is contained in:
parent
02905d9aaf
commit
8159a00b3e
@ -2064,6 +2064,9 @@ undoable_image_t::~undoable_image_t()
|
|||||||
int undoable_image_t::open(const char* pathname, int flags)
|
int undoable_image_t::open(const char* pathname, int flags)
|
||||||
{
|
{
|
||||||
UNUSED(flags);
|
UNUSED(flags);
|
||||||
|
if (access(pathname, F_OK) < 0) {
|
||||||
|
BX_PANIC(("r/o disk image doesn't exist"));
|
||||||
|
}
|
||||||
int mode = hdimage_detect_image_mode(pathname);
|
int mode = hdimage_detect_image_mode(pathname);
|
||||||
if (mode == BX_HDIMAGE_MODE_UNKNOWN) {
|
if (mode == BX_HDIMAGE_MODE_UNKNOWN) {
|
||||||
BX_PANIC(("r/o disk image mode not detected"));
|
BX_PANIC(("r/o disk image mode not detected"));
|
||||||
@ -2201,6 +2204,9 @@ int volatile_image_t::open(const char* pathname, int flags)
|
|||||||
Bit32u timestamp;
|
Bit32u timestamp;
|
||||||
|
|
||||||
UNUSED(flags);
|
UNUSED(flags);
|
||||||
|
if (access(pathname, F_OK) < 0) {
|
||||||
|
BX_PANIC(("r/o disk image doesn't exist"));
|
||||||
|
}
|
||||||
int mode = hdimage_detect_image_mode(pathname);
|
int mode = hdimage_detect_image_mode(pathname);
|
||||||
if (mode == BX_HDIMAGE_MODE_UNKNOWN) {
|
if (mode == BX_HDIMAGE_MODE_UNKNOWN) {
|
||||||
BX_PANIC(("r/o disk image mode not detected"));
|
BX_PANIC(("r/o disk image mode not detected"));
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
#ifndef BX_HDIMAGE_H
|
#ifndef BX_HDIMAGE_H
|
||||||
#define BX_HDIMAGE_H
|
#define BX_HDIMAGE_H
|
||||||
|
|
||||||
|
// required for access() checks
|
||||||
|
#ifndef F_OK
|
||||||
|
#define F_OK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// hdimage capabilities
|
// hdimage capabilities
|
||||||
#define HDIMAGE_READONLY 1
|
#define HDIMAGE_READONLY 1
|
||||||
#define HDIMAGE_HAS_GEOMETRY 2
|
#define HDIMAGE_HAS_GEOMETRY 2
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// ported from QEMU block driver with some additions (see below)
|
// ported from QEMU block driver with some additions (see below)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004,2005 Johannes E. Schindelin
|
// Copyright (c) 2004,2005 Johannes E. Schindelin
|
||||||
// Copyright (C) 2010-2013 The Bochs Project
|
// Copyright (C) 2010-2014 The Bochs Project
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -59,10 +59,6 @@
|
|||||||
#define VVFAT_BOOT "vvfat_boot.bin"
|
#define VVFAT_BOOT "vvfat_boot.bin"
|
||||||
#define VVFAT_ATTR "vvfat_attr.cfg"
|
#define VVFAT_ATTR "vvfat_attr.cfg"
|
||||||
|
|
||||||
#ifndef F_OK
|
|
||||||
#define F_OK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// portable mkdir / rmdir
|
// portable mkdir / rmdir
|
||||||
static int bx_mkdir(const char *path)
|
static int bx_mkdir(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2013 Volker Ruppert
|
|
||||||
// Copyright (C) 2001-2013 The Bochs Project
|
// Copyright (C) 2001-2013 The Bochs Project
|
||||||
|
// Copyright (C) 2013-2014 Volker Ruppert
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or
|
// This library is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
@ -775,6 +775,9 @@ void convert_image(int newimgmode, Bit64u newsize)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (access(bx_filename_1, F_OK) < 0) {
|
||||||
|
fatal("source disk image doesn't exist");
|
||||||
|
}
|
||||||
if (mode == -1) {
|
if (mode == -1) {
|
||||||
mode = hdimage_detect_image_mode(bx_filename_1);
|
mode = hdimage_detect_image_mode(bx_filename_1);
|
||||||
}
|
}
|
||||||
@ -841,6 +844,9 @@ void commit_redolog()
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
if (access(bx_filename_1, F_OK) < 0) {
|
||||||
|
fatal("base disk image doesn't exist");
|
||||||
|
}
|
||||||
int mode = hdimage_detect_image_mode(bx_filename_1);
|
int mode = hdimage_detect_image_mode(bx_filename_1);
|
||||||
if (mode == BX_HDIMAGE_MODE_UNKNOWN)
|
if (mode == BX_HDIMAGE_MODE_UNKNOWN)
|
||||||
fatal("base disk image mode not detected");
|
fatal("base disk image mode not detected");
|
||||||
|
Loading…
Reference in New Issue
Block a user