bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/4] tests: add double quotes around a use of $VERBOSE


From: Jim Meyering
Subject: [PATCH 1/4] tests: add double quotes around a use of $VERBOSE
Date: Tue, 17 May 2011 23:12:41 +0200

In removing all FS-related support, I've encountered
a few changes that are appropriate for master, independent
of that work.  Here are four:

>From 7504a510c120d12c799f2f1f432ee7ef3c515211 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 13 May 2011 20:55:10 +0200
Subject: [PATCH 1/4] tests: add double quotes around a use of $VERBOSE

* tests/t-local.sh (scsi_debug_cleanup_): Add missing double quotes.
---
 tests/t-local.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tests/t-local.sh b/tests/t-local.sh
index b9b8b28..f89f81d 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -26,7 +26,7 @@ scsi_debug_cleanup_()
     # "Module scsi_debug is in use".
     for i in 1 2 3; do
       rmmod scsi_debug \
-       && { test $VERBOSE = yes && warn_ $ME_ rmmod scsi_debug...; break; }
+       && { test "$VERBOSE" = yes && warn_ $ME_ rmmod scsi_debug...; break; }
       sleep .2 || sleep 1
     done
   fi
--
1.7.5.1.341.g177b8


>From 2f70be2fc96946f4379735b96ecb15c061a2d8d3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 16 May 2011 13:51:23 +0200
Subject: [PATCH 2/4] bfs: remove unused files

---
 libparted/fs/bfs/Makefile.am |    6 -
 libparted/fs/bfs/bfs.c       |  272 ------------------------------------------
 libparted/fs/bfs/bfs.h       |   46 -------
 3 files changed, 0 insertions(+), 324 deletions(-)
 delete mode 100644 libparted/fs/bfs/Makefile.am
 delete mode 100644 libparted/fs/bfs/bfs.c
 delete mode 100644 libparted/fs/bfs/bfs.h

diff --git a/libparted/fs/bfs/Makefile.am b/libparted/fs/bfs/Makefile.am
deleted file mode 100644
index 15d3c48..0000000
--- a/libparted/fs/bfs/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-partedincludedir       = -I$(top_srcdir)/include
-
-noinst_LTLIBRARIES     = libbfs.la
-libbfs_la_SOURCES      = bfs.c
-
-INCLUDES = $(partedincludedir) $(INTLINCS)
diff --git a/libparted/fs/bfs/bfs.c b/libparted/fs/bfs/bfs.c
deleted file mode 100644
index d85f331..0000000
--- a/libparted/fs/bfs/bfs.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
-    libparted - a library for manipulating disk partitions
-    Copyright (C) 2005, 2007, 2009-2011 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>
-#include <parted/debug.h>
-
-#if ENABLE_NLS
-#  include <libintl.h>
-#  define _(String) dgettext (PACKAGE, String)
-#else
-#  define _(String) (String)
-#endif /* ENABLE_NLS */
-
-#include <unistd.h>
-
-#include "bfs.h"
-
-
-#define BFS_SPECIFIC(fs) ((struct BfsSpecific*) (fs->type_specific))
-#define BFS_SB(fs)       (BFS_SPECIFIC(fs)->sb)
-
-
-const char BFS_MAGIC[4] = { 0x1B, 0xAD, 0xFA, 0xCE };
-const long long BFS_SECTOR_SIZE         = 512;
-const uint32_t  BFS_PED_SANITY          = 0xffffffff;
-const long long BFS_PED_MIN_INODES      = 16;
-
-static PedGeometry*
-bfs_probe (PedGeometry* geom)
-{
-       uint8_t*        buf;
-
-        PED_ASSERT (geom      != NULL);
-        PED_ASSERT (geom->dev != NULL);
-
-        buf = ped_malloc (geom->dev->sector_size);
-
-       if (!ped_geometry_read (geom, buf, 0, 1))
-               return 0;
-
-        //if ( PED_CPU_TO_LE32((uint32_t)buf) == BFS_MAGIC )
-               return ped_geometry_new (geom->dev, geom->start,
-                                ped_div_round_up (
-                                        PED_CPU_TO_LE32((uint32_t)(buf+8)),
-                                        geom->dev->sector_size));
-       else
-               return NULL;
-}
-
-#ifndef DISCOVER_ONLY
-static int
-bfs_clobber (PedGeometry* geom)
-{
-       uint8_t*  buf;
-
-        PED_ASSERT (geom      != NULL);
-        PED_ASSERT (geom->dev != NULL);
-
-        buf = ped_malloc (geom->dev->sector_size);
-
-        if (!ped_geometry_read (geom, buf, 0, 1))
-                return 0;
-       memset (buf, 0, 512);
-       return ped_geometry_write (geom, buf, 0, 1);
-}
-#endif /* !DISCOVER_ONLY */
-
-
-static PedFileSystem*
-bfs_alloc (const PedGeometry* geom)
-{
-       PedFileSystem*  fs;
-
-       fs = (PedFileSystem*) ped_malloc (sizeof (PedFileSystem));
-       if (!fs)
-               goto error;
-
-       fs->type_specific = (struct BfsSpecific*) ped_malloc (
-                        sizeof (struct BfsSpecific));
-       if (!fs->type_specific)
-               goto error_free_fs;
-
-       fs->geom = ped_geometry_duplicate (geom);
-       if (!fs->geom)
-               goto error_free_type_specific;
-
-       fs->checked = 0;
-       return fs;
-
-error_free_type_specific:
-       free (fs->type_specific);
-error_free_fs:
-       free (fs);
-error:
-       return NULL;
-}
-
-
-void
-bfs_free (PedFileSystem* fs)
-{
-        ped_geometry_destroy (fs->geom);
-        free (fs->type_specific);
-        free (fs);
-}
-
-
-static PedFileSystem*
-bfs_open (PedGeometry *geom)
-{
-        PedFileSystem* fs = bfs_alloc (geom);
-
-        struct bfs_sb* sb = (struct bfs_sb*) ped_malloc(sizeof(struct bfs_sb));
-        struct BfsSpecific* bfs;
-        uint8_t* buf;
-
-        PED_ASSERT (geom      != NULL);
-        PED_ASSERT (geom->dev != NULL);
-
-        buf = ped_malloc (geom->dev->sector_size);
-
-        if (!fs)
-                return NULL;
-
-        bfs = fs->type_specific;
-
-        if (!ped_geometry_read (geom, buf, 0, 1))
-                return NULL;
-
-        memcpy (sb, buf, BFS_SECTOR_SIZE);
-
-        bfs->sb = sb;
-
-        return fs;
-}
-
-
-#ifndef DISCOVER_ONLY
-static struct bfs_inode* create_root_inode()
-{
-        struct bfs_inode* root = ped_malloc (sizeof(struct bfs_inode));
-
-        root->i = 2UL;
-        /*root->start = FIX;
-        root->end = ;
-        root->eof_off = ;*/
-        root->attr = 2UL;
-        root->mode = 512UL; /* rwxrwxrwx */
-        root->uid = root->gid = 0UL;
-        root->nlinks = 0UL;
-        root->atime = root->ctime = 0UL;
-        memset ((void*)root->reserved, 0, 32*4);
-
-        return root;
-}
-
-
-static uint8_t* _block_alloc (int n)
-{
-        return ped_calloc (n * BFS_SECTOR_SIZE);
-}
-
-
-static void _write_inodes (PedFileSystem* fs)
-{
-}
-
-
-/* write a BFS block - always 512 bytes */
-static int _write_block (PedFileSystem* fs, uint8_t* buf, int n)
-{
-        /* FIXME: support for bs != 2^9 */
-        return ped_geometry_write ( fs->geom, buf, n, 1 );
-}
-
-
-static int _write_sb (PedFileSystem* fs)
-{
-        uint8_t* sb = _block_alloc (1);
-
-        BFS_SB(fs)->magic  = BFS_MAGIC;
-        BFS_SB(fs)->sanity = BFS_PED_SANITY;
-        BFS_SB(fs)->start  = BFS_SPECIFIC(fs)->data_start;
-        BFS_SB(fs)->size   = BFS_SPECIFIC(fs)->size;
-
-        memcpy (sb, BFS_SB(fs), sizeof(struct bfs_sb));
-
-        return _write_block (fs, sb, 1);
-}
-
-
-static PedFileSystem*
-bfs_create (PedGeometry *geom, PedTimer *timer)
-{
-        PedFileSystem* fs = bfs_alloc (geom);
-        int n_inodes = PED_MAX (BFS_PED_MIN_INODES, 16/*some sane value 
here*/);
-
-        /* TODO: check whether geometry is big enough */
-
-        fs->data_start = 1 + ped_round_up_to (n_inodes * 64, 512);
-        fs->size = geom->dev->sector_size * length;
-
-        ped_timer_set_state_name (timer, "Writing inodes");
-
-
-
-        ped_timer_set_state_name (timer, "Writing super block");
-        _write_sb (fs);
-
-        return 0;
-}
-#endif /* !DISCOVER_ONLY */
-
-
-static PedFileSystemOps bfs_ops = {
-       probe:          bfs_probe,
-#ifndef DISCOVER_ONLY
-       clobber:        bfs_clobber,
-#else
-       clobber:        NULL,
-#endif
-       open:           bfs_open,
-#ifndef DISCOVER_ONLY
-       create:         bfs_create,
-#else
-        create:         NULL
-#endif
-       close:          NULL,
-       check:          NULL,
-       copy:           NULL,
-       resize:         NULL,
-       get_create_constraint:  NULL,
-       get_resize_constraint:  NULL,
-       get_copy_constraint:    NULL
-};
-
-static PedFileSystemType bfs_type = {
-       next:           NULL,
-       ops:            &bfs_ops,
-       name:           "bfs",
-        block_sizes:    ((int[2]){512, 0})
-};
-
-void
-ped_file_system_bfs_init ()
-{
-       ped_file_system_type_register (&bfs_type);
-}
-
-void
-ped_file_system_bfs_done ()
-{
-       ped_file_system_type_unregister (&bfs_type);
-}
diff --git a/libparted/fs/bfs/bfs.h b/libparted/fs/bfs/bfs.h
deleted file mode 100644
index 2fb75ab..0000000
--- a/libparted/fs/bfs/bfs.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef BFS_H
-#define BFS_H
-
-#ifndef blk_t
-  typedef long long blk_t;
-#endif
-
-struct bfs_sb
-{
-        char magic[4];
-        uint32_t start;
-        uint32_t size;
-        uint32_t sanity[4];
-};
-
-struct bfs_inode
-{
-        uint32_t i;
-        uint32_t start;
-        uint32_t end;
-        uint32_t eof_off;
-        uint32_t attr;
-        uint32_t mode;
-        uint32_t uid;
-        uint32_t gid;
-        uint32_t nlinks;
-        uint32_t atime;
-        uint32_t ctime;
-        uint32_t reserved[4];
-};
-
-struct bfs_dirent
-{
-        uint16_t        i;
-        uint8_t         name[14];
-};
-
-struct BfsSpecific
-{
-        struct bfs_sb   *sb;
-        int             n_inodes;
-        blk_t           data_start;
-        long long       size;
-};
-
-#endif
--
1.7.5.1.341.g177b8


>From f8719930ebce4eee44822d4fcede0413cce184dd Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 16 May 2011 18:13:25 +0200
Subject: [PATCH 3/4] linux: fix diagnostic about operating on very small file
 or device

* libparted/arch/linux.c (init_file): Correct diagnostic.
Parted would claim that a small-but-non-empty file has zero length.
---
 libparted/arch/linux.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index b56ce2b..05962e0 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -1098,7 +1098,7 @@ init_file (PedDevice* dev)
                 ped_exception_throw (
                         PED_EXCEPTION_ERROR,
                         PED_EXCEPTION_CANCEL,
-                        _("The device %s has zero length, and can't possibly "
+                        _("The device %s is so small that it cannot possibly "
                           "store a file system or partition table.  Perhaps "
                           "you selected the wrong device?"),
                         dev->path);
--
1.7.5.1.341.g177b8


>From 8f0d7ee20660de806ed0b1308938f80db22e21a5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 17 Sep 2009 20:12:50 +0200
Subject: [PATCH 4/4] tests: remove tests that are too FS-centric

* tests/t2100-mkswap.sh: Likewise.
* tests/t3000-resize-fs.sh: Remove file, now that all FS-ops are gone.
* tests/Makefile.am (TESTS): Remove them here, too.
---
 tests/Makefile.am        |    2 -
 tests/t2100-mkswap.sh    |   88 ---------------------------------------
 tests/t3000-resize-fs.sh |  103 ----------------------------------------------
 3 files changed, 0 insertions(+), 193 deletions(-)
 delete mode 100755 tests/t2100-mkswap.sh
 delete mode 100755 tests/t3000-resize-fs.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index f5a1562..4ea08f3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,12 +23,10 @@ TESTS = \
   t1100-busy-label.sh \
   t1101-busy-partition.sh \
   t1700-probe-fs.sh \
-  t2100-mkswap.sh \
   t2200-dos-label-recog.sh \
   t2300-dos-label-extended-bootcode.sh \
   t2310-dos-extended-2-sector-min-offset.sh \
   t2400-dos-hfs-partition-type.sh \
-  t3000-resize-fs.sh \
   t3200-type-change.sh \
   t3300-palo-prep.sh \
   t3310-flags.sh \
diff --git a/tests/t2100-mkswap.sh b/tests/t2100-mkswap.sh
deleted file mode 100755
index b48a122..0000000
--- a/tests/t2100-mkswap.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/sh
-# create linux-swap partitions
-
-# Copyright (C) 2007, 2009-2011 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/>.
-
-. "${srcdir=.}/init.sh"; path_prepend_ ../parted
-require_512_byte_sector_size_
-
-######################################################################
-# When creating a partition of type linux-swap(v1) in a DOS partition
-# table, ensure that the proper file system type (0x82) is used.
-# Some releases, e.g. parted-1.8.8 would mistakenly use 0x83.
-######################################################################
-N=2M
-dev=loop-file
-dev2=loop-file-2
-# create a file to simulate the underlying device
-dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null || fail=1
-
-# label the test disk
-parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# create a partition
-parted -s $dev mkpart primary 2048s 4095s > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# create a linux-swap file system
-parted -s $dev mkfs 1 "linux-swap(v1)" > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# Extract the byte at offset 451.  It must be 0x82, not 0x83.
-# extract byte 451 (fs-type)
-od -t x1 -An -j450 -N1 $dev > out && echo " 82" > exp || fail=1
-
-# expect it to be 82, not 83
-compare out exp || fail=1
-
-# create another file to simulate the underlying device
-dd if=/dev/null of=$dev2 bs=1 seek=$N 2> /dev/null || fail=1
-
-# label another test disk
-parted -s $dev2 mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# create another partition
-parted -s $dev2 mkpart primary 2048s 4095s > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# create another linux-swap file system
-parted -s $dev2 mkfs 1 "linux-swap(v1)" > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# partition starts at offset 1048576; swap UUID is 1036 bytes in
-# extract UUID 1
-od -t x1 -An -j1049612 -N16 $dev > uuid1 || fail=1
-# extract UUID 2
-od -t x1 -An -j1049612 -N16 $dev2 > uuid2 || fail=1
-# two linux-swap file systems must have different UUIDs
-cmp uuid1 uuid2 && fail=1
-
-# check linux-swap file system
-parted -s $dev2 check 1 > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-# extract new UUID 2
-od -t x1 -An -j1049612 -N16 $dev2 > uuid2-new || fail=1
-# check preserves linux-swap UUID
-compare uuid2 uuid2-new || fail=1
-
-# create a linux-swap file system via alias
-parted -s $dev mkfs 1 linux-swap > out 2>&1 || fail=1
-compare out /dev/null || fail=1
-
-Exit $fail
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
deleted file mode 100755
index caed954..0000000
--- a/tests/t3000-resize-fs.sh
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-# exercise the resize sub-command; FAT and HFS only
-
-# Copyright (C) 2009-2011 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/>.
-
-. "${srcdir=.}/init.sh"; path_prepend_ ../parted
-require_hfs_
-
-require_root_
-require_scsi_debug_module_
-require_512_byte_sector_size_
-
-ss=$sector_size_
-
-start=63s
-default_end=546147s
-    new_end=530144s
-
-# create memory-backed device
-scsi_debug_setup_ dev_size_mb=550 > dev-name ||
-  skip_ 'failed to create scsi_debug device'
-dev=$(cat dev-name)
-
-parted -s $dev mklabel gpt > out 2>&1 || fail=1
-# expect no output
-compare out /dev/null || fail=1
-
-# ensure that the disk is large enough
-dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
-device_sectors_required=$(echo $default_end | sed 's/s$//')
-# Ensure that $dev is large enough for this test
-test $device_sectors_required -le $dev_n_sectors || fail=1
-
-for fs_type in hfs+ fat32; do
-
-  # create an empty $fs_type partition, cylinder aligned, size > 256 MB
-  parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1 || 
fail=1
-  echo "Warning: The resulting partition is not properly" \
-      "aligned for best performance." > exp
-  compare out exp || fail=1
-
-  # print partition table
-  parted -m -s $dev u s p > out 2>&1 || fail=1
-
-  # FIXME: check expected output
-
-  # There's a race condition here: on udev-based systems, the partition#1
-  # device, ${dev}1 (i.e., /dev/sde1) is not created immediately, and
-  # without some delay, this mount command would fail.  Using a flash card
-  # as $dev, the loop below typically iterates 7-20 times.
-
-  # wait for new partition device to appear
-  wait_for_dev_to_appear_ ${dev}1 || { warn_ "${dev}1 did not appear"  fail=1; 
}
-  sleep 1
-
-  case $fs_type in
-    fat32) mkfs_cmd='mkfs.vfat -F 32';;
-    hfs*) mkfs_cmd='mkfs.hfs';;
-    *) error "internal error: unhandled fs type: $fs_type";;
-  esac
-
-  # create the file system
-  $mkfs_cmd ${dev}1 || fail=1
-
-  # NOTE: shrinking is the only type of resizing that works.
-  # resize that file system to be one cylinder (8MiB) smaller
-  parted -s $dev resize 1 $start $new_end > out 2> err || fail=1
-  # expect no output
-  compare out /dev/null || fail=1
-  compare err /dev/null || fail=1
-
-  # print partition table
-  parted -m -s $dev u s p > out 2>&1 || fail=1
-
-  # compare against expected output
-  sed -n 3p out > k && mv k out || fail=1
-  printf "1:$start:$new_end:530082s:$fs_type:primary:$ms;\n" > exp || fail=1
-  compare out exp || fail=1
-
-  # Remove the partition explicitly, so that mklabel doesn't evoke a warning.
-  parted -s $dev rm 1 || fail=1
-
-  # Create a clean partition table for the next iteration.
-  parted -s $dev mklabel gpt > out 2>&1 || fail=1
-  # expect no output
-  compare out /dev/null || fail=1
-
-done
-
-Exit $fail
--
1.7.5.1.341.g177b8



reply via email to

[Prev in Thread] Current Thread [Next in Thread]