/*
reiserfs.c -- libparted / libreiserfs glue
Copyright (C) 2001-2002, 2007, 2009-2010 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/>.
This is all rather complicated. There are a few combinations:
* shared libraries full support
* dynamic libraries present full support (via dlopen)
* dynamic libraries absent (full support disabled) (via dlopen)
* discover only
We'd love to hear comments...
So far, we've opted for maximum flexibility for the user. Is it
all worth it?
*/
#include <config.h>
# define REISER_FULL_SUPPORT
#endif
#include <fcntl.h>
#include <errno.h>
#ifdef DYNAMIC_LOADING
# include <dlfcn.h>
#endif
#if ENABLE_NLS
# include <libintl.h>
#else
#endif
#include "reiserfs.h"
#include "geom_dal.h"
#ifdef DYNAMIC_LOADING
# define FPTR *
# define FCLASS static
#else
# define FPTR
# define FCLASS extern
#endif
#ifdef DYNAMIC_LOADING
static int libreiserfs_present;
static void *libdal_handle;
static void *libreiserfs_handle;
#endif /* DYNAMIC_LOADING */
#ifdef REISER_FULL_SUPPORT
(int(FPTR)(reiserfs_exception_t *));
int, int, const char *,
const char *, blk_t,
reiserfs_gauge_t *);
#ifdef HAVE_REISERFS_FS_CHECK
#endif
reiserfs_gauge_t *);
char *, reiserfs_gauge_handler_t, void *);
int determined, int update_header,
int update_footer)
{
}
static PedExceptionOption
{
switch (option) {
case EXCEPTION_UNHANDLED:
return PED_EXCEPTION_UNHANDLED;
case EXCEPTION_FIX:
return PED_EXCEPTION_FIX;
case EXCEPTION_YES:
return PED_EXCEPTION_YES;
case EXCEPTION_NO:
return PED_EXCEPTION_NO;
case EXCEPTION_OK:
return PED_EXCEPTION_OK;
case EXCEPTION_RETRY:
return PED_EXCEPTION_RETRY;
case EXCEPTION_IGNORE:
return PED_EXCEPTION_IGNORE;
case EXCEPTION_CANCEL:
return PED_EXCEPTION_CANCEL;
default:
return PED_EXCEPTION_UNHANDLED;
}
}
static PedExceptionType
{
switch (type) {
case EXCEPTION_INFORMATION:
return PED_EXCEPTION_INFORMATION;
case EXCEPTION_WARNING:
return PED_EXCEPTION_WARNING;
case EXCEPTION_ERROR:
return PED_EXCEPTION_ERROR;
case EXCEPTION_FATAL:
return PED_EXCEPTION_FATAL;
case EXCEPTION_BUG:
return PED_EXCEPTION_BUG;
case EXCEPTION_NO_FEATURE:
return PED_EXCEPTION_NO_FEATURE;
default:
return PED_EXCEPTION_NO_FEATURE;
}
}
{
}
#endif /* REISER_FULL_SUPPORT */
{
int i;
for (i = 0; reiserfs_super_offset[i] != -1; i++) {
continue;
continue;
strlen(REISERFS_SIGNATURE)) == 0
strlen(REISER2FS_SIGNATURE)) == 0
strlen(REISER3FS_SIGNATURE)) == 0) {
}
}
return NULL;
}
#ifndef DISCOVER_ONLY
{
int i;
for (i = 0; reiserfs_super_offset[i] != -1; i++) {
continue;
if (!ped_geometry_write
return 0;
}
return 1;
}
#endif /* !DISCOVER_ONLY */
#ifdef REISER_FULL_SUPPORT
{
goto error;
goto error_fs_geom_free;
/*
We are passing NULL as DAL for journal. Therefore we let libreiserfs know,
that journal not available and parted will be working fine for reiserfs
with relocated journal too.
*/
goto error_free_dal;
goto error_free_fs;
return fs;
return NULL;
}
{
goto error_fs_geom_free;
if (! (gauge =
goto error_free_dal;
}
gauge)))
goto error_free_gauge;
if (gauge)
goto error_free_fs_info;
return fs;
if (gauge)
return NULL;
}
{
return 1;
}
{
return NULL;
}
{
#ifdef HAVE_REISERFS_FS_CHECK
#endif
if (!reiserfs_fs_is_consistent(fs_info)) {
_("The file system is in an invalid "
"state. Perhaps it is mounted?"));
return 0;
}
if (!reiserfs_fs_is_resizeable(fs_info))
_("The file system is in old "
"(unresizeable) format."));
if (!reiserfs_fs_bitmap_check(fs_info)) {
_("Invalid free blocks count. Run "
"reiserfsck --check first."));
return 0;
}
#ifdef HAVE_REISERFS_FS_CHECK
if (!
(gauge =
return 0;
}
_("Reiserfs tree seems to be corrupted. "
"Run reiserfsck --check first."));
return 0;
}
if (gauge)
#endif
_("The reiserfs file system passed a basic check. "
"For a more comprehensive check, run "
"reiserfsck --check."));
return 1;
}
{
_("Sorry, can't move the start of "
"reiserfs partitions yet."));
return 0;
}
_("Couldn't reopen device "
"abstraction layer for "
return 0;
}
}
if (!
(gauge =
return 0;
}
goto error_free_gauge;
} else {
goto error_free_gauge;
}
if (gauge)
return 1;
if (gauge)
return 0;
}
fs)
{
return NULL;
return NULL;
return NULL;
/*
Minsize for reiserfs is area occupied by data blocks and
metadata blocks minus free space blocks and minus bitmap
blocks which describes free space blocks.
*/
}
{
_("Couldn't create reiserfs device "
"abstraction handler."));
goto error_free_fs_geom;
}
fs_len =
if (fs_len <= min_needed_blk) {
_("Device is too small for %lu blocks."),
goto error_free_dal;
}
goto error_free_dal;
if (! (gauge =
goto error_free_new_fs;
}
goto error_free_gauge;
if (gauge)
return new_fs;
if (gauge)
return NULL;
}
{
return NULL;
}
#endif /* !REISER_FULL_SUPPORT */
#ifdef DYNAMIC_LOADING
{
void *entry;
char *error;
_("Couldn't resolve symbol %s. "
"Error: %s."),
return NULL;
}
return entry;
}
static int reiserfs_ops_interface_version_check(void)
{
int (*libreiserfs_get_max_interface_version) (void);
int (*libreiserfs_get_min_interface_version) (void);
_("GNU Parted found an invalid libreiserfs library."));
return 0;
}
_("GNU Parted has detected libreiserfs interface "
"version mismatch. Found %d-%d, required %d. "
"ReiserFS support will be disabled."),
return 0;
}
return 1;
}
static int reiserfs_ops_init(void)
{
goto error;
return 1;
return 0;
}
static void reiserfs_ops_done()
{
if (libdal_handle)
if (libreiserfs_handle)
}
#endif /* DYNAMIC_LOADING */
#ifdef REISER_FULL_SUPPORT
.probe = reiserfs_probe,
.open = reiserfs_open,
.close = reiserfs_close,
.check = reiserfs_check,
.copy = reiserfs_copy,
};
.ops = &reiserfs_full_ops,
.name = "reiserfs",
};
#endif /* REISER_FULL_SUPPORT */
.probe = reiserfs_probe,
#ifdef DISCOVER_ONLY
#else
#endif
};
.ops = &reiserfs_simple_ops,
.name = "reiserfs",
};
{
#ifdef DYNAMIC_LOADING
if (libreiserfs_present) {
} else {
}
#else /* !DYNAMIC_LOADING */
#ifdef REISER_FULL_SUPPORT
#else
#endif
#endif /* !DYNAMIC_LOADING */
}
{
#ifdef DYNAMIC_LOADING
#endif /* DYNAMIC_LOADING */
}