1N/A/*
1N/A libparted - a library for manipulating disk partitions
1N/A Copyright (C) 2001, 2007, 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#define _JFS_UTILITY
1N/A#include "jfs_types.h"
1N/A#include "jfs_superblock.h"
1N/A
1N/A#define JFS_SUPER_SECTOR 64
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#define JFS_BLOCK_SIZES ((int[2]){512, 0})
1N/A
1N/Astatic PedGeometry*
1N/Ajfs_probe (PedGeometry* geom)
1N/A{
1N/A union {
1N/A struct superblock sb;
1N/A char bytes[512];
1N/A } buf;
1N/A
1N/A /* FIXME: for now, don't even try to deal with larger sector size. */
1N/A if (geom->dev->sector_size != PED_SECTOR_SIZE_DEFAULT)
1N/A return NULL;
1N/A
1N/A if (geom->length < JFS_SUPER_SECTOR + 1)
1N/A return NULL;
1N/A if (!ped_geometry_read (geom, &buf, JFS_SUPER_SECTOR, 1))
1N/A return NULL;
1N/A
1N/A if (strncmp (buf.sb.s_magic, JFS_MAGIC, 4) == 0) {
1N/A PedSector block_size = PED_LE32_TO_CPU (buf.sb.s_pbsize) / 512;
1N/A PedSector block_count = PED_LE64_TO_CPU (buf.sb.s_size);
1N/A
1N/A return ped_geometry_new (geom->dev, geom->start,
1N/A block_size * block_count);
1N/A } else {
1N/A return NULL;
1N/A }
1N/A}
1N/A
1N/A#ifndef DISCOVER_ONLY
1N/Astatic int
1N/Ajfs_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, JFS_SUPER_SECTOR, 1);
1N/A}
1N/A#endif /* !DISCOVER_ONLY */
1N/A
1N/Astatic PedFileSystemOps jfs_ops = {
1N/A .probe = jfs_probe,
1N/A#ifndef DISCOVER_ONLY
1N/A .clobber = jfs_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 jfs_type = {
1N/A .next = NULL,
1N/A .ops = &jfs_ops,
1N/A .name = "jfs",
1N/A .block_sizes = JFS_BLOCK_SIZES
1N/A};
1N/A
1N/Avoid
1N/Aped_file_system_jfs_init ()
1N/A{
1N/A ped_file_system_type_register (&jfs_type);
1N/A}
1N/A
1N/Avoid
1N/Aped_file_system_jfs_done ()
1N/A{
1N/A ped_file_system_type_unregister (&jfs_type);
1N/A}