1N/A/*
1N/A libparted - a library for manipulating disk partitions
1N/A Copyright (C) 2001, 2009-2010 Free Software Foundation, Inc.
1N/A
1N/A This program is free software; you can redistribute it and/or modify
1N/A it under the terms of the GNU General Public License as published by
1N/A the Free Software Foundation; either version 3 of the License, or
1N/A (at your option) any later version.
1N/A
1N/A This program is distributed in the hope that it will be useful,
1N/A but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A GNU General Public License for more details.
1N/A
1N/A You should have received a copy of the GNU General Public License
1N/A along with this program. If not, see <http://www.gnu.org/licenses/>.
1N/A*/
1N/A
1N/A#include <config.h>
1N/A
1N/A#include <parted/parted.h>
1N/A#include <parted/endian.h>
1N/A
1N/A#if ENABLE_NLS
1N/A# include <libintl.h>
1N/A# define _(String) dgettext (PACKAGE, String)
1N/A#else
1N/A# define _(String) (String)
1N/A#endif /* ENABLE_NLS */
1N/A
1N/A#include <uuid/uuid.h>
1N/A#include "platform_defs.h"
1N/A#include "xfs_types.h"
1N/A#include "xfs_sb.h"
1N/A
1N/A#define XFS_BLOCK_SIZES ((int[2]){512, 0})
1N/A
1N/Astatic PedGeometry*
1N/Axfs_probe (PedGeometry* geom)
1N/A{
1N/A PedSector block_size;
1N/A PedSector block_count;
1N/A union {
1N/A struct xfs_sb sb;
1N/A char bytes [512];
1N/A } buf;
1N/A
1N/A if (geom->length < XFS_SB_DADDR + 1)
1N/A return NULL;
1N/A if (!ped_geometry_read (geom, &buf, XFS_SB_DADDR, 1))
1N/A return NULL;
1N/A
1N/A if (PED_LE32_TO_CPU (buf.sb.sb_magicnum) == XFS_SB_MAGIC) {
1N/A block_size = PED_LE32_TO_CPU (buf.sb.sb_blocksize) / 512;
1N/A block_count = PED_LE64_TO_CPU (buf.sb.sb_dblocks);
1N/A
1N/A return ped_geometry_new (geom->dev, geom->start,
1N/A block_size * block_count);
1N/A }
1N/A
1N/A if (PED_BE32_TO_CPU (buf.sb.sb_magicnum) == XFS_SB_MAGIC) {
1N/A block_size = PED_BE32_TO_CPU (buf.sb.sb_blocksize) / 512;
1N/A block_count = PED_BE64_TO_CPU (buf.sb.sb_dblocks);
1N/A
1N/A return ped_geometry_new (geom->dev, geom->start,
1N/A block_size * block_count);
1N/A }
1N/A
1N/A return NULL;
1N/A}
1N/A
1N/A#ifndef DISCOVER_ONLY
1N/Astatic int
1N/Axfs_clobber (PedGeometry* geom)
1N/A{
1N/A char buf[512];
1N/A
1N/A memset (buf, 0, 512);
1N/A return ped_geometry_write (geom, buf, XFS_SB_DADDR, 1);
1N/A}
1N/A#endif /* !DISCOVER_ONLY */
1N/A
1N/Astatic PedFileSystemOps xfs_ops = {
1N/A .probe = xfs_probe,
1N/A#ifndef DISCOVER_ONLY
1N/A .clobber = xfs_clobber,
1N/A#else
1N/A .clobber = NULL,
1N/A#endif
1N/A .open = NULL,
1N/A .create = NULL,
1N/A .close = NULL,
1N/A .check = NULL,
1N/A .copy = NULL,
1N/A .resize = NULL,
1N/A .get_create_constraint = NULL,
1N/A .get_resize_constraint = NULL,
1N/A .get_copy_constraint = NULL
1N/A};
1N/A
1N/Astatic PedFileSystemType xfs_type = {
1N/A .next = NULL,
1N/A .ops = &xfs_ops,
1N/A .name = "xfs",
1N/A .block_sizes = XFS_BLOCK_SIZES
1N/A};
1N/A
1N/Avoid
1N/Aped_file_system_xfs_init ()
1N/A{
1N/A ped_file_system_type_register (&xfs_type);
1N/A}
1N/A
1N/Avoid
1N/Aped_file_system_xfs_done ()
1N/A{
1N/A ped_file_system_type_unregister (&xfs_type);
1N/A}