journal.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
libparted - a library for manipulating disk partitions
Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DISCOVER_ONLY
#include <config.h>
#include <stdint.h>
#if ENABLE_NLS
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
#include "hfs.h"
#include "reloc_plus.h"
#include "journal.h"
static int hfsj_vh_replayed = 0;
static int is_le = 0;
static uint32_t
{
int i;
}
return (~cksum);
}
int
{
if (!hfsplus_update_vh (fs))
return 0;
return 1;
}
int
{
int binsect;
return 0;
return 0;
return 1;
}
/* Return the sector in the journal that is after the area read */
/* or 0 on error */
static PedSector
void* buf)
{
int r;
while (nb_sect--) {
if (!r) return 0;
read_sect++;
if (read_sect == journ_length)
which is asserted to be
1 sector long */
}
return read_sect;
}
static int
{
unsigned int blhdr_nbsect;
int i, r;
blhdr = (HfsJBlockListHeader*)
if (!blhdr) return 0;
do {
if (!start) goto err_replay;
_("Bad block list header checksum."));
goto err_replay;
}
if (!size) continue;
if (size % PED_SECTOR_SIZE_DEFAULT) {
_("Invalid size of a transaction "
"block while replaying the journal "
"(%i bytes)."),
size);
goto err_replay;
}
if (!block) goto err_replay;
block);
if (!start) {
goto err_replay;
}
/* the sector stored in the journal seems to be
relative to the begin of the block device which
contains the hfs+ journaled volume */
else
r = 1;
/* check if wrapper mdb or vh with no wrapper has
changed */
&& (2 >= sector)
hfsj_vh_replayed = 1;
/* check if vh of embedded hfs+ has changed */
&& (sector
&& (sector
hfsj_vh_replayed = 1;
if (!r) goto err_replay;
}
return 0;
}
/* 0 => Failure, don't continue to open ! */
/* 1 => Success, the journal has been completly replayed, or don't need to */
int
{
int binsect;
return 0;
/ ( PED_SECTOR_SIZE_DEFAULT * binsect );
}
return 1;
_("Journal stored outside of the volume are "
"not supported. Try to desactivate the "
"journal and run Parted again."));
return 0;
}
_("Journal offset or size is not multiple of "
"the sector size."));
return 0;
}
return 0;
is_le = 1;
_("Incorrect magic values in the journal header."));
return 0;
}
_("Journal size mismatch between journal info block "
"and journal header."));
return 0;
}
_("Some header fields are not multiple of the sector "
"size."));
return 0;
}
_("The sector size stored in the journal is not 512 "
"bytes. Parted only supports 512 bytes length "
"sectors."));
return 0;
}
_("Bad journal checksum."));
return 0;
}
/* The 2 following test are in the XNU Darwin source code */
/* so I assume they're needed */
return 1;
if (ped_exception_throw (
_("The journal is not empty. Parted must replay the "
"transactions before opening the file system. This will "
"modify the file system."))
return 0;
/* Replay one complete transaction */
return 0;
/* Recalculate cksum of the journal header */
/* Update the Journal Header */
return 0;
}
if (hfsj_vh_replayed) {
/* probe could have reported incorrect info ! */
/* is there a way to ask parted to quit ? */
_("The volume header or the master directory block has "
"changed while replaying the journal. You should "
"restart Parted."));
return 0;
}
return 1;
}
#endif /* DISCOVER_ONLY */