advfs.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 "file.h"
#include "advfs.h"
/* - if a < b, 0 if a == b, + if a > b */
/* Comparaison is done in the following order : */
/* CNID, then fork type, then start block */
/* Note that HFS implementation in linux has a bug */
/* in this function */
static int
{
/* do NOT use a substraction, because */
/* 0xFFFFFFFF - 1 = 0xFFFFFFFE so this */
/* would return -2, despite the fact */
/* 0xFFFFFFFF > 1 !!! (this is the 2.4 bug) */
-1 : +1;
return 0;
/* the whole thing wont work with 16 bits ints */
/* anyway */
}
/* do a B-Tree lookup */
/* read the first record immediatly inferior or egal to the given key */
/* return 0 on error */
/* record_out _must_ be large enough to receive record_size bytes */
/* WARNING : the compare function called only handle Extents BTree */
/* so modify this function if you want to do lookup in */
/* other BTrees has well */
int
void *record_out, unsigned int record_size,
{
unsigned int node_number, record_number;
int i;
/* Read the header node */
return 0;
/* Get the node number of the root */
if (!node_number)
return 0;
/* Read the root node */
return 0;
/* Follow the white rabbit */
while (1) {
for (i = record_number; i; i--) {
/* check for obvious error in FS */
_("The file system contains errors."));
return 0;
}
break;
}
if (!i) return 0;
unsigned int skip;
return 0;
} else
break;
}
/* copy the result if needed */
if (record_size)
/* send record reference if needed */
if (record_ref) {
record_ref->record_number = i;
}
/* success */
return 1;
}
/* free the bad blocks linked list */
void
{
while (first) {
}
}
/* This function reads bad blocks extents in the extents file
and store it in f.s. specific data of fs */
int
{
if (priv_data->bad_blocks_loaded)
return 1;
{
+ sizeof (HfsExtDataRec)];
(record + sizeof (HfsExtentKey));
while (1) {
int i;
if (first_pass)
break;
else
goto errbb;
}
break;
for (i = 0; i < HFS_EXT_NB; i++) {
if (ret_cache[i].block_count) {
sizeof (HfsPrivateLinkExtent));
if (!new_xt)
goto errbb;
sizeof (HfsExtDescriptor));
block += PED_BE16_TO_CPU (
ret_cache[i].block_count);
}
}
first_pass = 0;
}
return 1;}
return 0;
}
/* This function check if fblock is a bad block */
int
{
/* Won't compile without the strange cast ! gcc bug ? */
/* or maybe C subtilties... */
(fblock < (unsigned int) (PED_BE16_TO_CPU (
+ PED_BE16_TO_CPU (
return 1;
}
return 0;
}
/* This function returns the first sector of the last free block of an
HFS volume we can get after a hfs_pack_free_space_from_block call */
/* On error this function returns 0 */
{
/* find the next block to the last bad block of the volume */
if (!hfs_read_bad_blocks (fs))
return 0;
last_bad = 0;
}
/* Count the free blocks from last_bad to the end of the volume */
end_free_blocks = 0;
block++) {
}
/* Calculate the block that will by the first free at the
end of the volume */
}
/* return the block which should be used to pack data to have at
least free fblock blocks at the end of the volume */
unsigned int
{
unsigned int block;
block--) {
fblock--;
}
block--;
block++;
return block;
}
#endif /* !DISCOVER_ONLY */