Hello list,

can we add some basic LUKS [1] support (see attached file) to parted?
It's currently probing only but that's nevertheless a useful feature.

Thanks in advance.

Stefan

[1] http://luks.endorphin.org/
/*
    libparted - a library for manipulating disk partitions
    Copyright (C) 2000 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 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, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#include "config.h"

#include <parted/parted.h>
#include <parted/endian.h>

#if ENABLE_NLS
#  include <libintl.h>
#  define _(String) dgettext (PACKAGE, String)
#else
#  define _(String) (String)
#endif /* ENABLE_NLS */

#include <string.h>

#define LUKS_MAGIC	"LUKS"
#define PHDR_SIZE	592

static PedGeometry*
luks_probe (PedGeometry* geom)
{
	char	buf[PHDR_SIZE];

	if (!ped_geometry_read (geom, buf, 0, 1))
		return NULL;

	if (strncmp (LUKS_MAGIC, buf, strlen(LUKS_MAGIC)) == 0) 
		return ped_geometry_new (geom->dev, geom->start, geom->length);
	else
		return NULL;
}

static PedFileSystemOps luks_ops = {
	probe:		luks_probe,
	clobber:	NULL,
	open:		NULL,
	create:		NULL,
	close:		NULL,
	check:		NULL,
	copy:		NULL,
	resize:		NULL,
	get_create_constraint:	NULL,
	get_resize_constraint:	NULL,
	get_copy_constraint:	NULL
};

static PedFileSystemType luks_type = {
	next:	NULL,
	ops:	&luks_ops,
	name:	"luks",
};

void
ped_file_system_luks_init ()
{
	ped_file_system_type_register (&luks_type);
}

void
ped_file_system_luks_done ()
{
	ped_file_system_type_unregister (&luks_type);
}


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to