Hi, This patch implements basic ZFS support (probe and clobber only).
2010-08-11 Robert Millan <[email protected]>
* configure.ac (AC_OUTPUT): Add `libparted/fs/zfs/Makefile'. * libparted/fs/Makefile.am (SUBDIRS): Add `zfs'. (libfs_la_LIBADD): Add `zfs/libzfs.la'. * libparted/libparted.c (ped_file_system_zfs_init): New prototype. (init_file_system_types): Call ped_file_system_zfs_init(). (ped_file_system_zfs_done): New prototype. (done_file_system_types): Call ped_file_system_zfs_done(). * libparted/fs/zfs/Makefile.am: New file. * libparted/fs/zfs/zfs.c: Likewise. diff -Nurp parted.old/configure.ac parted/configure.ac --- parted.old/configure.ac 2010-08-11 14:53:28.000000000 +0200 +++ parted/configure.ac 2010-08-11 14:53:55.000000000 +0200 @@ -634,6 +634,7 @@ libparted/fs/ntfs/Makefile libparted/fs/reiserfs/Makefile libparted/fs/ufs/Makefile libparted/fs/xfs/Makefile +libparted/fs/zfs/Makefile libparted/tests/Makefile libparted.pc parted/Makefile diff -Nurp parted.old/libparted/fs/Makefile.am parted/libparted/fs/Makefile.am --- parted.old/libparted/fs/Makefile.am 2010-08-11 14:53:28.000000000 +0200 +++ parted/libparted/fs/Makefile.am 2010-08-11 14:53:55.000000000 +0200 @@ -4,7 +4,7 @@ # # This file may be modified and/or distributed without restriction. -SUBDIRS = amiga ext2 ufs fat ntfs hfs linux_swap xfs jfs reiserfs # bfs +SUBDIRS = amiga ext2 ufs fat ntfs hfs linux_swap xfs jfs reiserfs zfs # bfs partedincludedir = -I$(top_srcdir)/include noinst_LTLIBRARIES = libfs.la @@ -24,7 +24,8 @@ libfs_la_LIBADD = $(UUID_LIBS) \ linux_swap/liblinuxswap.la \ xfs/libxfs.la \ jfs/libjfs.la \ - reiserfs/libreiserfs.la + reiserfs/libreiserfs.la \ + zfs/libzfs.la # bfs/libbfs.la libfs_la_SOURCES = diff -Nurp parted.old/libparted/fs/zfs/Makefile.am parted/libparted/fs/zfs/Makefile.am --- parted.old/libparted/fs/zfs/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ parted/libparted/fs/zfs/Makefile.am 2010-08-11 14:53:55.000000000 +0200 @@ -0,0 +1,8 @@ +partedincludedir = -I$(top_srcdir)/include + +noinst_LTLIBRARIES = libzfs.la +libzfs_la_SOURCES = zfs.c + +INCLUDES = $(partedincludedir) $(INTLINCS) + +MAINTAINERCLEANFILES = Makefile.in diff -Nurp parted.old/libparted/fs/zfs/zfs.c parted/libparted/fs/zfs/zfs.c --- parted.old/libparted/fs/zfs/zfs.c 1970-01-01 01:00:00.000000000 +0100 +++ parted/libparted/fs/zfs/zfs.c 2010-08-11 14:53:55.000000000 +0200 @@ -0,0 +1,106 @@ +/* + libparted - a library for manipulating disk partitions + Copyright (C) 2000, 2007, 2009-2010 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 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 <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 <unistd.h> + +#define ZFS_BLOCK_SIZES ((int[2]){512, 0}) + +#define ZFS_SIGNATURE 0x00bab10c + +struct zfs_uberblock +{ + uint64_t signature; + uint64_t version; +}; + +static PedGeometry* +zfs_probe (PedGeometry* geom) +{ + uint8_t buf[512]; + struct zfs_uberblock *uber = (void *) buf; + + if (!ped_geometry_read (geom, buf, 256, 1)) + return 0; + + if ((le64toh (uber->signature) == ZFS_SIGNATURE + || be64toh (uber->signature) == ZFS_SIGNATURE) + && uber->version != 0) + return ped_geometry_new (geom->dev, geom->start, geom->length); + else + return NULL; +} + +#ifndef DISCOVER_ONLY +static int +zfs_clobber (PedGeometry* geom) +{ + char buf[512]; + + memset (buf, 0, 512); + return ped_geometry_write (geom, buf, 256, 1); +} +#endif /* !DISCOVER_ONLY */ + +static PedFileSystemOps zfs_ops = { + probe: zfs_probe, +#ifndef DISCOVER_ONLY + clobber: zfs_clobber, +#else + clobber: NULL, +#endif + 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 zfs_type = { + next: NULL, + ops: &zfs_ops, + name: "zfs", + block_sizes: ZFS_BLOCK_SIZES +}; + +void +ped_file_system_zfs_init () +{ + ped_file_system_type_register (&zfs_type); +} + +void +ped_file_system_zfs_done () +{ + ped_file_system_type_unregister (&zfs_type); +} diff -Nurp parted.old/libparted/libparted.c parted/libparted/libparted.c --- parted.old/libparted/libparted.c 2010-08-11 14:53:28.000000000 +0200 +++ parted/libparted/libparted.c 2010-08-11 14:53:55.000000000 +0200 @@ -109,6 +109,7 @@ extern void ped_file_system_jfs_init (vo 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_zfs_init (void); static void init_file_system_types () @@ -123,6 +124,7 @@ init_file_system_types () ped_file_system_hfs_init (); ped_file_system_fat_init (); ped_file_system_ext2_init (); + ped_file_system_zfs_init (); } #endif /* ENABLE_FS */ @@ -189,10 +191,12 @@ extern void ped_file_system_reiserfs_don extern void ped_file_system_ufs_done (void); extern void ped_file_system_xfs_done (void); extern void ped_file_system_amiga_done (void); +extern void ped_file_system_zfs_done (void); static void done_file_system_types () { + ped_file_system_zfs_done (); ped_file_system_ext2_done (); ped_file_system_fat_done (); ped_file_system_hfs_done ();
_______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

