libparted.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1999, 2000, 2001, 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/>.
*/
#include <config.h>
#include "configmake.h"
#ifdef linux
#else
#endif
#if ENABLE_NLS
# include <locale.h>
# include <libintl.h>
#else
#endif /* ENABLE_NLS */
const PedArchitecture* ped_architecture;
/* ped_malloc() debugging. Stick the address and size of memory blocks that
* weren't ped_free()d in here, and an exception will be thrown when it is
* allocated. That way, you can find out what, exactly, the allocated thing
* is, and where it is created.
*/
typedef struct
{
void* pointer;
/* IMHO, none of the DEBUG-related code below is useful, and the
ped_malloc memset code is actually quite harmful: it masked at
least two nasty bugs that were fixed in June of 2007. */
#ifdef DEBUG
static pointer_size_type dodgy_malloc_list[] = {
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0},
{0, 0}
};
static int dodgy_memory_active[100];
#endif /* DEBUG */
int
{
return 1;
}
extern void ped_disk_aix_init ();
extern void ped_disk_bsd_init ();
extern void ped_disk_dvh_init ();
extern void ped_disk_gpt_init ();
extern void ped_disk_loop_init ();
extern void ped_disk_mac_init ();
extern void ped_disk_msdos_init ();
extern void ped_disk_pc98_init ();
extern void ped_disk_sun_init ();
extern void ped_disk_amiga_init ();
extern void ped_disk_dasd_init ();
static void
{
ped_disk_loop_init (); /* must be last in the probe list */
#endif
#ifdef ENABLE_PC98
#endif
}
#ifdef ENABLE_FS
extern void ped_file_system_amiga_init (void);
extern void ped_file_system_xfs_init (void);
extern void ped_file_system_ufs_init (void);
extern void ped_file_system_reiserfs_init (void);
extern void ped_file_system_ntfs_init (void);
extern void ped_file_system_linux_swap_init (void);
extern void ped_file_system_jfs_init (void);
extern void ped_file_system_hfs_init (void);
extern void ped_file_system_fat_init (void);
extern void ped_file_system_ext2_init (void);
extern void ped_file_system_solaris_x86_init (void);
static void
{
}
#endif /* ENABLE_FS */
extern void ped_disk_aix_done ();
extern void ped_disk_bsd_done ();
extern void ped_disk_dvh_done ();
extern void ped_disk_gpt_done ();
extern void ped_disk_loop_done ();
extern void ped_disk_mac_done ();
extern void ped_disk_msdos_done ();
extern void ped_disk_pc98_done ();
extern void ped_disk_sun_done ();
extern void ped_disk_amiga_done ();
extern void ped_disk_dasd_done ();
static void
{
#endif
#ifdef ENABLE_PC98
#endif
}
static void
_init()
{
#ifdef ENABLE_NLS
#endif
init_disk_types ();
#ifdef ENABLE_FS
#endif
/* FIXME: a better way of doing this? */
#ifdef linux
#else
#endif
#ifdef DEBUG
#endif
}
#ifdef ENABLE_FS
extern void ped_file_system_ext2_done (void);
extern void ped_file_system_fat_done (void);
extern void ped_file_system_hfs_done (void);
extern void ped_file_system_jfs_done (void);
extern void ped_file_system_linux_swap_done (void);
extern void ped_file_system_ntfs_done (void);
extern void ped_file_system_reiserfs_done (void);
extern void ped_file_system_ufs_done (void);
extern void ped_file_system_xfs_done (void);
extern void ped_file_system_amiga_done (void);
static void
{
}
#endif /* ENABLE_FS */
static void
_done()
{
done_disk_types ();
#ifdef ENABLE_FS
#endif
}
const char*
{
return VERSION;
}
#ifdef DEBUG
static void
{
int i;
for (i=0; dodgy_malloc_list[i].pointer; i++) {
continue;
continue;
if (!is_malloc && !dodgy_memory_active[i])
continue;
if (is_malloc) {
"Dodgy malloc(%x) == %p occurred (active==%d)",
dodgy_memory_active[i]++;
} else {
"Dodgy free(%p) occurred (active==%d)",
ptr, dodgy_memory_active[i]);
dodgy_memory_active[i]--;
}
return;
}
}
#endif /* DEBUG */
void*
{
void* mem;
if (!mem) {
_("Out of memory."));
return NULL;
}
#ifdef DEBUG
#endif
return mem;
}
int
{
void* mem;
if (!mem) {
_("Out of memory."));
return 0;
}
return 1;
}
{
return buf;
}
void
{
#ifdef DEBUG
_check_dodgy_pointer (ptr, 0, 0);
#endif
}