This patch makes Parted much more portable by breaking code that is
dependent on the operating system into operating system specific
directories of which a single set is chosen at compile time. As a
proof of concept, Parted was ported to the Hurd.
Change Log Entry
---------------
2001-03-07 Neal H Walfield <[EMAIL PROTECTED]>
* configure.in: $OS new variable. The operating system
as grok from $host_os. Substituted into the Makefile.am's.
Determine if we need to enable gnu extensions (needed by
the Hurd).
Make llseek linux only.
Add references to the new Makefile.am in libparted/device
and libparted/device/$OS.
* libparted/Makefile.am (SUBDIRS): Add directory device.
* libparted/disk.c (_partition_is_mounted): If the device
is a PED_DEVICE_FILE, do not complain that it cannot be
found in /etc/mtab.
* libparted/disk_dos.c: Doc fix.
* libparted/device: New directory.
(libparted_ls_LDFLAGS): Update libtool version.
(libparted_la_SOURCES): Remove device.c, llseek.c, llseek.h
(libparted_la_ADD): Add device/libdevice.la
* libparted/device.c: Removed file. Broken into the device
directory.
* libparted/libparted.c (init_disk_types): Add external declarations
for ped_disk_loop_init, ped_disk_msdos_init, ped_disk_pc98_init,
ped_disk_mac_init, ped_disk_bsd_init and ped_disk_sun_init.
(init_file_system_types): Add external declarations for
ped_file_system_ufs_init, ped_file_system_reiserfs_init,
ped_file_system_ntfs_init, ped_file_system_linux_swap_init,
ped_file_system_hfs_init, ped_file_system_fat_init and
ped_file_system_ext2_init.
(done_disk_types): Add external declarations for ped_disk_loop_done,
ped_disk_msdos_done, ped_disk_pc98_done, ped_disk_mac_done,
ped_disk_bsd_done and ped_disk_sun_done.
(done_file_system_types): Add external declarations for
ped_file_system_ufs_done, ped_file_system_reiserfs_done,
ped_file_system_ntfs_done, ped_file_system_linux_swap_done,
ped_file_system_hfs_done, ped_file_system_fat_done and
ped_file_system_ext2_done.
* libparted/llseek.h: Moved to libparted/device/linux directory.
* libparted/llseek.c: Likewise.
* libparted/include/parted/device.h (_PedDevice): fd field removed.
void *po added -- operating system dependent peropen hook.
* libparted/device/Makefile.am: New file.
* libparted/device/gnu
* libparted/device/priv.h: New file. Declaration of internal
functions formerly forward declarations in libparted/device.h.
* libparted/device/device-add.c: New file. Function formerly from
libparted/device.c.
* libparted/device/device-begin-external-access.c: Likewise.
* libparted/device/device-close.c: Likewise.
* libparted/device/device-destroy.c: Likewise.
* libparted/device/device-end-external-access.c: Likewise.
* libparted/device/device-free-all.c: Likewise.
* libparted/device/device-get-next.c: Likewise.
* libparted/device/device-get.c: Likewise.
* libparted/device/device-open.c: Likewise.
* libparted/device/device-probe-all.c: Likewise.
* libparted/device/device-remove.c: Likewise.
* libparted/device/device-stat.c: Likewise.
* libparted/device/device.c: Likewise.
* libparted/device/do-refresh-close.c: Likewise.
* libparted/device/do-refresh-open.c: Likewise.
* libparted/device/probe.c: Likewise.
* libparted/device/gnu: New directory.
* libparted/device/linux: Likewise.
* libparted/device/gnu/Makefile.am: New file.
* libparted/device/gnu/device-check.c: New file. Hurd specific
implementation of respective function.
* libparted/device/gnu/peropen.h: New file. Declaration of
peropen structure.
* libparted/device/gnu/device-get-length.c: Likewise.
* libparted/device/gnu/device-get-sector-size.c: Likewise.
* libparted/device/gnu/device-new.c: Likewise.
* libparted/device/gnu/device-probe-geometry.c: Likewise.
* libparted/device/gnu/device-probe-type.c: Likewise.
* libparted/device/gnu/device-read.c: Likewise.
* libparted/device/gnu/device-sync.c: Likewise.
* libparted/device/gnu/device-write.c: Likewise.
* libparted/device/gnu/do-close.c: Likewise.
* libparted/device/gnu/do-open.c: Likewise.
* libparted/device/gnu/flush-cache.c: Likewise.
* libparted/device/gnu/kernel-reread-part-table.c: Likewise.
* libparted/device/gnu/probe-proc-partitions.c: Likewise.
* libparted/device/gnu/probe-standard-partitions.c: Likewise.
* libparted/device/linux/Makefile.am: New file.
* libparted/device/linux/arch.h: New file. Linux specific
declarations: _do_device_seek (was ped_device_seek in
libparted/device.c) and BLKRRPART, BLKGETSIZE, BLKFLSBUF,
BLKSSZGET ioctls.
* libparted/device/linux/device-check.c: New file. Linux specific
implementations of respective function.
* libparted/device/linux/peropen.h: New file. Declaration of
peropen structure.
* libparted/device/linux/device-get-length.c: Likewise.
* libparted/device/linux/device-get-sector-size.c: Likewise.
* libparted/device/linux/device-new.c: Likewise.
* libparted/device/linux/device-probe-geometry.c: Likewise.
* libparted/device/linux/device-probe-type.c: Likewise.
* libparted/device/linux/device-read.c: Likewise.
* libparted/device/linux/device-sync.c: Likewise.
* libparted/device/linux/device-write.c: Likewise.
* libparted/device/linux/do-close.c: Likewise.
* libparted/device/linux/do-open.c: Likewise.
* libparted/device/linux/do-seek.c: Likewise.
* libparted/device/linux/flush-cache.c: Likewise.
* libparted/device/linux/kernel-reread-part-table.c: Likewise.
* libparted/device/linux/probe-proc-partitions.c: Likewise.
* libparted/device/linux/probe-standard-partitions.c: Likewise.
* libparted/device/linux/llseek.c: Moved from libparted.
* libparted/device/linux/llseek.h: Likewise.
* libparted/fs_ext2/ext2.c: Doc fixes. Error messages
rewritten.
* libparted/fs_ext2/interface.c: Include stdlib.h and string.h.
Doc fixes.
* libparted/fs_hfs/hfs.c: Include <asm/page.h> only if we are on
Linux.
* libparted/fs_linux_swap/linux_swap.c: Likewise.
* libparted/fs_ntfs/ntfs.c: Likewise.
* libparted/fs_reiserfs/reiserfs.c: Likewise.
* parted/parted.c (do_print): Print out free space if it is more
then a few blocks.
(_init): Do not check if MALLOC_TRACE is defined. This is done
automatically by mtrace.
* parted/ui.c (banner_msg): Add a trailing new line.
(print_dev_using): Remove leading new line.
* doc/API: Improve language.
* doc/USER: Improve language. Remove contractions. Mention the
Hurd where appropriate.
Compiling
---------
To compile (on GNU/Linux or GNU/Hurd), you need to do several things.
Patch parted-1.5.1-pre1. Run:
$ autconf && automake && automake libparted/device/gnu && automake
libparted/device/linux
Fix the po directory or edit po/POTFILES.in and remove the references
to llseek.c and device.c.
On the Hurd, after you run configure, you must edit the config.h
and add:
#include <sys/types.h>
#define off_t off64_t
Comments
--------
I have tested reading my hard drive partition table and several files. As
for writing, I have only tested the files as I only have my laptop with me
at the moment and cannot afford scorch it.
The following are some comments on Parted in general and my port of it to
the Hurd:
* On the Hurd, off_t is 32 bits, however, 64 bit offsets are supported
through the store_offset_t type which is aliased to off64_t. At the
moment, I have been going the following hack in config.h:
#include <sys/types.h>
#define off_t off64_t
This needs to be fixed.
* The Hurd implementation of device_{read,write} happily support files of
record sizes other than 512 bytes. So far, 512 and 1 byte records
have been tested; greater than 512 bytes needs to be tested (use
tmpfs).
* When rebuilding the automake files, it is necessary to run automake
manually on the libparted/device/{gnu,linux} directories:
# automake && automake libparted/device/gnu && automake \
> libparted/device/linux
as the directories are mentioned via a variable in configure.in.
* Because there are library dependencies of libparted on libstore and
libshouldbeinlibc, libtool refuses to build shared libraries. We really
need them on the Hurd, how do we work around this?
* autoconf claims that we cannot cross compile; What do we need to do?
* <asm/page.h> does not need to be included on the Hurd. How can this
be autoconf'ed?
* I have broken the translations -- all messages that point to
libparted/device.h, libparted/llseek.{c,h} are uncommented and
I have fixed the language used in several spots.
Bugs and Feature Requests
-------------------------
* If there are three primary partitions and not an extended partition
and you attempt to make an extended partition, you are not prompted
for a type, i.e.:
(parted) mkpart
Partition type? ex
File system type? ext2?
Start? 3.001
End? 9.999
You found a bug in ...
Assertion (dos_data != NULL) at
../../../parted-1.5.1-pre1/libparted/fs_ext2/interface.c:291 in function
_ext2_set_system () failed.
Typing in ``extended'' when prompted for the partition type works correctly.
* Cfdisk only extends extended partitions as far as it needs (i.e. the
end of the last partition). When Parted encounters this, it will
not resize the extended partitions as it claims it overlaps other
partitions. Of course it over laps other partitions! Also, when trying
to create a partition in the ``free space'' Parted says that the
space overlaps another partition (not very informative).
* On that note, I am happy that Parted is very conservative when writing
partition table, however, it is far to strict when reading them. For
instance, I had to use Cfdisk to ``fix'' my partition table (Parted failed
to read my Open BSD partition table correctly). Since we want to use
libparted to help boot strap the Hurd, this needs to be relaxed a lot.
* When prompting for arguments, Parted should suggest a default (e.g. in
brackets).
* It would be very nice if, like Cfdisk, Parted could offer nice defaults
for numbers, e.g. when creating a partition, find the first free space
and use that as a default or print the start of all of the starts of
free space.
* When entering the start and end of a partition, Parted should be liberal
within a few blocks, that is to say, if a partition ends at 3.000 and
I want to make a second that starts at 3, I should not have to type in
3.001. The same should hold if the partition ends at 2.901 and I enter
3 as the start of a new partition -- there is should be no tiny free
space. Or, if that is unsatisfactory, prompt if the user would like
it to happen:
You entered 3.000 as the start of a new partition, If I do this, there
will be 0.089 MB of free space between this and the nearest partition,
would you like to start the partition at 2.902? [yes] no?
* When using the mkpart command, it is not obvious that the filesystem type
is optional: I have hit enter several times thinking that ext2 was the
default. Maybe provide none as an option?
* The file system type argument to mkpart is not optional (try
``mkpart logical 2 5'')!
* When Parted reads an argument that it prompted for, it adds an entry to
the history buffer rather then appending to the command line (like bash
does).
* When typing ``foo bar'' at a Parted prompt (i.e. an error), Parted prints
the help screen for each argument (in this example twice).
* linux_swap_check is throughly broken -- Linux says bad argument when
unmounting and the Hurd says that it is paging to a raw partition
(normally says that it found a linux swap signature). Basically,
why is it writing anything?
* linux_swap_check takes a _long_ time, how about a progress meter?
* ped_device_write takes a const buffer. Logically, this is fine, however,
this generates warnings when passing the buffer to functions such as those
(store_write) used to write the buffer to disk.
* All of the functions in libpart/device/priv.h should be named
privately, which is to say that they should start with an underscore
and not have public prefixes.
The Patch
---------
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/configure.in
parted-1.5.1-pre1/configure.in
--- parted-1.5.1-pre1-vanilla/configure.in Wed Jan 31 18:01:15 2001
+++ parted-1.5.1-pre1/configure.in Tue Mar 6 17:35:40 2001
@@ -3,6 +3,18 @@
AM_CONFIG_HEADER(config.h)
+AC_CANONICAL_HOST
+case "$host_os" in
+ linux*) OS=linux ;;
+ gnu*) OS=gnu ;;
+ *) OS=unknown ;;
+esac
+AC_SUBST(OS)
+
+if test x$OS = xgnu; then
+ CFLAGS="$CFLAGS -D_GNU_SOURCE=1"
+fi
+
dnl Command-line options
AC_ARG_WITH(readline,
[ --with-readline support fancy command line editing], ,
@@ -38,7 +50,7 @@
#include <unistd.h>
])
-if test $ac_cv_sizeof_off_t -lt 8; then
+if test x$OS = xlinux -a $ac_cv_sizeof_off_t -lt 8; then
dnl Need to disable shared libraries, to get llseek() to work. Long
dnl story. The short story is: lseek() isn't in glibc, so a syscall
dnl must be made. syscalls can't be made from within shared libraries,
@@ -162,7 +174,9 @@
)
dnl required for libparted/llseek.c (TODO: make linux-x86 only)
-AC_CHECK_HEADER(linux/unistd.h)
+if test x$OS = xlinux; then
+ AC_CHECK_HEADER(linux/unistd.h)
+fi
if test x$with_readline = xyes; then
AC_CHECK_HEADERS(readline/readline.h readline/history.h, ,
@@ -218,6 +232,8 @@
libparted/fs_ntfs/Makefile
libparted/fs_reiserfs/Makefile
libparted/fs_ufs/Makefile
+libparted/device/Makefile
+libparted/device/${OS}/Makefile
parted/Makefile
intl/Makefile
doc/Makefile
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/include/parted/device.h
parted-1.5.1-pre1/include/parted/device.h
--- parted-1.5.1-pre1-vanilla/include/parted/device.h Fri Jan 26 14:51:17 2001
+++ parted-1.5.1-pre1/include/parted/device.h Sat Mar 3 17:16:51 2001
@@ -50,7 +50,6 @@
int external_mode;
int dirty;
int boot_dirty;
- int fd;
/* x86-specific: TODO hide this in arch_specific. But argghh! The disk
* label stuff needs it, not to mention front-ends :-( */
@@ -58,6 +57,8 @@
int geom_known;
int geom_already_guessed;
short host, did;
+
+ void *po; /* A peropen hook. */
};
extern void ped_device_probe_all ();
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/Makefile.am parted-1.5.1-pre1/libparted/Makefile.am
--- parted-1.5.1-pre1-vanilla/libparted/Makefile.am Wed Jan 31 17:34:07 2001
+++ parted-1.5.1-pre1/libparted/Makefile.am Sat Mar 3 18:50:11 2001
@@ -1,19 +1,16 @@
-SUBDIRS = fs_ext2 fs_fat fs_hfs fs_linux_swap fs_ntfs fs_reiserfs fs_ufs
+SUBDIRS = fs_ext2 fs_fat fs_hfs fs_linux_swap fs_ntfs fs_reiserfs fs_ufs device
LIBS = @INTLLIBS@ @LIBS@
partedincludedir = -I$(top_srcdir)/include
lib_LTLIBRARIES = libparted.la
-libparted_la_LDFLAGS = -version-info 4:0:0
+libparted_la_LDFLAGS = -version-info 5:0:0
libparted_la_SOURCES = constraint.c \
- device.c \
debug.c \
exception.c \
filesys.c \
geom.c \
libparted.c \
- llseek.c \
- llseek.h \
natmath.c \
disk.c \
disk_bsd.c \
@@ -29,7 +26,8 @@
fs_linux_swap/liblinuxswap.la \
fs_ntfs/libntfs.la \
fs_reiserfs/libreiserfs.la \
- fs_ufs/libufs.la
+ fs_ufs/libufs.la \
+ device/libdevice.la
EXTRA_DIST = mbr.s
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/Makefile.am
parted-1.5.1-pre1/libparted/device/Makefile.am
--- parted-1.5.1-pre1-vanilla/libparted/device/Makefile.am Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/Makefile.am Thu Mar 1 23:09:06 2001
@@ -0,0 +1,27 @@
+SUBDIRS=@OS@
+
+partedincludedir = -I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libdevice.la
+libdevice_la_SOURCES = device.c \
+ device.h \
+ device-add.c \
+ device-begin-external-access.c \
+ device-close.c \
+ device-destroy.c \
+ device-end-external-access.c \
+ device-free-all.c \
+ device-get-next.c \
+ device-get.c \
+ device-open.c \
+ device-probe-all.c \
+ device-remove.c \
+ device-stat.c \
+ do-refresh-close.c \
+ do-refresh-open.c \
+ priv.h \
+ probe.c
+
+libdevice_la_LIBADD = @OS@/libarch.la
+
+INCLUDES = $(partedincludedir) @INTLINCS@
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-add.c
parted-1.5.1-pre1/libparted/device/device-add.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-add.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-add.c Fri Mar 2 18:29:46 2001
@@ -0,0 +1,34 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+/* O(n) add function, hehe */
+void
+ped_device_add (PedDevice* dev)
+{
+ PedDevice* walk;
+ for (walk = devices; walk && walk->next; walk = walk->next);
+ if (walk)
+ walk->next = dev;
+ else
+ devices = dev;
+ dev->next = NULL;
+}
+
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-begin-external-access.c
parted-1.5.1-pre1/libparted/device/device-begin-external-access.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-begin-external-access.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device-begin-external-access.c Sun Feb 25
+16:24:32 2001
@@ -0,0 +1,33 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+ped_device_begin_external_access (PedDevice* dev)
+{
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ dev->external_mode = 1;
+ if (dev->open_count)
+ _do_close (dev);
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-close.c
parted-1.5.1-pre1/libparted/device/device-close.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-close.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-close.c Sun Feb 25 16:24:53 2001
@@ -0,0 +1,33 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+ped_device_close (PedDevice* dev)
+{
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ if (--dev->open_count)
+ return _do_refresh_close (dev);
+
+ return _do_close (dev);
+
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-destroy.c
parted-1.5.1-pre1/libparted/device/device-destroy.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-destroy.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-destroy.c Sun Feb 25 16:24:56 2001
@@ -0,0 +1,32 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+void
+ped_device_destroy (PedDevice* dev)
+{
+ PED_ASSERT (dev != NULL, return);
+
+ while (dev->open_count)
+ ped_device_close (dev);
+
+ ped_free (dev->path);
+ ped_free (dev);
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-end-external-access.c
parted-1.5.1-pre1/libparted/device/device-end-external-access.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-end-external-access.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device-end-external-access.c Sun Feb 25
+16:25:07 2001
@@ -0,0 +1,33 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+ped_device_end_external_access (PedDevice* dev)
+{
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (dev->external_mode, return 0);
+
+ dev->external_mode = 0;
+ if (dev->open_count)
+ _do_open (dev);
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-free-all.c
parted-1.5.1-pre1/libparted/device/device-free-all.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-free-all.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device-free-all.c Sun Feb 25 17:19:26
+2001
@@ -0,0 +1,32 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+void
+ped_device_free_all ()
+{
+ PedDevice* dev;
+ while (devices)
+ {
+ dev = devices;
+ ped_device_remove (dev);
+ ped_device_destroy (dev);
+ }
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-get-next.c
parted-1.5.1-pre1/libparted/device/device-get-next.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-get-next.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device-get-next.c Tue Mar 6 17:48:06
+2001
@@ -0,0 +1,29 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+PedDevice*
+ped_device_get_next (const PedDevice* dev)
+{
+ if (dev)
+ return dev->next;
+ else
+ return devices;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-get.c
parted-1.5.1-pre1/libparted/device/device-get.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-get.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-get.c Tue Mar 6 17:48:29 2001
@@ -0,0 +1,45 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+/* First searches through probed devices, then attempts to open the device
+ * regardless.
+ */
+PedDevice*
+ped_device_get (const char* path)
+{
+ PedDevice* walk;
+
+ PED_ASSERT (path != NULL, return NULL);
+
+ for (walk = devices; walk != NULL; walk = walk->next) {
+ if (!strcmp (walk->path, path))
+ return walk;
+ }
+
+ walk = ped_device_new (path);
+ if (!walk)
+ return NULL;
+ ped_device_add (walk);
+ return walk;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-open.c
parted-1.5.1-pre1/libparted/device/device-open.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-open.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-open.c Sun Feb 25 16:25:21 2001
@@ -0,0 +1,32 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+ped_device_open (PedDevice* dev)
+{
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ if (dev->open_count++)
+ return _do_refresh_open (dev);
+
+ return _do_open (dev);
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-probe-all.c
parted-1.5.1-pre1/libparted/device/device-probe-all.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-probe-all.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device-probe-all.c Sun Feb 25 16:25:22
+2001
@@ -0,0 +1,27 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+void
+ped_device_probe_all ()
+{
+ probe_proc_partitions ();
+ probe_standard_devices ();
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-remove.c
parted-1.5.1-pre1/libparted/device/device-remove.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-remove.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-remove.c Sun Feb 25 16:25:27 2001
@@ -0,0 +1,36 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+void
+ped_device_remove (PedDevice* dev)
+{
+ PedDevice* walk;
+ PedDevice* last = NULL;
+
+ for (walk = devices; walk != NULL; last = walk, walk = walk->next) {
+ if (walk == dev) break;
+ }
+
+ if (last)
+ last->next = dev->next;
+ else
+ devices = dev->next;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device-stat.c
parted-1.5.1-pre1/libparted/device/device-stat.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device-stat.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/device-stat.c Wed Feb 28 15:44:57 2001
@@ -0,0 +1,48 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+int
+ped_device_stat (PedDevice* dev, struct stat * dev_stat)
+{
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ while (1) {
+ if (!stat (dev->path, dev_stat)) {
+ return 1;
+ } else {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("Could not stat device %s - %s."),
+ dev->path,
+ strerror (errno))
+ != PED_EXCEPTION_RETRY)
+ return 0;
+ }
+ }
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/device.c
parted-1.5.1-pre1/libparted/device/device.c
--- parted-1.5.1-pre1-vanilla/libparted/device/device.c Thu Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/device.c Sun Feb 25 17:18:25 2001
@@ -0,0 +1,25 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include <stdlib.h>
+
+#include "priv.h"
+
+PedDevice* devices = NULL;
+
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/do-refresh-close.c
parted-1.5.1-pre1/libparted/device/do-refresh-close.c
--- parted-1.5.1-pre1-vanilla/libparted/device/do-refresh-close.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/do-refresh-close.c Sun Feb 25 16:25:38
+2001
@@ -0,0 +1,26 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+_do_refresh_close (PedDevice* dev)
+{
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/do-refresh-open.c
parted-1.5.1-pre1/libparted/device/do-refresh-open.c
--- parted-1.5.1-pre1-vanilla/libparted/device/do-refresh-open.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/do-refresh-open.c Wed Feb 28 15:45:55
+2001
@@ -0,0 +1,27 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+_do_refresh_open (PedDevice* dev)
+{
+ _flush_cache (dev);
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/Makefile.am
parted-1.5.1-pre1/libparted/device/gnu/Makefile.am
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/Makefile.am Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/gnu/Makefile.am Fri Mar 2 18:41:44 2001
@@ -0,0 +1,22 @@
+partedincludedir = -I$(top_srcdir)/libparted/device
+-I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libarch.la
+libarch_la_SOURCES = device-check.c \
+ device-get-length.c \
+ device-get-sector-size.c \
+ device-new.c \
+ device-probe-geometry.c \
+ device-probe-type.c \
+ device-read.c \
+ device-sync.c \
+ device-write.c \
+ do-close.c \
+ do-open.c \
+ flush-cache.c \
+ kernel-reread-part-table.c \
+ probe-proc-partitions.c \
+ probe-standard-partitions.c
+
+libarch_la_LDFLAGS = -lstore -lshouldbeinlibc
+
+INCLUDES = $(partedincludedir) @INTLINCS@
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-check.c
parted-1.5.1-pre1/libparted/device/gnu/device-check.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-check.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-check.c Wed Feb 28 19:46:25
+2001
@@ -0,0 +1,36 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+/* returns the number of sectors that are ok.
+ */
+PedSector
+ped_device_check (PedDevice* dev, void* buffer, PedSector start,
+ PedSector count)
+{
+ int status;
+ int done = 0;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (buffer != NULL, return 0);
+
+ return count;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-get-length.c
parted-1.5.1-pre1/libparted/device/gnu/device-get-length.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-get-length.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-get-length.c Tue Mar 6 19:21:10
+2001
@@ -0,0 +1,36 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+/* TODO: do a binary search if BLKGETSIZE doesn't work?! */
+PedSector
+device_get_length (PedDevice* dev)
+{
+ struct peropen *po = dev->po;
+
+ PED_ASSERT (dev->open_count, return 0);
+
+ if (po->store->block_size == PED_SECTOR_SIZE)
+ return po->store->blocks;
+ else
+ return (po->store->size + PED_SECTOR_SIZE - 1)
+ / PED_SECTOR_SIZE;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-get-sector-size.c
parted-1.5.1-pre1/libparted/device/gnu/device-get-sector-size.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-get-sector-size.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-get-sector-size.c Tue Mar 6
+19:01:29 2001
@@ -0,0 +1,31 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+int
+device_get_sector_size (PedDevice* dev)
+{
+ struct peropen *po = dev->po;
+
+ PED_ASSERT (dev->open_count, return 0);
+
+ return PED_SECTOR_SIZE;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-new.c
parted-1.5.1-pre1/libparted/device/gnu/device-new.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-new.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-new.c Tue Mar 6 18:58:42 2001
@@ -0,0 +1,122 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <string.h>
+#include <errno.h>
+
+static int
+init_file (PedDevice* dev)
+{
+ PedExceptionOption ex_status;
+
+retry_open:
+ if (!ped_device_open (dev)) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("Unable to open %s."),
+ dev->path);
+ switch (ex_status) {
+ case PED_EXCEPTION_RETRY:
+ goto retry_open;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ goto error;
+ }
+
+ return 0;
+ }
+
+retry_probe:
+ if (!device_probe_geometry (dev)) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("Unable to probe store."));
+ switch (ex_status) {
+ case PED_EXCEPTION_RETRY:
+ goto retry_probe;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ goto error_close_dev;
+ }
+
+ return 0;
+ }
+
+ dev->model = "";
+
+ ped_device_close (dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (dev);
+error:
+ return 0;
+}
+
+PedDevice*
+ped_device_new (const char* path)
+{
+ PedDevice* dev;
+
+ PED_ASSERT (path != NULL, return NULL);
+
+ dev = (PedDevice*) ped_malloc (sizeof (PedDevice));
+ if (!dev)
+ goto error;
+
+ dev->path = strdup (path);
+ if (! dev->path)
+ goto error_free_dev;
+ dev->open_count = 0;
+ dev->external_mode = 0;
+ dev->dirty = 0;
+ dev->boot_dirty = 0;
+ dev->geom_known = 1;
+ dev->geom_already_guessed = 0;
+
+ ped_exception_fetch_all ();
+ if (!device_probe_type (dev)
+ || dev->type != PED_DEVICE_FILE) {
+ ped_exception_throw (PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_CANCEL,
+ _("ped_device_new() Unsupported device type"));
+ goto error_free_path;
+ } else
+ ped_exception_leave_all ();
+
+ if (!init_file (dev))
+ goto error_free_dev;
+
+ return dev;
+
+error_free_path:
+ ped_free (dev->path);
+error_free_dev:
+ ped_free (dev);
+error:
+ return NULL;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-probe-geometry.c
parted-1.5.1-pre1/libparted/device/gnu/device-probe-geometry.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-probe-geometry.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-probe-geometry.c Sat Mar 3
+19:31:47 2001
@@ -0,0 +1,41 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+device_probe_geometry (PedDevice* dev)
+{
+ dev->length = device_get_length (dev);
+ if (!dev->length)
+ return 0;
+
+ dev->sector_size = device_get_sector_size (dev);
+ if (!dev->sector_size)
+ return 0;
+
+ /* XXX: We have no way to get this! */
+ dev->sectors = 32;
+ dev->heads = 4;
+ dev->geom_known = 0;
+ dev->cylinders = dev->length / (dev->heads * dev->sectors
+ * (dev->sector_size / PED_SECTOR_SIZE));
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-probe-type.c
parted-1.5.1-pre1/libparted/device/gnu/device-probe-type.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-probe-type.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-probe-type.c Sat Mar 3 18:04:26
+2001
@@ -0,0 +1,28 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+device_probe_type (PedDevice* dev)
+{
+ dev->type = PED_DEVICE_FILE;
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-read.c
parted-1.5.1-pre1/libparted/device/gnu/device-read.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-read.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-read.c Sat Mar 3 13:53:14
+2001
@@ -0,0 +1,116 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <error.h>
+#include <mach.h>
+
+int
+ped_device_read (const PedDevice* dev, void* user_buffer,
+ PedSector device_start, PedSector count)
+{
+ error_t err;
+ PedExceptionOption ex_status;
+ struct peropen *po;
+ size_t start;
+ size_t store_start_block;
+ /* In bytes. This can be larger than COUNT when store pages are
+ larger than PED_SECTOR_SIZE. */
+ size_t store_read_length;
+ void * store_read_buffer;
+ size_t have_read;
+ size_t read_offset;
+ size_t device_read_length = count * PED_SECTOR_SIZE;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (user_buffer != NULL, return 0);
+
+ po = dev->po;
+
+ start = device_start * PED_SECTOR_SIZE;
+ if (PED_SECTOR_SIZE != po->store->block_size) {
+ store_start_block = start / po->store->block_size;
+ store_read_length = (device_read_length
+ + po->store->block_size - 1)
+ / po->store->block_size;
+ } else {
+ store_start_block = device_start;
+ store_read_length = device_read_length;
+ }
+
+ read_offset = start - store_start_block * po->store->block_size;
+
+ if (store_read_length % po->store->block_size != 0)
+ store_read_length = store_read_length + po->store->block_size
+ - store_read_length % po->store->block_size;
+
+retry:
+ have_read = 0;
+ while (1) {
+ size_t did_read;
+ size_t offset;
+
+ err = store_read (po->store, store_start_block,
+ store_read_length - have_read,
+ &store_read_buffer, &did_read);
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during read on %s"),
+ strerror (err),
+ dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ goto retry;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ memcpy (user_buffer + have_read - read_offset,
+ store_read_buffer
+ + (have_read >= read_offset
+ ? 0 : read_offset - have_read),
+ have_read + did_read > device_read_length + read_offset
+ ? device_read_length + read_offset - have_read
+ : did_read);
+
+ vm_deallocate (mach_task_self (), store_read_buffer, did_read);
+
+ have_read += did_read;
+ store_start_block += did_read / po->store->block_size;
+
+ if (have_read >= device_read_length)
+ break;
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-sync.c
parted-1.5.1-pre1/libparted/device/gnu/device-sync.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-sync.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-sync.c Tue Mar 6 19:36:56
+2001
@@ -0,0 +1,73 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+#include <hurd/fs.h>
+
+int
+ped_device_sync (PedDevice* dev)
+{
+ error_t err;
+ PedExceptionOption ex_status;
+ struct peropen *po = dev->po;
+ static char *last_failure = NULL;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ if (dev->read_only || ! dev->dirty)
+ return 1;
+
+ while (1) {
+ err = file_sync (po->store->source, 1, 0);
+ if (! err || err == EOPNOTSUPP || err == EPERM
+ || (last_failure && strcmp (last_failure, dev->path) == 0))
+ break;
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s trying to sync %s to disk"),
+ strerror (errno), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ if (last_failure)
+ free (last_failure);
+ last_failure = strdup (dev->path);
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-write.c
parted-1.5.1-pre1/libparted/device/gnu/device-write.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/device-write.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/device-write.c Tue Mar 6 19:18:13
+2001
@@ -0,0 +1,260 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <error.h>
+#include <string.h>
+#include <mach.h>
+#include <hurd/store.h>
+
+int
+ped_device_write (PedDevice* dev, const void* buffer, PedSector start,
+ PedSector count)
+{
+ error_t err;
+ PedExceptionOption ex_status;
+ struct peropen* po;
+ void * temp;
+ size_t did_read;
+ size_t did_write;
+
+
+ /* Map a disk sector to a store sector. */
+ #define PED_TO_STORE(store, sector) (((sector) * PED_SECTOR_SIZE) \
+ / (store)->block_size)
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (buffer != NULL, return 0);
+
+ po = dev->po;
+
+ if (dev->read_only) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Can't write to %s, because it is opened read-only."),
+ dev->path)
+ != PED_EXCEPTION_IGNORE)
+ return 0;
+ else
+ return 1;
+ }
+
+#ifdef READONLY
+ printf ("ped_device_write (\"%s\", %p, %d, %d)\n",
+ dev->path, buffer, (int) start, (int) count);
+#else
+ dev->dirty = 1;
+
+ /* If the first ``device'' block (PedSector) is not aligned on a
+ store block, then we need to fetch the old block, copy in the
+ overlaping area and finally, write the modified data out to the
+ store. */
+ if ((PED_SECTOR_SIZE * start) % po->store->block_size != 0) {
+ size_t write_offset;
+ size_t flushing;
+
+doggy_first_block_read:
+ /* We do not bother looping as we are only reading a
+ single block. */
+ err = store_read (po->store,
+ PED_TO_STORE (po->store, start),
+ po->store->block_size, &temp,
+ &did_read);
+ if (! err && did_read != po->store->block_size)
+ err = EIO;
+
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during read on %s"),
+ strerror (err), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ break;
+
+ case PED_EXCEPTION_RETRY:
+ goto doggy_first_block_read;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ write_offset = (start * PED_SECTOR_SIZE)
+ % po->store->block_size;
+ flushing = po->store->block_size - write_offset;
+ if (flushing > count * PED_SECTOR_SIZE)
+ flushing = count * PED_SECTOR_SIZE;
+
+ memcpy (temp + write_offset, buffer, flushing);
+
+doggy_first_block_write:
+ err = store_write (po->store,
+ PED_TO_STORE (po->store, start),
+ temp, po->store->block_size,
+ &did_write);
+ if (! err && did_write != po->store->block_size)
+ err = EIO;
+
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during write on %s"),
+ strerror (err), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ break;
+
+ case PED_EXCEPTION_RETRY:
+ goto doggy_first_block_write;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ vm_deallocate (mach_task_self (), temp,
+ did_read);
+ return 0;
+ }
+ }
+
+ start += flushing / PED_SECTOR_SIZE;
+ count -= flushing / PED_SECTOR_SIZE;
+ buffer += write_offset;
+
+ vm_deallocate (mach_task_self (), temp, did_read);
+
+ if (count == 0)
+ return 1;
+ }
+
+ while (count > 0 && count >= po->store->block_size / PED_SECTOR_SIZE) {
+ err = store_write (po->store, PED_TO_STORE (po->store, start),
+ buffer, count * PED_SECTOR_SIZE,
+ &did_write);
+
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during write on %s"),
+ strerror (err), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ break;
+
+ case PED_EXCEPTION_RETRY:
+ continue;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ start += did_write / PED_SECTOR_SIZE;
+ count -= did_write / PED_SECTOR_SIZE;
+ buffer += did_write;
+ }
+
+ if (count == 0)
+ return 1;
+
+ /* We are now left with (strictly) less then a store block to write
+ to disk. Thus, we read the block, overlay the buffer and flush. */
+ PED_ASSERT (count * PED_SECTOR_SIZE < po->store->block_size, return 0);
+
+doggy_last_block_read:
+ /* We do not bother looping as we are only reading a
+ single block. */
+ err = store_read (po->store,
+ PED_TO_STORE (po->store, start),
+ po->store->block_size, &temp,
+ &did_read);
+ if (! err && did_read != po->store->block_size)
+ err = EIO;
+
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during read on %s"),
+ strerror (err), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ break;
+
+ case PED_EXCEPTION_RETRY:
+ goto doggy_last_block_read;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ memcpy (temp, buffer, count * PED_SECTOR_SIZE);
+
+doggy_last_block_write:
+ err = store_write (po->store,
+ PED_TO_STORE (po->store, start),
+ temp, po->store->block_size,
+ &did_write);
+ if (! err && did_write != po->store->block_size)
+ err = EIO;
+
+ if (err) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during write on %s"),
+ strerror (err), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ break;
+
+ case PED_EXCEPTION_RETRY:
+ goto doggy_last_block_write;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ vm_deallocate (mach_task_self (), temp,
+ did_read);
+ return 0;
+ }
+ }
+
+#endif
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/do-close.c
parted-1.5.1-pre1/libparted/device/gnu/do-close.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/do-close.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/gnu/do-close.c Sat Mar 3 18:05:41 2001
@@ -0,0 +1,84 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <hurd/store.h>
+
+int
+_do_close (PedDevice* dev)
+{
+ struct peropen *po;
+
+ po = dev->po;
+
+ _flush_cache (dev);
+
+ if (dev->dirty && dev->type != PED_DEVICE_FILE) {
+ if (_kernel_reread_part_table (dev))
+ dev->dirty = 0;
+ }
+
+ if (dev->dirty && dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
+ /* ouch! */
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("The partition table was unable to be reread, "
+ "as such, you need to reboot before mounting any "
+ "modified partitions. You also need to reinstall "
+ "your boot loader before you reboot (which may "
+ "require mounting modified partitions). It is "
+ "impossible do both things! So you'll need to "
+ "boot off a rescue disk, and reinstall your boot "
+ "loader from the rescue disk. Read section 4 of "
+ "the Parted User documentation for more "
+ "information."));
+ store_free (po->store);
+ return 1;
+ }
+
+ if (dev->dirty && dev->type != PED_DEVICE_FILE) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("The partition table on %s (%s). This means "
+ "the Hurd knows nothing about any modifications "
+ "you made. You should reboot your computer "
+ "before doing anything with %s."),
+ dev->path, strerror (errno), dev->path);
+ }
+
+ if (dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("You should reinstall your boot loader before "
+ "rebooting. Read section 4 of the Parted User "
+ "documentation for more information."));
+ }
+
+ store_free (po->store);
+ ped_free (po);
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/do-open.c
parted-1.5.1-pre1/libparted/device/gnu/do-open.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/do-open.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/gnu/do-open.c Sat Mar 3 12:24:39 2001
@@ -0,0 +1,71 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <error.h>
+#include <string.h>
+#include <stdlib.h>
+#include <hurd/store.h>
+
+int
+_do_open (PedDevice* dev)
+{
+ error_t err;
+ struct peropen *po;
+ char* rw_error_msg;
+
+ dev->po = po = ped_malloc (sizeof (struct peropen));
+ if (! po)
+ return ENOMEM;
+
+retry:
+ err = store_open (dev->path, 0, NULL, &po->store);
+ if (err) {
+ rw_error_msg = strerror (err);
+
+ err = store_open (dev->path, STORE_READONLY, NULL,
+ &po->store);
+ if (err) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("Error opening %s: %s"),
+ dev->path, strerror (err))
+ != PED_EXCEPTION_RETRY) {
+ ped_free (po);
+ return 0;
+ } else
+ goto retry;
+ } else {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("Unable to open %s read-write (%s). %s has "
+ "been opened read-only."),
+ dev->path, rw_error_msg, dev->path);
+ dev->read_only = 1;
+ }
+ } else {
+ dev->read_only = 0;
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/flush-cache.c
parted-1.5.1-pre1/libparted/device/gnu/flush-cache.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/flush-cache.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/flush-cache.c Sun Feb 25 20:23:43
+2001
@@ -0,0 +1,39 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <hurd/fs.h>
+
+void
+_flush_cache (PedDevice* dev)
+{
+ struct peropen *po = dev->po;
+
+ /* XXX Ignore this? */
+ if (! dev->open_count)
+ return;
+
+ if (dev->read_only)
+ return;
+
+ /* Wait for a complete sync to finish. */
+ file_sync (po->store->source, 1, 0);
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/kernel-reread-part-table.c
parted-1.5.1-pre1/libparted/device/gnu/kernel-reread-part-table.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/kernel-reread-part-table.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/kernel-reread-part-table.c Sun Feb 25
+20:25:04 2001
@@ -0,0 +1,27 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+_kernel_reread_part_table (PedDevice* dev)
+{
+ /* XXX: We must wait for partfs to be finished. */
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/peropen.h
parted-1.5.1-pre1/libparted/device/gnu/peropen.h
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/peropen.h Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/gnu/peropen.h Wed Feb 28 15:48:36 2001
@@ -0,0 +1,32 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __DEVICE_HURD_PEROPEN_H__
+#define __DEVICE_HURD_PEROPEN_H__
+
+#define _GNU_SOURCE 1
+#include <hurd.h>
+#include <hurd/store.h>
+
+struct peropen
+{
+ struct store *store;
+};
+
+#endif /* __DEVICE_HURD_PEROPEN_H__ */
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/probe-proc-partitions.c
parted-1.5.1-pre1/libparted/device/gnu/probe-proc-partitions.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/probe-proc-partitions.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/probe-proc-partitions.c Sun Feb 25
+20:25:53 2001
@@ -0,0 +1,26 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+probe_proc_partitions ()
+{
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/gnu/probe-standard-partitions.c
parted-1.5.1-pre1/libparted/device/gnu/probe-standard-partitions.c
--- parted-1.5.1-pre1-vanilla/libparted/device/gnu/probe-standard-partitions.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/gnu/probe-standard-partitions.c Sun Feb 25
+20:27:22 2001
@@ -0,0 +1,42 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+probe_standard_devices ()
+{
+ probe ("/dev/sd0");
+ probe ("/dev/sd1");
+ probe ("/dev/sd2");
+ probe ("/dev/sd3");
+ probe ("/dev/sd4");
+ probe ("/dev/sd5");
+
+ probe ("/dev/hd0");
+ probe ("/dev/hd1");
+ probe ("/dev/hd2");
+ probe ("/dev/hd3");
+ probe ("/dev/hd4");
+ probe ("/dev/hd5");
+ probe ("/dev/hd6");
+ probe ("/dev/hd7");
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/Makefile.am
parted-1.5.1-pre1/libparted/device/linux/Makefile.am
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/Makefile.am Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/Makefile.am Thu Mar 1 22:59:29
+2001
@@ -0,0 +1,23 @@
+partedincludedir = -I$(top_srcdir)/libparted/device
+-I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libarch.la
+libarch_la_SOURCES = device-check.c \
+ device-get-length.c \
+ device-get-sector-size.c \
+ device-new.c \
+ device-probe-geometry.c \
+ device-probe-type.c \
+ device-read.c \
+ device-sync.c \
+ device-write.c \
+ do-close.c \
+ do-open.c \
+ do-seek.c \
+ flush-cache.c \
+ kernel-reread-part-table.c \
+ llseek.c \
+ llseek.h \
+ probe-proc-partitions.c \
+ probe-standard-partitions.c
+
+INCLUDES = $(partedincludedir) @INTLINCS@
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/arch.h
parted-1.5.1-pre1/libparted/device/linux/arch.h
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/arch.h Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/arch.h Tue Mar 6 17:50:48 2001
@@ -0,0 +1,33 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __DEVICE_LINUX_ARCH_H__
+#define __DEVICE_LINUX_ARCH_H__
+
+#include "priv.h"
+
+/* from <linux/fs.h> */
+#define BLKRRPART _IO(0x12,95) /* re-read partition table */
+#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
+#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
+
+int _do_device_seek (const PedDevice* dev, PedSector sector);
+
+#endif /* __DEVICE_LINUX_ARCH_H__ */
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-check.c
parted-1.5.1-pre1/libparted/device/linux/device-check.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-check.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-check.c Wed Feb 28 15:52:32
+2001
@@ -0,0 +1,59 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* returns the number of sectors that are ok.
+ */
+PedSector
+ped_device_check (PedDevice* dev, void* buffer, PedSector start,
+ PedSector count)
+{
+ int status;
+ int done = 0;
+ struct peropen *po;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (buffer != NULL, return 0);
+
+ po = dev->po;
+
+ if (!_do_device_seek (dev, start))
+ return 0;
+
+ while (1) {
+ status = read (po->fd, buffer, (count-done) * PED_SECTOR_SIZE);
+ if (status < 0)
+ return 0;
+
+ done += status / PED_SECTOR_SIZE;
+ if (done == count * PED_SECTOR_SIZE)
+ break;
+ else
+ continue;
+ }
+
+ return count;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-get-length.c
parted-1.5.1-pre1/libparted/device/linux/device-get-length.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-get-length.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-get-length.c Tue Mar 6
+20:05:16 2001
@@ -0,0 +1,50 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <string.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+
+/* TODO: do a binary search if BLKGETSIZE doesn't work?! */
+PedSector
+device_get_length (PedDevice* dev)
+{
+ unsigned long size;
+ struct peropen *po;
+
+ PED_ASSERT (dev->open_count, return 0);
+
+ po = dev->po;
+
+ if (ioctl (po->fd, BLKGETSIZE, &size)) {
+ ped_exception_throw (
+ PED_EXCEPTION_BUG,
+ PED_EXCEPTION_CANCEL,
+ _("Unable to determine the size of %s (%s)"),
+ dev->path,
+ strerror (errno));
+ return 0;
+ }
+
+ return size;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-get-sector-size.c
parted-1.5.1-pre1/libparted/device/linux/device-get-sector-size.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-get-sector-size.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-get-sector-size.c Tue Mar 6
+20:05:32 2001
@@ -0,0 +1,76 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <stdio.h>
+#include <sys/ioctl.h>
+
+static int
+_get_linux_version ()
+{
+ FILE* f;
+ int major;
+ int minor;
+
+ f = fopen ("/proc/sys/kernel/osrelease", "r");
+ if (!f)
+ return 0;
+ if (fscanf (f, "%d.%d.", &major, &minor) != 2)
+ return 0;
+ fclose (f);
+
+ return major * 0x100 + minor;
+}
+
+int
+device_get_sector_size (PedDevice* dev)
+{
+ int sector_size;
+ struct peropen *po;
+
+ PED_ASSERT (dev->open_count, return 0);
+
+ po = dev->po;
+
+ if (_get_linux_version() < 0x203) /* BLKSSZGET is broken < 2.3.x */
+ return PED_SECTOR_SIZE;
+ if (ioctl (po->fd, BLKSSZGET, §or_size))
+ return PED_SECTOR_SIZE;
+
+ if (sector_size != PED_SECTOR_SIZE) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_BUG,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("The sector size on %s is %d bytes. Parted is known "
+ "not to work properly with drives with sector sizes "
+ "other than %d bytes"),
+ dev->path,
+ sector_size,
+ PED_SECTOR_SIZE)
+ == PED_EXCEPTION_IGNORE)
+ return sector_size;
+ else
+ return 0;
+ }
+
+ return sector_size;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-new.c
parted-1.5.1-pre1/libparted/device/linux/device-new.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-new.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-new.c Sat Mar 3 17:47:25
+2001
@@ -0,0 +1,315 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <scsi/scsi.h>
+
+#include <linux/hdreg.h>
+
+#ifndef SCSI_IOCTL_SEND_COMMAND
+#define SCSI_IOCTL_SEND_COMMAND 1
+#endif
+
+static char*
+strip_name(char* n)
+{
+ int len = strlen (n);
+ int end = 0;
+ int i = 0;
+
+ while (i < len) {
+ if ((n[i] != ' ') || ((n[i] == ' ') && (n[i + 1] != ' '))) {
+ n[end] = n[i];
+ end++;
+ }
+ i++;
+ }
+ n[end] = 0;
+ return (strdup(n));
+}
+
+static int
+init_ide (PedDevice* dev)
+{
+ struct stat dev_stat;
+ int dev_major;
+ struct hd_driveid hdi;
+ PedExceptionOption ex_status;
+ struct peropen *po;
+
+ if (!ped_device_stat (dev, &dev_stat))
+ goto error;
+
+ dev_major = major (dev_stat.st_rdev);
+
+ if (!ped_device_open (dev))
+ goto error;
+
+ po = dev->po;
+
+ if (ioctl (po->fd, HDIO_GET_IDENTITY, &hdi)) {
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Could not get identity of device %s - %s"),
+ dev->path, strerror (errno));
+ switch (ex_status) {
+ case PED_EXCEPTION_CANCEL:
+ goto error_close_dev;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_IGNORE:
+ dev->model = strdup(_("unknown"));
+ }
+ } else {
+ dev->model = strip_name (hdi.model);
+ }
+
+ if (!device_probe_geometry (dev))
+ goto error_close_dev;
+
+ ped_device_close (dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (dev);
+error:
+ return 0;
+}
+
+static int
+init_scsi (PedDevice* dev)
+{
+ unsigned char idlun [8];
+ unsigned char buffer [128];
+ unsigned char* cmd;
+ struct hd_geometry geometry;
+ struct peropen *po;
+
+ if (!ped_device_open (dev))
+ goto error;
+
+ po = dev->po;
+
+ memset (buffer, 0, 96);
+
+ *((int *) buffer) = 0; /* length of input data */
+ *(((int *) buffer) + 1) = 96; /* length of output buffer */
+
+ cmd = (char *) (((int *) buffer) + 2);
+
+ cmd[0] = 0x12; /* INQUIRY */
+ cmd[1] = 0x00; /* lun=0, evpd=0 */
+ cmd[2] = 0x00; /* page code = 0 */
+ cmd[3] = 0x00; /* (reserved) */
+ cmd[4] = 96; /* allocation length */
+ cmd[5] = 0x00; /* control */
+
+ if (ioctl(po->fd, SCSI_IOCTL_SEND_COMMAND, buffer)) {
+ buffer[40] = 0;
+ dev->model = strip_name (buffer + 16);
+ } else {
+ dev->model = _("Unknown SCSI");
+ }
+
+ if (ioctl (po->fd, SCSI_IOCTL_GET_IDLUN, idlun)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_CANCEL,
+ _("Error initialising SCSI device "
+ "%s - %s"),
+ dev->path, strerror (errno));
+ goto error_close_dev;
+ }
+
+ if (!device_probe_geometry (dev))
+ goto error_close_dev;
+
+ dev->host = *((unsigned long *) (idlun + 4));
+ dev->did = idlun [0];
+
+ ped_device_close (dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (dev);
+error:
+ return 0;
+}
+
+static int
+init_file (PedDevice* dev)
+{
+ struct stat dev_stat;
+
+ if (!ped_device_stat (dev, &dev_stat))
+ return 0;
+
+ dev->length = dev_stat.st_size / 512;
+ dev->cylinders = dev->length / 4 / 32;
+ dev->heads = 4;
+ dev->sectors = 32;
+ dev->sector_size = 512;
+ dev->geom_known = 0;
+ dev->model = "";
+ return 1;
+}
+
+static int
+init_generic (PedDevice* dev, char* model_name)
+{
+ struct stat dev_stat;
+ PedExceptionOption ex_status;
+
+ if (!ped_device_stat (dev, &dev_stat))
+ goto error;
+
+ if (!ped_device_open (dev))
+ goto error;
+
+ ped_exception_fetch_all ();
+ if (device_probe_geometry (dev)) {
+ ped_exception_leave_all ();
+ } else {
+ /* hack to allow use of files, for testing */
+ ped_exception_catch ();
+ ped_exception_leave_all ();
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Unable to determine geometry of "
+ "file/device. You should not use Parted "
+ "unless you REALLY know what you're doing!"));
+ switch (ex_status) {
+ case PED_EXCEPTION_CANCEL:
+ goto error_close_dev;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_IGNORE:
+ }
+
+ /* what should we stick in here? */
+ dev->length = dev_stat.st_size / PED_SECTOR_SIZE;
+ dev->cylinders = dev->length / 4 / 32;
+ dev->heads = 4;
+ dev->sectors = 32;
+ dev->sector_size = PED_SECTOR_SIZE;
+ dev->geom_known = 0;
+ }
+
+ dev->model = model_name;
+
+ ped_device_close (dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (dev);
+error:
+ return 0;
+}
+
+PedDevice*
+ped_device_new (const char* path)
+{
+ PedDevice* dev;
+
+ PED_ASSERT (path != NULL, return NULL);
+
+ dev = (PedDevice*) ped_malloc (sizeof (PedDevice));
+ if (!dev)
+ goto error;
+
+ dev->path = strdup (path);
+ if (! dev->path)
+ goto error_free_dev;
+
+ dev->open_count = 0;
+ dev->external_mode = 0;
+ dev->dirty = 0;
+ dev->boot_dirty = 0;
+ dev->geom_known = 1;
+ dev->geom_already_guessed = 0;
+
+ if (!device_probe_type (dev))
+ goto error_free_path;
+
+ switch (dev->type) {
+ case PED_DEVICE_IDE:
+ if (!init_ide (dev))
+ goto error_free_path;
+ break;
+
+ case PED_DEVICE_SCSI:
+ if (!init_scsi (dev))
+ goto error_free_path;
+ break;
+
+ case PED_DEVICE_DAC960:
+ if (!init_generic (dev, _("DAC960 RAID controller")))
+ goto error_free_path;
+ break;
+
+ case PED_DEVICE_CPQARRAY:
+ if (!init_generic (dev, _("Compaq Smart Array")))
+ goto error_free_path;
+ break;
+
+ case PED_DEVICE_FILE:
+ if (!init_file (dev))
+ goto error_free_dev;
+ break;
+
+ case PED_DEVICE_UNKNOWN:
+ if (ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Device %s is neither a SCSI nor IDE drive."),
+ dev->path)
+ == PED_EXCEPTION_CANCEL)
+ goto error_free_path;
+ if (!init_generic (dev, _("Unknown")))
+ goto error_free_path;
+ break;
+
+ default:
+ ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
+ PED_EXCEPTION_CANCEL,
+ _("ped_device_new() Unsupported device type"));
+ goto error_free_path;
+ }
+ return dev;
+
+error_free_path:
+ free (dev->path);
+error_free_dev:
+ ped_free (dev);
+error:
+ return NULL;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-probe-geometry.c
parted-1.5.1-pre1/libparted/device/linux/device-probe-geometry.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-probe-geometry.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-probe-geometry.c Tue Mar 6
+20:06:37 2001
@@ -0,0 +1,76 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <linux/hdreg.h>
+
+int
+device_probe_geometry (PedDevice* dev)
+{
+ struct stat dev_stat;
+ struct hd_geometry geometry;
+ struct peropen *po;
+
+ po = dev->po;
+
+ if (!ped_device_stat (dev, &dev_stat))
+ goto error;
+ PED_ASSERT (S_ISBLK (dev_stat.st_mode), goto error);
+
+ dev->length = device_get_length (dev);
+ if (!dev->length)
+ goto error;
+
+ if (ioctl (po->fd, HDIO_GETGEO, &geometry)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_CANCEL,
+ _("Could not read geometry of %s - %s."),
+ dev->path, strerror (errno));
+ goto error;
+ }
+
+ dev->sector_size = device_get_sector_size (dev);
+ if (!dev->sector_size)
+ goto error;
+
+ dev->sectors = geometry.sectors;
+ dev->heads = geometry.heads;
+ if (!dev->sectors || !dev->heads)
+ goto error_dodgey_geometry;
+
+ dev->cylinders = dev->length / (dev->heads * dev->sectors
+ * (dev->sector_size / PED_SECTOR_SIZE));
+
+ return 1;
+
+error_dodgey_geometry:
+ ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_CANCEL,
+ _("Device %s has dodgey geometry."),
+ dev->path);
+error:
+ return 0;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-probe-type.c
parted-1.5.1-pre1/libparted/device/linux/device-probe-type.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-probe-type.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-probe-type.c Sat Mar 3
+18:07:40 2001
@@ -0,0 +1,110 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <sys/stat.h>
+
+/* from <linux/major.h> */
+#define IDE0_MAJOR 3
+#define IDE1_MAJOR 22
+#define IDE2_MAJOR 33
+#define IDE3_MAJOR 34
+#define IDE4_MAJOR 56
+#define IDE5_MAJOR 57
+#define SCSI_CDROM_MAJOR 11
+#define SCSI_DISK0_MAJOR 8
+#define SCSI_DISK1_MAJOR 65
+#define SCSI_DISK2_MAJOR 66
+#define SCSI_DISK3_MAJOR 67
+#define SCSI_DISK4_MAJOR 68
+#define SCSI_DISK5_MAJOR 69
+#define SCSI_DISK6_MAJOR 70
+#define SCSI_DISK7_MAJOR 71
+#define COMPAQ_SMART2_MAJOR 72
+#define COMPAQ_SMART2_MAJOR1 73
+#define COMPAQ_SMART2_MAJOR2 74
+#define COMPAQ_SMART2_MAJOR3 75
+#define COMPAQ_SMART2_MAJOR4 76
+#define COMPAQ_SMART2_MAJOR5 77
+#define COMPAQ_SMART2_MAJOR6 78
+#define COMPAQ_SMART2_MAJOR7 79
+#define DAC960_MAJOR 48
+
+#define SCSI_BLK_MAJOR(M) ( \
+ (M) == SCSI_DISK0_MAJOR \
+ || (M) == SCSI_CDROM_MAJOR \
+ || ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR))
+
+static int
+_is_ide_major (int major)
+{
+ switch (major) {
+ case IDE0_MAJOR:
+ case IDE1_MAJOR:
+ case IDE2_MAJOR:
+ case IDE3_MAJOR:
+ case IDE4_MAJOR:
+ case IDE5_MAJOR:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+static int
+_is_cpqarray_major (int major)
+{
+ return COMPAQ_SMART2_MAJOR <= major && major <= COMPAQ_SMART2_MAJOR7;
+}
+
+int
+device_probe_type (PedDevice* dev)
+{
+ struct stat dev_stat;
+ int dev_major;
+ int dev_minor;
+ PedExceptionOption ex_status;
+
+ if (!ped_device_stat (dev, &dev_stat))
+ return 0;
+
+ if (!S_ISBLK(dev_stat.st_mode)) {
+ dev->type = PED_DEVICE_FILE;
+ return 1;
+ }
+
+ dev_major = major (dev_stat.st_rdev);
+ dev_minor = minor (dev_stat.st_rdev);
+
+ if (SCSI_BLK_MAJOR (dev_major) && (dev_minor % 0x10 == 0)) {
+ dev->type = PED_DEVICE_SCSI;
+ } else if (_is_ide_major (dev_major) && (dev_minor % 0x40 == 0)) {
+ dev->type = PED_DEVICE_IDE;
+ } else if (dev_major == DAC960_MAJOR && (dev_minor % 0x8 == 0)) {
+ dev->type = PED_DEVICE_DAC960;
+ } else if (_is_cpqarray_major (dev_major) && (dev_minor % 0x10 == 0)) {
+ dev->type = PED_DEVICE_CPQARRAY;
+ } else {
+ dev->type = PED_DEVICE_FILE;
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-read.c
parted-1.5.1-pre1/libparted/device/linux/device-read.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-read.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-read.c Wed Feb 28 16:03:19
+2001
@@ -0,0 +1,98 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+int
+ped_device_read (const PedDevice* dev, void* buffer, PedSector start,
+ PedSector count)
+{
+ int status;
+ PedExceptionOption ex_status;
+ size_t read_length = count * PED_SECTOR_SIZE;
+ struct peropen *po;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (buffer != NULL, return 0);
+
+ po = dev->po;
+
+ while (1) {
+ if (_do_device_seek (dev, start))
+ break;
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during seek for read on %s"),
+ strerror (errno), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ while (1) {
+ status = read (po->fd, buffer, read_length);
+ if (status == count * PED_SECTOR_SIZE) break;
+ if (status > 0) {
+ read_length -= status;
+ buffer += status;
+ continue;
+ }
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during read on %s"),
+ strerror (errno),
+ dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-sync.c
parted-1.5.1-pre1/libparted/device/linux/device-sync.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-sync.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-sync.c Wed Feb 28 16:07:47
+2001
@@ -0,0 +1,68 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+ped_device_sync (PedDevice* dev)
+{
+ int status;
+ PedExceptionOption ex_status;
+ struct peropen *po;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ po = dev->po;
+
+ if (dev->read_only)
+ return 1;
+
+ while (1) {
+ status = fsync (po->fd);
+ if (status >= 0) break;
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during write on %s"),
+ strerror (errno), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/device-write.c
parted-1.5.1-pre1/libparted/device/linux/device-write.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/device-write.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/device-write.c Tue Mar 6 17:04:17
+2001
@@ -0,0 +1,112 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+ped_device_write (PedDevice* dev, const void* buffer, PedSector start,
+ PedSector count)
+{
+ int status;
+ PedExceptionOption ex_status;
+ size_t write_length = count * PED_SECTOR_SIZE;
+ struct peropen *po;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+ PED_ASSERT (buffer != NULL, return 0);
+
+ po = dev->po;
+
+ if (dev->read_only) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_IGNORE_CANCEL,
+ _("Can't write to %s, because it is opened read-only."),
+ dev->path)
+ != PED_EXCEPTION_IGNORE)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (1) {
+ if (_do_device_seek (dev, start))
+ break;
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR, PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during seek for write on %s"),
+ strerror (errno), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+
+#ifdef READONLY
+ printf ("ped_device_write (\"%s\", %p, %d, %d)\n",
+ dev->path, buffer, (int) start, (int) count);
+#else
+ dev->dirty = 1;
+ while (1) {
+ status = write (po->fd, buffer, write_length);
+ if (status == count * PED_SECTOR_SIZE) break;
+ if (status > 0) {
+ write_length -= status;
+ buffer += status;
+ continue;
+ }
+
+ ex_status = ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_IGNORE_CANCEL,
+ _("%s during write on %s"),
+ strerror (errno), dev->path);
+
+ switch (ex_status) {
+ case PED_EXCEPTION_IGNORE:
+ return 1;
+
+ case PED_EXCEPTION_RETRY:
+ break;
+
+ case PED_EXCEPTION_UNHANDLED:
+ ped_exception_catch ();
+ case PED_EXCEPTION_CANCEL:
+ return 0;
+ }
+ }
+#endif
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/do-close.c
parted-1.5.1-pre1/libparted/device/linux/do-close.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/do-close.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/do-close.c Sat Mar 3 18:07:53 2001
@@ -0,0 +1,84 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <errno.h>
+
+int
+_do_close (PedDevice* dev)
+{
+ struct peropen *po;
+
+ po = dev->po;
+
+ _flush_cache (dev);
+
+ if (dev->dirty && dev->type != PED_DEVICE_FILE) {
+ if (_kernel_reread_part_table (dev))
+ dev->dirty = 0;
+ }
+
+ if (dev->dirty && dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
+ /* ouch! */
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("The kernel was unable to re-read your partition "
+ "table, so you need to reboot before mounting any "
+ "modified partitions. You also need to reinstall "
+ "your boot loader before you reboot (which may "
+ "require mounting modified partitions). It is "
+ "impossible do both things! So you'll need to "
+ "boot off a rescue disk, and reinstall your boot "
+ "loader from the rescue disk. Read section 4 of "
+ "the Parted User documentation for more "
+ "information."));
+ ped_free (po);
+ close (po->fd);
+ return 1;
+ }
+
+ if (dev->dirty && dev->type != PED_DEVICE_FILE) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_IGNORE,
+ _("The kernel was unable to re-read the partition "
+ "table on %s (%s). This means Linux knows nothing "
+ "about any modifications you made. You should "
+ "reboot your computer before doing anything with "
+ "%s."),
+ dev->path, strerror (errno), dev->path);
+ }
+
+ if (dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("You should reinstall your boot loader before "
+ "rebooting. Read section 4 of the Parted User "
+ "documentation for more information."));
+ }
+
+ close (po->fd);
+ ped_free (po);
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/do-open.c
parted-1.5.1-pre1/libparted/device/linux/do-open.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/do-open.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/do-open.c Sat Mar 3 16:44:22 2001
@@ -0,0 +1,72 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int
+_do_open (PedDevice* dev)
+{
+ struct peropen *po;
+ char* rw_error_msg;
+
+ po = dev->po = ped_malloc (sizeof (struct peropen));
+ if (! po)
+ return 0;
+
+retry:
+ po->fd = open (dev->path, O_RDWR);
+ if (po->fd == -1) {
+ rw_error_msg = strerror (errno);
+
+ po->fd = open (dev->path, O_RDONLY);
+ if (po->fd == -1) {
+ if (ped_exception_throw (
+ PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_RETRY_CANCEL,
+ _("Error opening %s: %s"),
+ dev->path, strerror (errno))
+ != PED_EXCEPTION_RETRY) {
+ ped_free (po);
+ return 0;
+ } else
+ goto retry;
+ } else {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("Unable to open %s read-write (%s). %s has "
+ "been opened read-only."),
+ dev->path, rw_error_msg, dev->path);
+ dev->read_only = 1;
+ }
+ } else {
+ dev->read_only = 0;
+ }
+
+ _flush_cache (dev);
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/do-seek.c
parted-1.5.1-pre1/libparted/device/linux/do-seek.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/do-seek.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/do-seek.c Sat Mar 3 16:37:02 2001
@@ -0,0 +1,48 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+int
+_do_device_seek (const PedDevice* dev, PedSector sector)
+{
+ struct peropen *po;
+
+ PED_ASSERT (dev != NULL, return 0);
+ PED_ASSERT (!dev->external_mode, return 0);
+
+ po = dev->po;
+
+#if SIZEOF_OFF_T < 8
+ if (sizeof (off_t) < 8) {
+ loff_t pos = sector * PED_SECTOR_SIZE;
+ return ped_llseek (po->fd, pos, SEEK_SET) == pos;
+ } else
+#endif
+ {
+ off_t pos = sector * PED_SECTOR_SIZE;
+ return lseek (po->fd, pos, SEEK_SET) == pos;
+ }
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/flush-cache.c
parted-1.5.1-pre1/libparted/device/linux/flush-cache.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/flush-cache.c Thu Jan 1
01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/flush-cache.c Tue Mar 6 20:06:04
+2001
@@ -0,0 +1,59 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+void
+_flush_cache (PedDevice* dev)
+{
+ int i;
+ char* name;
+ int fd;
+ struct peropen *po;
+
+ po = dev->po;
+
+ if (dev->read_only)
+ return;
+
+ ioctl (po->fd, BLKFLSBUF);
+
+ name = (char*) ped_malloc (strlen (dev->path) + 3);
+ if (!name)
+ return;
+
+ for (i = 0; i < 16; i++) {
+ sprintf (name, "%s%d", dev->path, i);
+ fd = open (name, O_WRONLY, 0);
+ if (fd == -1)
+ continue;
+ ioctl (fd, BLKFLSBUF);
+ close (fd);
+ }
+
+ ped_free (name);
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/kernel-reread-part-table.c
parted-1.5.1-pre1/libparted/device/linux/kernel-reread-part-table.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/kernel-reread-part-table.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/kernel-reread-part-table.c Tue Mar 6
+20:06:08 2001
@@ -0,0 +1,44 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "peropen.h"
+#include "priv.h"
+#include "arch.h"
+
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+int
+_kernel_reread_part_table (PedDevice* dev)
+{
+ int retry_count = 5;
+ struct peropen *po;
+
+ po = dev->po;
+
+ sync();
+ while (ioctl (po->fd, BLKRRPART)) {
+ retry_count--;
+ sync();
+ if (!retry_count)
+ return 0;
+ }
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/llseek.c
parted-1.5.1-pre1/libparted/device/linux/llseek.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/llseek.c Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/llseek.c Wed Feb 28 16:15:05 2001
@@ -0,0 +1,80 @@
+/*
+ llseek.c -- llseek stub
+ Derived from work Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* This is a long, sad story about a function called lseek(). A long time ago,
+ * (in a galaxy, far away), hard disks were small, and 32-bits was enough to
+ * address any device. Hence, lseek()'s offset parameter was 32-bit on Linux
+ * x86.
+ * However, it became obvious that this wouldn't be enough, so the
+ * llseek() syscall was added. However, some of the standard C libraries
+ * did not use this llseek() properly. It is undocumented, as it is Linux
+ * only. So, we always must call the Linux syscall directly.
+ * When making one's own syscall, one uses the "_syscall5" macro
+ * (where 5 is the number of paramters). However, a syscall (i.e.
+ * software interrupt 0x80) takes its parameters through registers. In
+ * particular, it uses ebx as the first parameter to the syscall function
+ * (in llseek()'s case, the file descriptor).
+ * Unfortunately, ebx is also used to store the global offset table, which
+ * is needed in shared libraries. For some reason, gcc doesn't want to
+ * push ebx before the interrupt, and pop it back again afterwards. Anyway,
+ * the result is, the global offset table feature must be disabled. But this
+ * feature is required for shared libraries, to make the code position
+ * independent. So the result is, this part of the code must be statically
+ * linked to any binaries.
+ */
+
+static const char _llseek_c[] = "$Id: llseek.c,v 1.3 1999/10/02 20:56:47 aclausen Exp
+$";
+
+#include "config.h"
+
+#if SIZEOF_OFF_T < 8
+
+#include <unistd.h>
+#include <linux/unistd.h>
+#include <syscall.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#ifndef __NR__llseek
+#define __NR__llseek 140
+#endif
+
+static _syscall5(int,_llseek,
+ unsigned int, fd,
+ unsigned long, offset_high,
+ unsigned long, offset_low,
+ loff_t*, result,
+ unsigned int, origin)
+
+loff_t
+ped_llseek (unsigned int fd, loff_t offset, unsigned int whence)
+{
+ loff_t result;
+ int retval;
+
+ retval = _llseek(fd,
+ ((unsigned long long)offset) >> 32,
+ ((unsigned long long)offset) & 0xffffffff,
+ &result,
+ whence);
+ return (retval==-1 ? (loff_t) retval : result);
+}
+
+#endif /* SIZEOF_OFF_T < 8 */
+
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/llseek.h
parted-1.5.1-pre1/libparted/device/linux/llseek.h
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/llseek.h Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/llseek.h Wed Feb 28 16:15:20 2001
@@ -0,0 +1,35 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef LLSEEK_H_INCLUDED
+#define LLSEEK_H_INCLUDED
+
+#include "config.h"
+
+#if SIZEOF_OFF_T < 8
+
+#include <sys/types.h>
+
+extern loff_t
+ped_llseek (unsigned int fd, loff_t offset, unsigned int whence);
+
+#endif /* SIZEOF_OFF_T < 8 */
+
+#endif /* LLSEEK_H_INCLUDED */
+
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/peropen.h
parted-1.5.1-pre1/libparted/device/linux/peropen.h
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/peropen.h Thu Jan 1 01:00:00
1970
+++ parted-1.5.1-pre1/libparted/device/linux/peropen.h Wed Feb 28 15:48:21 2001
@@ -0,0 +1,28 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __DEVICE_LINUX_PEROPEN_H__
+#define __DEVICE_LINUX_PEROPEN_H__
+
+struct peropen
+{
+ int fd;
+};
+
+#endif /* __DEVICE_LINUX_PEROPEN_H__ */
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/probe-proc-partitions.c
parted-1.5.1-pre1/libparted/device/linux/probe-proc-partitions.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/probe-proc-partitions.c Thu
Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/probe-proc-partitions.c Wed Feb 28
+16:16:45 2001
@@ -0,0 +1,52 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+int
+probe_proc_partitions ()
+{
+ FILE* proc_part_file;
+ int major, minor, size;
+ char part_name [256];
+ char dev_name [256];
+
+ proc_part_file = fopen ("/proc/partitions", "r");
+ if (!proc_part_file)
+ return 0;
+
+ fgets (part_name, 256, proc_part_file);
+ fgets (part_name, 256, proc_part_file);
+
+ while (fscanf (proc_part_file, "%d %d %d %255s",
+ &major, &minor, &size, part_name) == 4) {
+ if (isdigit (part_name [strlen (part_name) - 1]))
+ continue;
+ strcpy (dev_name, "/dev/");
+ strcat (dev_name, part_name);
+ probe (dev_name);
+ }
+
+ fclose (proc_part_file);
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/linux/probe-standard-partitions.c
parted-1.5.1-pre1/libparted/device/linux/probe-standard-partitions.c
--- parted-1.5.1-pre1-vanilla/libparted/device/linux/probe-standard-partitions.c
Thu Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/linux/probe-standard-partitions.c Sun
+Feb 25 16:25:43 2001
@@ -0,0 +1,42 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+int
+probe_standard_devices ()
+{
+ probe ("/dev/sda");
+ probe ("/dev/sdb");
+ probe ("/dev/sdc");
+ probe ("/dev/sdd");
+ probe ("/dev/sde");
+ probe ("/dev/sdf");
+
+ probe ("/dev/hda");
+ probe ("/dev/hdb");
+ probe ("/dev/hdc");
+ probe ("/dev/hdd");
+ probe ("/dev/hde");
+ probe ("/dev/hdf");
+ probe ("/dev/hdg");
+ probe ("/dev/hdh");
+
+ return 1;
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/priv.h
parted-1.5.1-pre1/libparted/device/priv.h
--- parted-1.5.1-pre1-vanilla/libparted/device/priv.h Thu Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/priv.h Tue Mar 6 18:11:40 2001
@@ -0,0 +1,76 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __DEVICE_PRIV_H__
+#define __DEVICE_PRIV_H__
+
+#include "config.h"
+
+#include <parted/parted.h>
+#include <parted/device.h>
+
+#include <libintl.h>
+#define N_(String) String
+#if ENABLE_NLS
+# define _(String) dgettext (PACKAGE, String)
+#else
+# define _(String) (String)
+#endif /* ENABLE_NLS */
+
+extern PedDevice* devices;
+
+PedDevice* ped_device_new (const char* path);
+
+void ped_device_add (PedDevice* dev);
+
+int device_get_sector_size (PedDevice* dev);
+
+int device_probe_type (PedDevice* dev);
+
+int device_probe_geometry (PedDevice* dev);
+
+PedSector device_get_length (PedDevice* dev);
+
+void probe (char* path);
+
+int probe_proc_partitions ();
+
+int probe_standard_devices ();
+
+void ped_device_remove (PedDevice* dev);
+
+void ped_device_destroy (PedDevice* dev);
+
+void _flush_cache (PedDevice* dev);
+
+/* Attempt to ask the kernel to reread the partition table. */
+int _kernel_reread_part_table (PedDevice* dev);
+
+/* Open the underlying device. */
+int _do_open (PedDevice* dev);
+
+/* Reopen the underlying device. */
+int _do_refresh_open (PedDevice* dev);
+
+int _do_refresh_close (PedDevice* dev);
+
+/* Close the underlying device. */
+int _do_close (PedDevice* dev);
+
+#endif /* __DEVICE_PRIV_H__ */
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/device/probe.c
parted-1.5.1-pre1/libparted/device/probe.c
--- parted-1.5.1-pre1-vanilla/libparted/device/probe.c Thu Jan 1 01:00:00 1970
+++ parted-1.5.1-pre1/libparted/device/probe.c Wed Feb 28 15:46:04 2001
@@ -0,0 +1,56 @@
+/*
+ libparted - a library for manipulating disk partitions
+ Copyright (C) 1998-2001 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "priv.h"
+
+#include <string.h>
+
+void
+probe (char* path)
+{
+ PedDevice* dev;
+
+ PED_ASSERT (path != NULL, return);
+
+ for (dev = devices; dev; dev = dev->next) {
+ if (!strcmp (dev->path, path))
+ return;
+ }
+
+ ped_exception_fetch_all ();
+
+ dev = ped_device_new (path);
+ if (!dev)
+ goto error;
+
+ if (!ped_device_open (dev)) {
+ ped_device_destroy (dev);
+ goto error;
+ }
+ ped_exception_leave_all ();
+
+ ped_device_close (dev);
+ ped_device_add (dev);
+
+ return;
+
+error:
+ ped_exception_catch ();
+ ped_exception_leave_all ();
+}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/libparted/device.c
parted-1.5.1-pre1/libparted/device.c
--- parted-1.5.1-pre1-vanilla/libparted/device.c Tue Jan 30 21:35:27 2001
+++ parted-1.5.1-pre1/libparted/device.c Thu Jan 1 01:00:00 1970
@@ -1,1189 +0,0 @@
-/*
- libparted - a library for manipulating disk partitions
- Copyright (C) 1998-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include "config.h"
-
-#include <libintl.h>
-#define N_(String) String
-#if ENABLE_NLS
-# define _(String) dgettext (PACKAGE, String)
-#else
-# define _(String) (String)
-#endif /* ENABLE_NLS */
-
-#include "llseek.h"
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/sysmacros.h>
-#include <sys/stat.h>
-#include <scsi/scsi.h>
-
-#include <parted/parted.h>
-
-#ifndef SCSI_IOCTL_SEND_COMMAND
-#define SCSI_IOCTL_SEND_COMMAND 1
-#endif
-
-#ifdef linux
-#include <linux/hdreg.h>
-
-/* from <linux/fs.h> */
-#define BLKRRPART _IO(0x12,95) /* re-read partition table */
-#define BLKGETSIZE _IO(0x12,96) /* return device size */
-#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
-#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
-
-/* from <linux/major.h> */
-#define IDE0_MAJOR 3
-#define IDE1_MAJOR 22
-#define IDE2_MAJOR 33
-#define IDE3_MAJOR 34
-#define IDE4_MAJOR 56
-#define IDE5_MAJOR 57
-#define SCSI_CDROM_MAJOR 11
-#define SCSI_DISK0_MAJOR 8
-#define SCSI_DISK1_MAJOR 65
-#define SCSI_DISK2_MAJOR 66
-#define SCSI_DISK3_MAJOR 67
-#define SCSI_DISK4_MAJOR 68
-#define SCSI_DISK5_MAJOR 69
-#define SCSI_DISK6_MAJOR 70
-#define SCSI_DISK7_MAJOR 71
-#define COMPAQ_SMART2_MAJOR 72
-#define COMPAQ_SMART2_MAJOR1 73
-#define COMPAQ_SMART2_MAJOR2 74
-#define COMPAQ_SMART2_MAJOR3 75
-#define COMPAQ_SMART2_MAJOR4 76
-#define COMPAQ_SMART2_MAJOR5 77
-#define COMPAQ_SMART2_MAJOR6 78
-#define COMPAQ_SMART2_MAJOR7 79
-#define DAC960_MAJOR 48
-
-#define SCSI_BLK_MAJOR(M) ( \
- (M) == SCSI_DISK0_MAJOR \
- || (M) == SCSI_CDROM_MAJOR \
- || ((M) >= SCSI_DISK1_MAJOR && (M) <= SCSI_DISK7_MAJOR))
-
-#endif /* linux */
-
-static PedDevice* devices = NULL;
-
-static PedDevice*
-ped_device_new (const char* path);
-
-/* O(n) add function, hehe */
-static void
-ped_device_add (PedDevice* dev)
-{
- PedDevice* walk;
- for (walk = devices; walk && walk->next; walk = walk->next);
- if (walk)
- walk->next = dev;
- else
- devices = dev;
- dev->next = NULL;
-}
-
-static void
-ped_device_remove (PedDevice* dev)
-{
- PedDevice* walk;
- PedDevice* last = NULL;
-
- for (walk = devices; walk != NULL; last = walk, walk = walk->next) {
- if (walk == dev) break;
- }
-
- if (last)
- last->next = dev->next;
- else
- devices = dev->next;
-}
-
-PedDevice*
-ped_device_get_next (const PedDevice* dev)
-{
- if (dev)
- return dev->next;
- else
- return devices;
-}
-
-/* First searches through probed devices, then attempts to open the device
- * regardless.
- */
-PedDevice*
-ped_device_get (const char* path)
-{
- PedDevice* walk;
-
- PED_ASSERT (path != NULL, return NULL);
-
- for (walk = devices; walk != NULL; walk = walk->next) {
- if (!strcmp (walk->path, path))
- return walk;
- }
-
- walk = ped_device_new (path);
- if (!walk)
- return NULL;
- ped_device_add (walk);
- return walk;
-}
-
-static int
-ped_device_stat (PedDevice* dev, struct stat * dev_stat)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
- while (1) {
- if (!stat (dev->path, dev_stat)) {
- return 1;
- } else {
- if (ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_CANCEL,
- _("Could not stat device %s - %s."),
- dev->path,
- strerror (errno))
- != PED_EXCEPTION_RETRY)
- return 0;
- }
- }
-}
-
-static char*
-strip_name(char* n)
-{
- int len = strlen (n);
- int end = 0;
- int i = 0;
-
- while (i < len) {
- if ((n[i] != ' ') || ((n[i] == ' ') && (n[i + 1] != ' '))) {
- n[end] = n[i];
- end++;
- }
- i++;
- }
- n[end] = 0;
- return (strdup(n));
-}
-
-static int
-_is_ide_major (int major)
-{
- switch (major) {
- case IDE0_MAJOR:
- case IDE1_MAJOR:
- case IDE2_MAJOR:
- case IDE3_MAJOR:
- case IDE4_MAJOR:
- case IDE5_MAJOR:
- return 1;
-
- default:
- return 0;
- }
-}
-
-static int
-_is_cpqarray_major (int major)
-{
- return COMPAQ_SMART2_MAJOR <= major && major <= COMPAQ_SMART2_MAJOR7;
-}
-
-static int
-device_probe_type (PedDevice* dev)
-{
- struct stat dev_stat;
- int dev_major;
- int dev_minor;
- PedExceptionOption ex_status;
-
- if (!ped_device_stat (dev, &dev_stat))
- return 0;
-
- if (!S_ISBLK(dev_stat.st_mode)) {
- dev->type = PED_DEVICE_FILE;
- return 1;
- }
-
- dev_major = major (dev_stat.st_rdev);
- dev_minor = minor (dev_stat.st_rdev);
-
- if (SCSI_BLK_MAJOR (dev_major) && (dev_minor % 0x10 == 0)) {
- dev->type = PED_DEVICE_SCSI;
- } else if (_is_ide_major (dev_major) && (dev_minor % 0x40 == 0)) {
- dev->type = PED_DEVICE_IDE;
- } else if (dev_major == DAC960_MAJOR && (dev_minor % 0x8 == 0)) {
- dev->type = PED_DEVICE_DAC960;
- } else if (_is_cpqarray_major (dev_major) && (dev_minor % 0x10 == 0)) {
- dev->type = PED_DEVICE_CPQARRAY;
- } else {
- dev->type = PED_DEVICE_UNKNOWN;
- }
-
- return 1;
-}
-
-#ifdef linux
-static int
-_get_linux_version ()
-{
- FILE* f;
- int major;
- int minor;
-
- f = fopen ("/proc/sys/kernel/osrelease", "r");
- if (!f)
- return 0;
- if (fscanf (f, "%d.%d.", &major, &minor) != 2)
- return 0;
- fclose (f);
-
- return major * 0x100 + minor;
-}
-#endif /* linux */
-
-static int
-device_get_sector_size (PedDevice* dev)
-{
- int sector_size;
-
- PED_ASSERT (dev->open_count, return 0);
-
-#ifdef linux
- if (_get_linux_version() < 0x203) /* BLKSSZGET is broken < 2.3.x */
- return 512;
- if (ioctl (dev->fd, BLKSSZGET, §or_size))
- return 512;
-
- if (sector_size != 512) {
- if (ped_exception_throw (
- PED_EXCEPTION_BUG,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("The sector size on %s is %d bytes. Parted is known "
- "not to work properly with drives with sector sizes "
- "other than 512 bytes"),
- dev->path,
- sector_size)
- == PED_EXCEPTION_IGNORE)
- return sector_size;
- else
- return 0;
- }
-
- return sector_size;
-
-#else /* linux */
- return 512;
-#endif /* !linux */
-}
-
-/* TODO: do a binary search if BLKGETSIZE doesn't work?! */
-static PedSector
-device_get_length (PedDevice* dev)
-{
- unsigned long size;
-
- PED_ASSERT (dev->open_count, return 0);
-
- if (ioctl (dev->fd, BLKGETSIZE, &size)) {
- ped_exception_throw (
- PED_EXCEPTION_BUG,
- PED_EXCEPTION_CANCEL,
- _("Unable to determine the size of %s (%s)"),
- dev->path,
- strerror (errno));
- return 0;
- }
-
- return size;
-}
-
-static int
-device_probe_geometry (PedDevice* dev)
-{
- struct stat dev_stat;
- struct hd_geometry geometry;
-
- if (!ped_device_stat (dev, &dev_stat))
- goto error;
- PED_ASSERT (S_ISBLK (dev_stat.st_mode), goto error);
-
- dev->length = device_get_length (dev);
- if (!dev->length)
- goto error;
-
- if (ioctl (dev->fd, HDIO_GETGEO, &geometry)) {
- ped_exception_throw (PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Could not read geometry of %s - %s."),
- dev->path, strerror (errno));
- goto error;
- }
-
- dev->sector_size = device_get_sector_size (dev);
- if (!dev->sector_size)
- goto error;
-
- dev->sectors = geometry.sectors;
- dev->heads = geometry.heads;
- if (!dev->sectors || !dev->heads)
- goto error_dodgey_geometry;
-
- dev->cylinders = dev->length / (dev->heads * dev->sectors
- * (dev->sector_size / 512));
-
- return 1;
-
-error_dodgey_geometry:
- ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Device %s has dodgey geometry."),
- dev->path);
-error:
- return 0;
-}
-
-static int
-init_ide (PedDevice* dev)
-{
- struct stat dev_stat;
- int dev_major;
- struct hd_driveid hdi;
- PedExceptionOption ex_status;
-
- if (!ped_device_stat (dev, &dev_stat))
- goto error;
-
- dev_major = major (dev_stat.st_rdev);
-
- if (!ped_device_open (dev))
- goto error;
-
- if (ioctl (dev->fd, HDIO_GET_IDENTITY, &hdi)) {
- ex_status = ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("Could not get identity of device %s - %s"),
- dev->path, strerror (errno));
- switch (ex_status) {
- case PED_EXCEPTION_CANCEL:
- goto error_close_dev;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_IGNORE:
- dev->model = strdup(_("unknown"));
- }
- } else {
- dev->model = strip_name (hdi.model);
- }
-
- if (!device_probe_geometry (dev))
- goto error_close_dev;
-
- ped_device_close (dev);
- return 1;
-
-error_close_dev:
- ped_device_close (dev);
-error:
- return 0;
-}
-
-static int
-init_scsi (PedDevice* dev)
-{
- unsigned char idlun [8];
- unsigned char buffer [128];
- unsigned char* cmd;
- struct hd_geometry geometry;
-
- if (!ped_device_open (dev))
- goto error;
-
- memset (buffer, 0, 96);
-
- *((int *) buffer) = 0; /* length of input data */
- *(((int *) buffer) + 1) = 96; /* length of output buffer */
-
- cmd = (char *) (((int *) buffer) + 2);
-
- cmd[0] = 0x12; /* INQUIRY */
- cmd[1] = 0x00; /* lun=0, evpd=0 */
- cmd[2] = 0x00; /* page code = 0 */
- cmd[3] = 0x00; /* (reserved) */
- cmd[4] = 96; /* allocation length */
- cmd[5] = 0x00; /* control */
-
- if (ioctl(dev->fd, SCSI_IOCTL_SEND_COMMAND, buffer)) {
- buffer[40] = 0;
- dev->model = strip_name (buffer + 16);
- } else {
- dev->model = _("Unknown SCSI");
- }
-
- if (ioctl (dev->fd, SCSI_IOCTL_GET_IDLUN, idlun)) {
- ped_exception_throw (PED_EXCEPTION_ERROR,
- PED_EXCEPTION_CANCEL,
- _("Error initialising SCSI device "
- "%s - %s"),
- dev->path, strerror (errno));
- goto error_close_dev;
- }
-
- if (!device_probe_geometry (dev))
- goto error_close_dev;
-
- dev->host = *((unsigned long *) (idlun + 4));
- dev->did = idlun [0];
-
- ped_device_close (dev);
- return 1;
-
-error_close_dev:
- ped_device_close (dev);
-error:
- return 0;
-}
-
-static int
-init_file (PedDevice* dev)
-{
- struct stat dev_stat;
-
- if (!ped_device_stat (dev, &dev_stat))
- return 0;
-
- dev->length = dev_stat.st_size / 512;
- dev->cylinders = dev->length / 4 / 32;
- dev->heads = 4;
- dev->sectors = 32;
- dev->sector_size = 512;
- dev->geom_known = 0;
- dev->model = "";
- return 1;
-}
-
-static int
-init_generic (PedDevice* dev, char* model_name)
-{
- struct stat dev_stat;
- struct hd_geometry geometry;
- PedExceptionOption ex_status;
-
- if (!ped_device_stat (dev, &dev_stat))
- goto error;
-
- if (!ped_device_open (dev))
- goto error;
-
- ped_exception_fetch_all ();
- if (device_probe_geometry (dev)) {
- ped_exception_leave_all ();
- } else {
- /* hack to allow use of files, for testing */
- ped_exception_catch ();
- ped_exception_leave_all ();
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("Unable to determine geometry of "
- "file/device. You should not use Parted "
- "unless you REALLY know what you're doing!"));
- switch (ex_status) {
- case PED_EXCEPTION_CANCEL:
- goto error_close_dev;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_IGNORE:
- }
-
- /* what should we stick in here? */
- dev->length = dev_stat.st_size / 512;
- dev->cylinders = dev->length / 4 / 32;
- dev->heads = 4;
- dev->sectors = 32;
- dev->sector_size = 512;
- dev->geom_known = 0;
- }
-
- dev->model = model_name;
-
- ped_device_close (dev);
- return 1;
-
-error_close_dev:
- ped_device_close (dev);
-error:
- return 0;
-}
-
-static PedDevice*
-ped_device_new (const char* path)
-{
- PedDevice* dev;
-
- PED_ASSERT (path != NULL, return NULL);
-
- dev = (PedDevice*) ped_malloc (sizeof (PedDevice));
- if (!dev)
- goto error;
-
- dev->path = strdup (path);
- dev->open_count = 0;
- dev->external_mode = 0;
- dev->dirty = 0;
- dev->boot_dirty = 0;
- dev->geom_known = 1;
- dev->geom_already_guessed = 0;
-
- if (!device_probe_type (dev))
- goto error_free_dev;
-
- switch (dev->type) {
- case PED_DEVICE_IDE:
- if (!init_ide (dev))
- goto error_free_dev;
- break;
-
- case PED_DEVICE_SCSI:
- if (!init_scsi (dev))
- goto error_free_dev;
- break;
-
- case PED_DEVICE_DAC960:
- if (!init_generic (dev, _("DAC960 RAID controller")))
- goto error_free_dev;
- break;
-
- case PED_DEVICE_CPQARRAY:
- if (!init_generic (dev, _("Compaq Smart Array")))
- goto error_free_dev;
- break;
-
- case PED_DEVICE_FILE:
- if (!init_file (dev))
- goto error_free_dev;
- break;
-
- case PED_DEVICE_UNKNOWN:
- if (ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("Device %s is neither a SCSI nor IDE drive."),
- dev->path)
- == PED_EXCEPTION_CANCEL)
- goto error_free_dev;
- if (!init_generic (dev, _("Unknown")))
- goto error_free_dev;
- break;
-
- default:
- ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
- PED_EXCEPTION_CANCEL,
- _("ped_device_new() Unsupported device type"));
- goto error_free_dev;
- }
- return dev;
-
-error_free_dev:
- ped_free (dev);
-error:
- return NULL;
-}
-
-static void
-ped_device_destroy (PedDevice* dev)
-{
- PED_ASSERT (dev != NULL, return);
-
- while (dev->open_count)
- ped_device_close (dev);
-
- ped_free (dev->path);
- ped_free (dev);
-}
-
-#ifdef linux
-static void
-_flush_cache (PedDevice* dev)
-{
- int i;
- char* name;
- int fd;
-
- if (dev->read_only)
- return;
-
- ioctl (dev->fd, BLKFLSBUF);
-
- name = (char*) ped_malloc (strlen (dev->path) + 3);
- if (!name)
- return;
-
- for (i = 0; i < 16; i++) {
- sprintf (name, "%s%d", dev->path, i);
- fd = open (name, O_WRONLY, 0);
- if (fd == -1)
- continue;
- ioctl (fd, BLKFLSBUF);
- close (fd);
- }
-
- ped_free (name);
-}
-
-static int
-_kernel_reread_part_table (PedDevice* dev)
-{
- int retry_count = 5;
-
- sync();
- while (ioctl (dev->fd, BLKRRPART)) {
- retry_count--;
- sync();
- if (!retry_count)
- return 0;
- }
-
- return 1;
-}
-
-#endif /* linux */
-
-static int
-_do_refresh_open (PedDevice* dev)
-{
-#ifdef linux
- _flush_cache (dev);
-#endif
- return 1;
-}
-
-static int
-_do_open (PedDevice* dev)
-{
- char* rw_error_msg;
-
-retry:
- dev->fd = open (dev->path, O_RDWR);
- if (dev->fd == -1) {
- rw_error_msg = strerror (errno);
-
- dev->fd = open (dev->path, O_RDONLY);
- if (dev->fd == -1) {
- if (ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_CANCEL,
- _("Error opening %s: %s"),
- dev->path, strerror (errno))
- != PED_EXCEPTION_RETRY)
- return 0;
- else
- goto retry;
- } else {
- ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_OK,
- _("Unable to open %s read-write (%s). %s has "
- "been opened read-only."),
- dev->path, rw_error_msg, dev->path);
- dev->read_only = 1;
- }
- } else {
- dev->read_only = 0;
- }
-
-#ifdef linux
- _flush_cache (dev);
-#endif
-
- return 1;
-}
-
-static int
-_do_refresh_close (PedDevice* dev)
-{
- return 1;
-}
-
-static int
-_do_close (PedDevice* dev)
-{
-#ifdef linux
- _flush_cache (dev);
-
- if (dev->dirty && dev->type != PED_DEVICE_FILE) {
- if (_kernel_reread_part_table (dev))
- dev->dirty = 0;
- }
-
- if (dev->dirty && dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
- /* ouch! */
- ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_OK,
- _("The kernel was unable to re-read your partition "
- "table, so you need to reboot before mounting any "
- "modified partitions. You also need to reinstall "
- "your boot loader before you reboot (which may "
- "require mounting modified partitions). It is "
- "impossible do both things! So you'll need to "
- "boot off a rescue disk, and reinstall your boot "
- "loader from the rescue disk. Read section 4 of "
- "the Parted User documentation for more "
- "information."));
- close (dev->fd);
- return 1;
- }
-
- if (dev->dirty && dev->type != PED_DEVICE_FILE) {
- ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_IGNORE,
- _("The kernel was unable to re-read the partition "
- "table on %s (%s). This means Linux knows nothing "
- "about any modifications you made. You should "
- "reboot your computer before doing anything with "
- "%s."),
- dev->path, strerror (errno), dev->path);
- }
-
- if (dev->boot_dirty && dev->type != PED_DEVICE_FILE) {
- ped_exception_throw (
- PED_EXCEPTION_WARNING,
- PED_EXCEPTION_OK,
- _("You should reinstall your boot loader before "
- "rebooting. Read section 4 of the Parted User "
- "documentation for more information."));
- }
-#endif /* linux */
-
- close (dev->fd);
- return 1;
-}
-
-int
-ped_device_open (PedDevice* dev)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
- if (dev->open_count++)
- return _do_refresh_open (dev);
-
- return _do_open (dev);
-}
-
-int
-ped_device_close (PedDevice* dev)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
- if (--dev->open_count)
- return _do_refresh_close (dev);
-
- return _do_close (dev);
-
-}
-
-int
-ped_device_begin_external_access (PedDevice* dev)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
- dev->external_mode = 1;
- if (dev->open_count)
- _do_close (dev);
-
- return 1;
-}
-
-int
-ped_device_end_external_access (PedDevice* dev)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (dev->external_mode, return 0);
-
- dev->external_mode = 0;
- if (dev->open_count)
- _do_open (dev);
-
- return 1;
-}
-
-static int
-ped_device_seek (const PedDevice* dev, PedSector sector)
-{
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
-#if SIZEOF_OFF_T < 8 && defined(linux)
- if (sizeof (off_t) < 8) {
- loff_t pos = sector * 512;
- return ped_llseek (dev->fd, pos, SEEK_SET) == pos;
- } else
-#endif
- {
- off_t pos = sector * 512;
- return lseek (dev->fd, pos, SEEK_SET) == pos;
- }
-}
-
-int
-ped_device_read (const PedDevice* dev, void* buffer, PedSector start,
- PedSector count)
-{
- int status;
- PedExceptionOption ex_status;
- size_t read_length = count * PED_SECTOR_SIZE;
-
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
- PED_ASSERT (buffer != NULL, return 0);
-
- while (1) {
- if (ped_device_seek (dev, start))
- break;
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_IGNORE_CANCEL,
- _("%s during seek for read on %s"),
- strerror (errno), dev->path);
-
- switch (ex_status) {
- case PED_EXCEPTION_IGNORE:
- return 1;
-
- case PED_EXCEPTION_RETRY:
- break;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_CANCEL:
- return 0;
- }
- }
-
- while (1) {
- status = read (dev->fd, buffer, read_length);
- if (status == count * PED_SECTOR_SIZE) break;
- if (status > 0) {
- read_length -= status;
- buffer += status;
- continue;
- }
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_IGNORE_CANCEL,
- _("%s during read on %s"),
- strerror (errno),
- dev->path);
-
- switch (ex_status) {
- case PED_EXCEPTION_IGNORE:
- return 1;
-
- case PED_EXCEPTION_RETRY:
- break;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_CANCEL:
- return 0;
- }
- }
-
- return 1;
-}
-
-int
-ped_device_sync (PedDevice* dev)
-{
- int status;
- PedExceptionOption ex_status;
-
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
-
- if (dev->read_only)
- return 1;
-
- while (1) {
- status = fsync (dev->fd);
- if (status >= 0) break;
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_IGNORE_CANCEL,
- _("%s during write on %s"),
- strerror (errno), dev->path);
-
- switch (ex_status) {
- case PED_EXCEPTION_IGNORE:
- return 1;
-
- case PED_EXCEPTION_RETRY:
- break;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_CANCEL:
- return 0;
- }
- }
-
- return 1;
-}
-
-int
-ped_device_write (PedDevice* dev, const void* buffer, PedSector start,
- PedSector count)
-{
- int status;
- PedExceptionOption ex_status;
- size_t write_length = count * PED_SECTOR_SIZE;
-
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
- PED_ASSERT (buffer != NULL, return 0);
-
- if (dev->read_only) {
- if (ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_IGNORE_CANCEL,
- _("Can't write to %s, because it is opened read-only."),
- dev->path)
- != PED_EXCEPTION_IGNORE)
- return 0;
- else
- return 1;
- }
-
- while (1) {
- if (ped_device_seek (dev, start))
- break;
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_ERROR, PED_EXCEPTION_RETRY_IGNORE_CANCEL,
- _("%s during seek for write on %s"),
- strerror (errno), dev->path);
-
- switch (ex_status) {
- case PED_EXCEPTION_IGNORE:
- return 1;
-
- case PED_EXCEPTION_RETRY:
- break;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_CANCEL:
- return 0;
- }
- }
-
-#ifdef READONLY
- printf ("ped_device_write (\"%s\", %p, %d, %d)\n",
- dev->path, buffer, (int) start, (int) count);
-#else
- dev->dirty = 1;
- while (1) {
- status = write (dev->fd, buffer, write_length);
- if (status == count * PED_SECTOR_SIZE) break;
- if (status > 0) {
- write_length -= status;
- buffer += status;
- continue;
- }
-
- ex_status = ped_exception_throw (
- PED_EXCEPTION_ERROR,
- PED_EXCEPTION_RETRY_IGNORE_CANCEL,
- _("%s during write on %s"),
- strerror (errno), dev->path);
-
- switch (ex_status) {
- case PED_EXCEPTION_IGNORE:
- return 1;
-
- case PED_EXCEPTION_RETRY:
- break;
-
- case PED_EXCEPTION_UNHANDLED:
- ped_exception_catch ();
- case PED_EXCEPTION_CANCEL:
- return 0;
- }
- }
-#endif
- return 1;
-}
-
-/* returns the number of sectors that are ok.
- */
-PedSector
-ped_device_check (PedDevice* dev, void* buffer, PedSector start,
- PedSector count)
-{
- int status;
- int done = 0;
-
- PED_ASSERT (dev != NULL, return 0);
- PED_ASSERT (!dev->external_mode, return 0);
- PED_ASSERT (buffer != NULL, return 0);
-
- if (!ped_device_seek (dev, start))
- return 0;
-
- while (1) {
- status = read (dev->fd, buffer, (count-done) * PED_SECTOR_SIZE);
- if (status < 0)
- return 0;
-
- done += status / PED_SECTOR_SIZE;
- if (done == count * PED_SECTOR_SIZE)
- break;
- else
- continue;
- }
-
- return count;
-}
-
-static void
-probe (char* path)
-{
- PedDevice* dev;
-
- PED_ASSERT (path != NULL, return);
-
- for (dev = devices; dev; dev = dev->next) {
- if (!strcmp (dev->path, path))
- return;
- }
-
- ped_exception_fetch_all ();
-
- dev = ped_device_new (path);
- if (!dev)
- goto error;
-
- if (!ped_device_open (dev)) {
- ped_device_destroy (dev);
- goto error;
- }
- ped_exception_leave_all ();
-
- ped_device_close (dev);
- ped_device_add (dev);
-
- return;
-
-error:
- ped_exception_catch ();
- ped_exception_leave_all ();
-}
-
-static int
-probe_proc_partitions ()
-{
- FILE* proc_part_file;
- int major, minor, size;
- char part_name [256];
- char dev_name [256];
-
- proc_part_file = fopen ("/proc/partitions", "r");
- if (!proc_part_file)
- return 0;
-
- fgets (part_name, 256, proc_part_file);
- fgets (part_name, 256, proc_part_file);
-
- while (fscanf (proc_part_file, "%d %d %d %255s",
- &major, &minor, &size, part_name) == 4) {
- if (isdigit (part_name [strlen (part_name) - 1]))
- continue;
- strcpy (dev_name, "/dev/");
- strcat (dev_name, part_name);
- probe (dev_name);
- }
-
- fclose (proc_part_file);
- return 1;
-}
-
-static int
-probe_standard_devices ()
-{
- probe ("/dev/sda");
- probe ("/dev/sdb");
- probe ("/dev/sdc");
- probe ("/dev/sdd");
- probe ("/dev/sde");
- probe ("/dev/sdf");
-
- probe ("/dev/hda");
- probe ("/dev/hdb");
- probe ("/dev/hdc");
- probe ("/dev/hdd");
- probe ("/dev/hde");
- probe ("/dev/hdf");
- probe ("/dev/hdg");
- probe ("/dev/hdh");
-
- return 1;
-}
-
-void
-ped_device_probe_all ()
-{
- probe_proc_partitions ();
- probe_standard_devices ();
-}
-
-void
-ped_device_free_all ()
-{
- PedDevice* dev;
- while (devices)
- {
- dev = devices;
- ped_device_remove (dev);
- ped_device_destroy (dev);
- }
-}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/libparted/disk.c
parted-1.5.1-pre1/libparted/disk.c
--- parted-1.5.1-pre1-vanilla/libparted/disk.c Tue Jan 30 22:38:58 2001
+++ parted-1.5.1-pre1/libparted/disk.c Tue Mar 6 19:49:50 2001
@@ -1102,7 +1102,7 @@
static int
_partition_is_mounted (const PedPartition* part)
{
- char part_name [256];
+ char *part_name [256];/* XXX: Allocate this dynamically */
int status;
PED_ASSERT (part != NULL, return 0);
@@ -1126,6 +1126,10 @@
return status;
}
#endif
+
+ /* XXX */
+ if (part->geom.disk->dev->type == PED_DEVICE_FILE)
+ return 0;
status = _check_mount_table_is_busy ("/etc/mtab", part_name);
if (status != -1)
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/libparted/disk_dos.c
parted-1.5.1-pre1/libparted/disk_dos.c
--- parted-1.5.1-pre1-vanilla/libparted/disk_dos.c Wed Jan 31 14:46:17 2001
+++ parted-1.5.1-pre1/libparted/disk_dos.c Sat Mar 3 17:35:10 2001
@@ -55,7 +55,7 @@
typedef struct _DosRawPartition DosRawPartition;
typedef struct _DosRawTable DosRawTable;
-/* note: this lots of bit-bashing here. So you shouldn't look inside this.
+/* note: lots of bit-bashing here, thus, you shouldn't look inside it.
* Use chs_to_sector() and sector_to_chs() instead.
*/
typedef struct {
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_ext2/ext2.c
parted-1.5.1-pre1/libparted/fs_ext2/ext2.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_ext2/ext2.c Mon Dec 4 20:12:47 2000
+++ parted-1.5.1-pre1/libparted/fs_ext2/ext2.c Sun Mar 4 16:11:13 2001
@@ -257,26 +257,6 @@
return 0;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
off_t ext2_get_inode_offset(struct ext2_fs *fs, ino_t inode, blk_t *block)
{
int group;
@@ -593,15 +573,7 @@
return 0;
}
-
-
-
-
-
-
-
-
-
+
void ext2_close(struct ext2_fs *fs)
{
#if 0
@@ -712,9 +684,9 @@
{
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
- _("This ext2 filesystem has a rather strange layout! "
- "Please use dumpe2fs on this filesystem and send it "
- "to <[EMAIL PROTECTED]>. I won't resize it, sorry."));
+ _("This ext2 filesystem has a rather strange layout; "
+ "I won't resize it, sorry. Please use dumpe2fs on "
+ "this filesystem and send it to <[EMAIL PROTECTED]>."));
return 0;
}
}
@@ -764,8 +736,8 @@
if (!((EXT2_SUPER_STATE(fs->sb) | state) & EXT2_VALID_FS))
{
ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
- _("Filesystem was not cleanly unmounted! "
- "Run e2fsck first!"));
+ _("Filesystem was not cleanly unmounted or is currently "
+ "mount. If it is the former, try running e2fsck."));
goto error_free_fs;
}
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_ext2/interface.c
parted-1.5.1-pre1/libparted/fs_ext2/interface.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_ext2/interface.c Fri Jan 26 18:37:09
2001
+++ parted-1.5.1-pre1/libparted/fs_ext2/interface.c Sat Mar 3 17:35:25 2001
@@ -25,6 +25,8 @@
#include "config.h"
+#include <stdlib.h>
+#include <string.h>
#include <parted/parted.h>
#include <parted/disk_dos.h>
#include <parted/disk_loop.h>
@@ -36,9 +38,7 @@
#include "parted_io.h"
struct ext2_dev_handle* ext2_make_dev_handle_from_parted_geometry(PedGeometry* geom);
-
-
-
+
static int
_ext2_probe (const PedGeometry* geom);
@@ -66,10 +66,7 @@
static int
_ext2_set_system (const PedFileSystem* fs, PedPartition* part,
const PedDiskType* disk_type);
-
-
-
-
+
static PedFileSystemOps _ext2_ops = {
probe: _ext2_probe,
clobber: _ext2_clobber,
@@ -98,9 +95,7 @@
{
ped_file_system_type_unregister (&_ext2_type);
}
-
-
-
+
static int
_ext2_probe (const PedGeometry* geom)
{
@@ -237,7 +232,7 @@
f = (struct ext2_fs *) fs->type_specific;
-/* ensure that the geometry contains the new and old geometry */
+ /* ensure that the geometry contains the new and old geometry */
if (old_length > geom->length) {
if (!ext2_resize_fs(f, geom->length >> (f->logsize - 9)))
goto error;
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_hfs/hfs.c
parted-1.5.1-pre1/libparted/fs_hfs/hfs.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_hfs/hfs.c Fri Jan 5 14:30:56 2001
+++ parted-1.5.1-pre1/libparted/fs_hfs/hfs.c Sun Feb 25 12:07:35 2001
@@ -34,8 +34,11 @@
#endif /* ENABLE_NLS */
#include <unistd.h>
-#include <asm/page.h>
#include <string.h>
+
+#ifdef linux
+#include <asm/page.h>
+#endif
#define HFS_SIGNATURE 0x4244
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_linux_swap/linux_swap.c
parted-1.5.1-pre1/libparted/fs_linux_swap/linux_swap.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_linux_swap/linux_swap.c Fri Jan 26
20:50:35 2001
+++ parted-1.5.1-pre1/libparted/fs_linux_swap/linux_swap.c Sat Mar 3 17:35:25
+2001
@@ -38,8 +38,11 @@
#endif /* ENABLE_NLS */
#include <unistd.h>
-#include <asm/page.h>
#include <string.h>
+
+#ifdef linux
+#include <asm/page.h>
+#endif
#define SWAP_SPECIFIC(fs) ((SwapSpecific*) (fs->type_specific))
#define BUFFER_SIZE 128
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_ntfs/ntfs.c
parted-1.5.1-pre1/libparted/fs_ntfs/ntfs.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_ntfs/ntfs.c Fri Jan 5 14:29:47 2001
+++ parted-1.5.1-pre1/libparted/fs_ntfs/ntfs.c Sun Feb 25 12:07:53 2001
@@ -34,8 +34,11 @@
#endif /* ENABLE_NLS */
#include <unistd.h>
-#include <asm/page.h>
#include <string.h>
+
+#ifdef linux
+#include <asm/page.h>
+#endif
#define NTFS_SIGNATURE "NTFS"
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/fs_reiserfs/reiserfs.c
parted-1.5.1-pre1/libparted/fs_reiserfs/reiserfs.c
--- parted-1.5.1-pre1-vanilla/libparted/fs_reiserfs/reiserfs.c Fri Jan 5 14:30:13
2001
+++ parted-1.5.1-pre1/libparted/fs_reiserfs/reiserfs.c Sun Feb 25 12:07:57 2001
@@ -34,8 +34,11 @@
#endif /* ENABLE_NLS */
#include <unistd.h>
-#include <asm/page.h>
#include <string.h>
+
+#ifdef linux
+#include <asm/page.h>
+#endif
#define REISERFS_SIGNATURE "ReIsErFs"
#define REISER2FS_SIGNATURE "ReIsEr2Fs"
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po
parted-1.5.1-pre1-vanilla/libparted/libparted.c parted-1.5.1-pre1/libparted/libparted.c
--- parted-1.5.1-pre1-vanilla/libparted/libparted.c Wed Jan 31 17:58:01 2001
+++ parted-1.5.1-pre1/libparted/libparted.c Sat Mar 3 18:12:45 2001
@@ -58,6 +58,13 @@
/* Note: loop must be added AFTER msdos, because DOS partition tables and
* FAT file systems are hard to tell apart :-/
*/
+extern void ped_disk_loop_init (void);
+extern void ped_disk_msdos_init (void);
+extern void ped_disk_pc98_init (void);
+extern void ped_disk_mac_init (void);
+extern void ped_disk_bsd_init (void);
+extern void ped_disk_sun_init (void);
+
static void
init_disk_types ()
{
@@ -69,6 +76,14 @@
ped_disk_sun_init ();
}
+extern void ped_file_system_ufs_init (void);
+extern void ped_file_system_reiserfs_init (void);
+extern void ped_file_system_ntfs_init (void);
+extern void ped_file_system_linux_swap_init (void);
+extern void ped_file_system_hfs_init (void);
+extern void ped_file_system_fat_init (void);
+extern void ped_file_system_ext2_init (void);
+
static void
init_file_system_types ()
{
@@ -97,16 +112,29 @@
return 1;
}
+extern void ped_disk_msdos_done (void);
+extern void ped_disk_pc98_done (void);
+extern void ped_disk_loop_done (void);
+extern void ped_disk_mac_done (void);
+extern void ped_disk_bsd_done (void);
+
static void
done_disk_types ()
{
ped_disk_msdos_done ();
- ped_disk_pc98_done ();
+ ped_disk_pc98_done ();
ped_disk_loop_done ();
ped_disk_mac_done ();
ped_disk_bsd_done ();
ped_disk_sun_done ();
}
+
+extern void ped_file_system_ext2_done (void);
+extern void ped_file_system_fat_done (void);
+extern void ped_file_system_hfs_done (void);
+extern void ped_file_system_linux_swap_done (void);
+extern void ped_file_system_ntfs_done (void);
+extern void ped_file_system_reiserfs_done (void);
static void
done_file_system_types ()
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/libparted/llseek.c
parted-1.5.1-pre1/libparted/llseek.c
--- parted-1.5.1-pre1-vanilla/libparted/llseek.c Mon Dec 4 20:12:47 2000
+++ parted-1.5.1-pre1/libparted/llseek.c Thu Jan 1 01:00:00 1970
@@ -1,80 +0,0 @@
-/*
- llseek.c -- llseek stub
- Derived from work Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
-
- 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., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/* This is a long, sad story about a function called lseek(). A long time ago,
- * (in a galaxy, far away), hard disks were small, and 32-bits was enough to
- * address any device. Hence, lseek()'s offset parameter was 32-bit on Linux
- * x86.
- * However, it became obvious that this wouldn't be enough, so the
- * llseek() syscall was added. However, some of the standard C libraries
- * did not use this llseek() properly. It is undocumented, as it is Linux
- * only. So, we always must call the Linux syscall directly.
- * When making one's own syscall, one uses the "_syscall5" macro
- * (where 5 is the number of paramters). However, a syscall (i.e.
- * software interrupt 0x80) takes its parameters through registers. In
- * particular, it uses ebx as the first parameter to the syscall function
- * (in llseek()'s case, the file descriptor).
- * Unfortunately, ebx is also used to store the global offset table, which
- * is needed in shared libraries. For some reason, gcc doesn't want to
- * push ebx before the interrupt, and pop it back again afterwards. Anyway,
- * the result is, the global offset table feature must be disabled. But this
- * feature is required for shared libraries, to make the code position
- * independent. So the result is, this part of the code must be statically
- * linked to any binaries.
- */
-
-static const char _llseek_c[] = "$Id: llseek.c,v 1.3 1999/10/02 20:56:47 aclausen Exp
$";
-
-#include "config.h"
-
-#if SIZEOF_OFF_T < 8 && defined(linux)
-
-#include <unistd.h>
-#include <linux/unistd.h>
-#include <syscall.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#ifndef __NR__llseek
-#define __NR__llseek 140
-#endif
-
-static _syscall5(int,_llseek,
- unsigned int, fd,
- unsigned long, offset_high,
- unsigned long, offset_low,
- loff_t*, result,
- unsigned int, origin)
-
-loff_t
-ped_llseek (unsigned int fd, loff_t offset, unsigned int whence)
-{
- loff_t result;
- int retval;
-
- retval = _llseek(fd,
- ((unsigned long long)offset) >> 32,
- ((unsigned long long)offset) & 0xffffffff,
- &result,
- whence);
- return (retval==-1 ? (loff_t) retval : result);
-}
-
-#endif /* SIZEOF_OFF_T < 8 && defined(linux) */
-
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/libparted/llseek.h
parted-1.5.1-pre1/libparted/llseek.h
--- parted-1.5.1-pre1-vanilla/libparted/llseek.h Mon Dec 4 20:12:47 2000
+++ parted-1.5.1-pre1/libparted/llseek.h Thu Jan 1 01:00:00 1970
@@ -1,35 +0,0 @@
-/*
- libparted - a library for manipulating disk partitions
- Copyright (C) 1998-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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef LLSEEK_H_INCLUDED
-#define LLSEEK_H_INCLUDED
-
-#include "config.h"
-
-#if SIZEOF_OFF_T < 8 && defined(linux)
-
-#include <sys/types.h>
-
-extern loff_t
-ped_llseek (unsigned int fd, loff_t offset, unsigned int whence);
-
-#endif /* SIZEOF_OFF_T < 8 && defined(linux) */
-
-#endif /* LLSEEK_H_INCLUDED */
-
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/parted/parted.c
parted-1.5.1-pre1/parted/parted.c
--- parted-1.5.1-pre1-vanilla/parted/parted.c Wed Jan 31 18:11:01 2001
+++ parted-1.5.1-pre1/parted/parted.c Sun Mar 4 18:40:19 2001
@@ -632,12 +632,17 @@
for (part = ped_disk_next_partition (disk, NULL); part;
part = ped_disk_next_partition (disk, part)) {
- if (part->type != PED_PARTITION_PRIMARY
- && part->type != PED_PARTITION_LOGICAL
- && part->type != PED_PARTITION_EXTENDED)
+ if (! (part->type == PED_PARTITION_PRIMARY
+ || part->type == PED_PARTITION_LOGICAL
+ || part->type == PED_PARTITION_EXTENDED
+ || (part->type == PED_PARTITION_FREESPACE
+ && part->geom.length > 10)))
continue;
- printf ("%-5d ", part->num);
+ if (part->type != PED_PARTITION_FREESPACE)
+ printf ("%-5d ", part->num);
+ else
+ printf ("%5s ", "");
printf ("%10.3f %10.3f ",
(int) part->geom.start * 1.0 / MEGABYTE_SECTORS,
@@ -652,6 +657,11 @@
if (has_name)
printf ("%-22s", ped_partition_get_name (part));
+ if (part->type == PED_PARTITION_FREESPACE) {
+ printf ("\n");
+ continue;
+ }
+
first_flag = 1;
for (flag = ped_partition_flag_next (0); flag;
flag = ped_partition_flag_next (flag)) {
@@ -1128,8 +1138,7 @@
PedDevice* dev;
#ifdef ENABLE_MTRACE
- if (getenv ("MALLOC_TRACE"))
- mtrace();
+ mtrace();
#endif
_init_i18n ();
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/parted/ui.c
parted-1.5.1-pre1/parted/ui.c
--- parted-1.5.1-pre1-vanilla/parted/ui.c Sat Jan 27 22:29:18 2001
+++ parted-1.5.1-pre1/parted/ui.c Sat Mar 3 18:14:03 2001
@@ -64,7 +64,8 @@
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
"GNU General Public License for more details.\n"
"\n"
-"GNU Parted's development is supported by Conectiva, www.conectiva.com\n");
+"GNU Parted's development is supported by Conectiva, www.conectiva.com\n"
+"\n");
static char* usage_msg = N_(
"Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]\n"
@@ -883,7 +884,7 @@
void
print_using_dev (PedDevice* dev)
{
- printf (_("\nUsing %s\n"), dev->path);
+ printf (_("Using %s\n"), dev->path);
#if defined (__i386__)
if (dev->type != PED_DEVICE_FILE) {
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/doc/API
parted-1.5.1-pre1/doc/API
--- parted-1.5.1-pre1-vanilla/doc/API Mon Jan 8 19:52:33 2001
+++ parted-1.5.1-pre1/doc/API Wed Feb 28 15:42:07 2001
@@ -217,7 +217,7 @@
device. Returns NULL if dev is the last device.
int ped_device_open (PedDevice* dev)
- INTERNAL: Attempts to open dev, to allow use uf ped_device_read(),
+ INTERNAL: Attempts to open dev, to allow use of ped_device_read(),
ped_device_write() and ped_device_sync(). Returns zero on failure.
int ped_device_close (PedDevice* dev)
@@ -225,7 +225,9 @@
int ped_device_read (PedDevice* dev, void* buffer, PedSector start,
PedSector count)
- INTERNAL: Reads count sectors, beginning with sector start, from dev.
+ INTERNAL: Reads count sectors, beginning with sector start, from dev
+ into the allocated buffer, BUFFER. A sector is defined as
+ PED_SECTOR_SIZE.
Returns zero on failure.
int ped_device_write (PedDevice* dev, void* buffer, PedSector start,
@@ -245,16 +247,18 @@
not use any libparted commands that do IO to a device (eg:
ped_file_system_{open|resize|copy}, ped_disk_{read|write}), while
a device is in external access mode.
- Also, you should not ped_device_close() a device, while it is
+ Also, you should not ped_device_close () a device, while it is
in external access mode.
- Note: ped_device_begin_external_access_mode() does things like
- tell the kernel to flush it's caches, and re-read the partition table.
+ Note: ped_device_begin_external_access () performs operations
+ such as telling the kernel to flush it's caches, and re-reading the
+ partition table.
Returns zero on failure.
int ped_device_end_external_access (PedDevice* dev)
Ends external access mode.
- Note: ped_device_end_external_access_mode() does things like
- tell the kernel to flush it's caches, and re-read the partition table.
+ Note: ped_device_end_external_access () performs operations
+ such as telling the kernel to flush it's caches, and re-reading the
+ partition table.
Returns zero on failure.
-----------------------------------------------------------------------------
@@ -267,7 +271,7 @@
Most programs will need to use ped_disk_open() or ped_disk_create() to get
anything done. A PedDisk is always associated with a device, and has a
partition table. There are different types of partition tables (or disk
-labels). These are represented by PedDiskType's.
+labels) and are represented by PedDiskType's.
4.1 FIELDS
--------------
diff -Nur --exclude configure --exclude Makefile.in --exclude aclocal.m4 --exclude
config.h.in --exclude dt.h --exclude po parted-1.5.1-pre1-vanilla/doc/USER
parted-1.5.1-pre1/doc/USER
--- parted-1.5.1-pre1-vanilla/doc/USER Thu Jan 18 13:53:54 2001
+++ parted-1.5.1-pre1/doc/USER Tue Mar 6 16:50:12 2001
@@ -4,7 +4,7 @@
by Andrew Clausen <[EMAIL PROTECTED]>
- Copyright (C) 1999-2000 Free Software Foundation, Inc.
+ Copyright (C) 1999-2001 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
@@ -71,25 +71,25 @@
------------------------------------------------------------------------------
GNU Parted is a program for creating, destroying, resizing, checking and
-copying partitions, and the filesystems on them.
-
-This is useful for creating space for new operating systems, reorganising
-disk usage, copying data between hard disks, and "disk imaging" - replicating
-installations over many computers.
-
-This documentation assumes knowledge of partitions and file systems. If you
-want to learn more about these, the Partition mini-HOWTO is recommended reading.
-It is probably included with your distribution, or it is available at
+copying partitions and the filesystems on them. This is most often used
+to creating space for new operating systems, reorganising disk usage, copying
+data between hard disks and "disk imaging," i.e. replicating installations
+over many computers.
+
+This documentation assumes some knowledge of partitions and file systems.
+If you want to learn more about these, we recommend reading the Partition
+mini-HOWTO. This is probably included with your distribution and is also
+available at:
http://www.linuxdoc.org/HOWTO/mini/Partition.html
-GNU Parted was designed to minimize the chance of data loss. For example, it
-was designed to avoid data loss during interruptions (like power failure) and
-performs many safety checks. However there could be bugs in Parted, so you
-should back up your important files.
+GNU Parted was designed to minimize the chance of data loss, for example,
+from an interruption caused by a power failure. Additionally, many safety
+checks are performed, however, there could be bugs in Parted and you should
+always back up your important files before using Parted.
-The GNU Parted homepage is www.gnu.org/software/parted. It can be downloaded
-from ftp.gnu.org/gnu/parted.
+The GNU Parted homepage is http://www.gnu.org/software/parted. GNU Parted
+itself can be downloaded from ftp://ftp.gnu.org/gnu/parted.
The Parted mailing list is [EMAIL PROTECTED] To subscribe, write to
[EMAIL PROTECTED] with "subscribe" in the subject. Subscription
@@ -98,8 +98,9 @@
http://mail.gnu.org/mailman/listinfo/bug-parted
Please send bug reports to [EMAIL PROTECTED] When sending bug reports,
-please include the version of GNU Parted. If the bug is related to
-partition tables, then please include the output from these commands:
+please include the version of GNU Parted that you were using. If the bug is
+related to partition tables, then please include what you expected to see.
+For instance under GNU/Linux, send the output from these commands:
# fdisk /dev/hda -l
# fdisk /dev/hda
@@ -107,34 +108,35 @@
Command (m for help): x
Extended command (m for help): p
-Feel free to ask for help on this list - just check that your question isn't
-answered here first. If you don't understand the documentation, please tell
-us, so we can explain it better. General philosophy is: if you need to ask for
-help, then something needs to be fixed so you (and others) don't need to ask
-for help.
+Feel free to ask for help on this list, however, just check that your question
+is not already answered here. If you do not understand the documentation,
+please tell us so we can explain it better. The general philosophy is: if you
+need to ask for help, then something needs to be fixed.
-Also, we'd love to hear your ideas :-)
+Also, we would love to hear your ideas :-).
1.1 Software required
------------------------------------------------------------------------------
- * libuuid, part of the e2fsprogs package. If you don't have this, you can
-get it from:
+ * libuuid, a part of the e2fsprogs package. If you do not have this, you
+can download it from:
http://web.mit.edu/tytso/www/linux/e2fsprogs.html
-If you want to compile Parted, and e2fsprogs, note that you will need to
-"make install" and "make install-libs" e2fsprogs.
+If you compile e2fsprogs, you will need to not only run "make install" but
+also "make install-libs".
- * GNU Readline (optional), available from
+ * GNU Readline (optional) available from:
ftp://ftp.gnu.org/gnu/readline
-If you are compiling Parted, and you don't have readline, you can disable
-Parted's readline support with the --disable-readline option for ./configure
+If you are compiling Parted and you do not want to use readline, you can
+disable Parted's support by providign the "--disable-readline" to Parted's
+configure script.
+
- * GNU gettext (or compatible software) for compilation, if
-internationalisation support is desired.
+ * GNU gettext (or compatible software) if internationalisation support is
+desired. It is available from:
ftp://ftp.gnu.org/gnu/gettext
@@ -142,9 +144,9 @@
1.2 Platforms supported
------------------------------------------------------------------------------
Hopefully, this list will grow a lot. If you do not have one of these
-platforms (Linux at the moment!), then you can use a boot disk (see
-section 1.5)
+platforms, then you can use a boot disk (see section 1.5)
+ * GNU/Hurd (x86 PCs)
* Linux >= 2.2.x (Alpha, x86 PCs, PC98 and Macintosh PowerPC)
Note: GNU libc 2.1 or higher is required. You can probably use older versions
@@ -168,59 +170,67 @@
------------------------------------------------------------------------------
If you want to compile GNU Parted, this is generally done with:
- $ ./configure
+ $ gunzip -cd parted-x.y.z.tar.gz | tar xv
+ $ mkdir parted-x.y.z-build; cd parted-x.y.z-build
+ $ ../parted-x.y.z/configure
$ make
+ $ sudo make install
-However, there are a few options for ./configure:
+x.y.z is the version tuple.
- --without-readline turns off use of readline. This is useful for
- making rescue disks, etc., where few libraries
- are available.
+Certain parts of Parted can be excluded or built in different ways depending
+on options passed to configure:
+
+ --without-readline turns off the use of readline. This is useful
+ for environments where there are few libraries
+ available, such as making rescue disks.
--disable-nls turns off native language support. This is
useful for use with old versions of glibc,
or a trimmed down version of glibc suitable
for rescue disks.
- --disable-shared turns off shared libraries. This may be
- necessary for use with old versions of GNU
- libc, if you get a compile error about a
- "spilled register". Also useful for boot/rescue
- disks.
+ --disable-shared turns off the generation and use of shared
+ libraries. This may be necessary for use with
+ old versions of GNU libc, if you get a compile
+ error about a "spilled register". Also useful
+ for boot/rescue disks.
- --enable-all-static builds the Parted binariey as a fully static
+ --enable-all-static builds the Parted binary as a fully static
binary. This is convienient for boot disks,
- because you don't need to install libraries any
- libraries on the boot disk (although, other
- programs may require them...) Note: you will
- also want to run strip(1)
+ as you do not need to install libraries any
+ on the boot disk (although, other programs
+ may require them...) Note: you will also want
+ to run strip(1).
1.5 GNU Parted boot disks
------------------------------------------------------------------------------
-If you want run Parted on a machine without GNU/Linux installed, or you
-want to resize a root or boot partition, you will need to use a boot disk.
-
+If you want run Parted on a machine without GNU/Linux or GNU/Hurd installed,
+or you want to resize a root or boot partition, you will need to use a boot
+disk.
A boot disk image is available from:
ftp://ftp.gnu.org/gnu/parted/bootdisk/partboot.img
-To actually create the boot disk, type (in GNU/Linux):
+To actually create a boot disk, type (in GNU/Linux or GNU/Hurd):
# dd if=partboot.img of=/dev/fd0 bs=1440k
-Or use RAWRITE.EXE under DOS.
+You can also use RAWRITE.EXE under DOS.
-Unfortunately, the boot disk doesn't support a very wide range of hardware.
-If your hard disk isn't supported, then:
+Unfortunately, the boot disk does not support a very wide range of hardware.
+If your hard disk is not supported, then:
(1) Boot off the Parted boot disk.
(2) Insert another (formatted) floppy disk.
(3) Mount the floppy disk. ("mount -t ext2 /dev/fd0 /mnt/floppy" or
-"mount -t vfat /dev/fd0 /mnt/floppy")
+"mount -t vfat /dev/fd0 /mnt/floppy" under GNU/Linux or
+"settrans -ac /mnt/floppy /hurd/ext2fs /dev/fd0" under GNU/Hurd)
(4) Copy /sbin/parted to the floppy. ("cp /sbin/parted /mnt/floppy")
(5) Copy /lib/* to the floppy. ("cp /lib/* /mnt/floppy)
-(6) Unmount the floppy. ("umount /mnt/floppy")
+(6) Unmount the floppy. ("umount /mnt/floppy" under GNU/Linux or
+"settrans -g /mnt/floppy" under GNU/Hurd)
(7) Find a boot disk that DOES support your hard disk. (Hint: try looking for
rescue disks from various distributions on big mirror sites)
(8) Boot off your rescue disk. Mount the disk you copied Parted onto.
@@ -232,35 +242,38 @@
------------------------------------------------------------------------------
2 USING PARTED
------------------------------------------------------------------------------
-Unfortunately, partitioning your disk is rather complicated. This is because
-there are interactions between many different systems that need to be taken
-into consideration:
+Unfortunately, partitioning your disk is rather complicated as there are
+interactions between many different systems that need to be taken into
+consideration. This includes:
* the BIOS or firmware - the program that is built into a ROM chip inside your
computer, that does memory checks, etc. You can not (easily) change programs
-in this system. Examples of BIOS or firmware programs: AmiBIOS, Award,
-Phoenix, OpenFirmware. You will only have one of these programs.
+in this system. Examples of BIOS or firmware programs are AmiBIOS, Award,
+Phoenix and OpenFirmware. You will only have one of these programs.
* the boot loader - the program that allows you to select which operating you
-want to use, and loads that operating system. Examples: LILO, GRUB, Yaboot,
-Quik. You may have more than one boot loader installed, especially if you have
-more than one type of operating system installed.
-
- * the operating system (at the moment, this must be GNU/Linux) that runs
-Parted, and the other operating systems that you use.
-
- * the file system types - the way the data stored on partitions. Examples
-of these are: ext2, fat, hfs, reiserfs. You will often have partitions of
-different file system types.
+want to use and bootstraps that operating system. Examples are LILO, GRUB,
+Yaboot and Quik. You may have more than one boot loader installed, especially
+if you have more than one type of operating system installed.
+
+ * the operating system that runs Parted (at the moment, this must be
+GNU/Linux or GNU/Hurd), and the other operating systems that you use.
+
+ * the file system types - the way the data are stored on partitions.
+Examples of these are ext2, fat, hfs and reiserfs. You will often have
+partitions of different file system types especially if you have multiple
+operating systems installed.
-Parted supports many combinations of the above, and will support more in the
-future. Therefore, there chapter 3 is on BIOSs, chapter 4 is on boot loaders,
+Parted supports many combinations of the above and will support more in the
+future. Therefore, chapter 3 is on BIOSs, chapter 4 is on boot loaders,
chapter 5 is on operating systems, and chapter 6 is on file systems.
- This chapter describes how to use Parted, which is largley the same,
-no matter what systems you are using. You should read this chapter, then each
-of chapters 3, 4, 5 and 6. However, you only need to read the sections that are
-relevant to you. For example, if you are only using LILO as your boot loader,
-then you only need to read the section on LILO in chapter 4.
+
+This chapter describes how to use Parted, which is largley the same, no
+matter what systems you are using. You should read this chapter and then
+each of chapters 3, 4, 5 and 6. However, you only need to read the sections
+that are relevant to your installation. For example, if you are only using
+LILO as your boot loader, then you only need to read the section on LILO in
+chapter 4.
2.1 Running Parted
@@ -270,10 +283,11 @@
# parted DEVICE
-where DEVICE is the hard disk device to edit. (If you're lazy, Parted will
-attempt to guess which device you want).
+where DEVICE is the hard disk device to edit. If you do not specify a device,
+Parted will attempt to guess by probing the common cases.
-In command line mode, this is followed by one or more commands. For example:
+In command line mode, the device is followed by one or more commands. For
+example:
# parted /dev/sda resize 1 52 104 mkfs 2 fat
@@ -285,16 +299,17 @@
(parted) resize 1 52.0005 104.5
(parted) mkfs 2 fat
-Unambiguous abbreviations are allowed. For example, you can type "p" instead
-of "print", and "re" instead of "resize". Commands can be typed in, either in
-English, or your native language (if your language has been translated). This
-may create ambiguouities.
+Unambiguous abbreviations are allowed, e.g. you can type "p" instead of
+"print", and "re" instead of "resize". Commands can be typed either in
+English or your native language (if your language has been translated and
+support has been enabled); this may create additional abbreviation
+ambiguouities.
-Also: note that you can specify decimal places in the numbers corresponding
+Also note that you can specify decimal places in the numbers corresponding
to partition locations (in megabytes).
-2.2 Options
+2.2 Command Line Options
------------------------------------------------------------------------------
-h, --help displays this help message
-i, --interactive where necessary, prompts for user intervention
@@ -302,7 +317,7 @@
-v, --version displays the version
-2.3 Command summary
+2.3 Command Summary
------------------------------------------------------------------------------
check MINOR do a simple check on the filesystem
cp [FROM-DEVICE] FROM-MINOR TO-MINOR copy filesystem to another partition
@@ -326,17 +341,18 @@
LABEL-TYPE is one of: bsd, mac, loop, pc98, msdos
-MINOR is the partition number used by Linux.
+MINOR is the partition number as shown by the "print" command.
PART-TYPE is one of: primary, logical, extended
A primary partition is a normal, vanilla partition. An extended partition is
-a partition that merely contains other partitions - logical partitions to
-be precise. There must be at most one extended partition, which takes up
-the space of one primary partition. If you are not using an msdos disk label,
-then you can only have primary partitions.
+a partition that merely contains other partitions, specifically, logical
+partitions. Logical partitions are primary partitions which live in an
+extended partition. There can be at most one extended partition. This takes
+up the space of one primary partition. If you are not using an msdos disk
+label, then you can only have primary partitions.
START and END are measured in megabytes, starting from 0. You can use
-decimal numbers (eg: 1258.9)
+decimal numbers, e.g. 1258.9.
2.4 Detailed command descriptions
@@ -355,21 +371,22 @@
2.4.2 cp
----------
- cp [FROM-DEVICE] FROM-MINOR TO-MINOR copy filesystem to another
+ cp [FROM-DEVICE] FROM-MINOR TO-MINOR copy a filesystem to another
partition
-Copies a partition to another partition, deleting the original contents of
-the destination partition. The first MINOR number refers to the source
-partition, and the second to the destination partition.
-
-An optional parameter, a device can be given, which specificies which device
-the source partition is on.
-
-Supported file systems:
- * ext2 (provided the destination partition is larger than the source
-partition)
+Copies a partition to another partition thereby deleting the original contents
+of the destination partition. The first MINOR number refers to the source
+partition and the second to the destination partition.
+
+An optional parameter, a device can be given. This specificies which device
+the source partition is on. The destination partition is always on the
+active device.
+
+Supported file systems are:
+ * ext2 (provided the destination partition is larger than or equal to the
+source partition)
* FAT
- * linux-swap (equivalent to mkfs on destination partition)
+ * linux-swap (equivalent to mkfs on the destination partition)
Example:
@@ -395,10 +412,10 @@
Creates a new disk label, of type LABEL-TYPE. Everyone seems to have a
different word for "disk label" - these are all the same thing: partition table,
-partition map. Also, the Master Boot Record on x86 machines is stored in the
-same sector as Partition Tables (you don't need to know this to use Parted)
+partition map. Also, the master boot record on x86 machines is stored in the
+same sector as the partition table (you do not need to know this to use Parted)
-Supported disk labels:
+Supported disk labels are:
* bsd
* loopback (raw disk access)
* mac
@@ -520,11 +537,11 @@
Resizes a partition. Note: resize never changes the minor number. Note also:
extended partitions can be resized, so long as the new extended partition
-completely contains all logical partitions.
+completely contains all of the logical partitions.
Note that Parted does not require a file system to be "defragged" (Parted
-can safely move data around if necessary). It's a waste of time defragging.
-Don't bother!
+can safely move data around if necessary). Defragging is a waste of time;
+do not bother!
Supported file systems:
* ext2 - restriction: the new START must be the same as the old START
@@ -544,7 +561,7 @@
use mkpart (NOT mkpartfs) to recover it. Also, you can use the gpart program
(see Section 6) to recover damaged disk labels.
-Note for msdos disk labels: that if you delete a logical partition, all
+Note for msdos disk labels, if you delete a logical partition, all
logical partitions with a larger minor number will be renumbered. For example,
if you delete a logical partition with a minor number of 6, then logical
partitions that were number 7, 8 and 9 would be renumbered to 6, 7 and 8
@@ -559,8 +576,8 @@
--------------
select DEVICE choose the device to edit
-Selects the device for Parted to edit. The device will usually be a Linux hard
-disk device, or, if direct access to a file systems required - a partition,
+Selects the device for Parted to edit. The device will usually be a block
+device or, if direct access to a file system is required - a partition,
software RAID device, or LVM logical volume.
Example:
@@ -573,7 +590,7 @@
set MINOR FLAG STATE change a flag on partition MINOR
Changes a flag on a partition. A flag can be either "on" or "off". Some or
-all of these flags will be available, depending on what disk label you are
+all of these flags will be available depending on what disk label you are
using:
* boot (Mac, MSDOS, PC98) - should be enabled if you want to boot off the
partition. The semantics vary between disk labels. For MSDOS disk labels,
@@ -602,11 +619,11 @@
------------
quit exit program
-Quits Parted. It is only after Parted exits that the Linux kernel knows about
+Quits Parted. It is only after Parted exits that the kernel knows about
the changes Parted has made to the disks. However, the changes caused by
-typing your commands will PROBABLY be made to the disk immediately after typing
-a command. However, Linux's cache, and the disk's hardware cache may delay
-this.
+typing your commands will PROBABLY be made to the disk immediately after
+typing a command. However, on Linux, the kernel cache, and the disk's
+hardware cache may delay this.
2.5 Examples
@@ -620,7 +637,7 @@
SITUATION
-Suppose your disk layout looks like this:
+Your disk layout looks like this:
(parted) print
Disk geometry for /dev/hda: 0.000-1000.000 megabytes
@@ -633,22 +650,22 @@
Partition 1 has an ext2 file system, which is the root device. Partition 2
is a swap device.
-Suppose you wanted to use the free space at the end of the disk for the file]
-system on partition 1.
+You want to use the free space at the end of the disk for the file system on
+partition 1.
EXAMPLE PROCEDURE
(1) The following steps will modify both the root file system on partition 1,
-and the swap device on partition 2. Therefore, you shouldn't be using either
+and the swap device on partition 2. Therefore, you should not be using either
partitions. You should probably use a Parted boot disk (see section 1.5).
From the boot disk, run Parted:
# parted /dev/hda
-(2) Remove partition 2 (the swap partition). Normally, you wouldn't want to
-delete a partition with data on it. However, a swap partition doesn't contain
-data when it isn't "swapped on" (mounted), so you can remove it, and create a
-replacement swap partition later.
+(2) Remove partition 2 (the swap partition). Normally, you would not want to
+delete a partition with data on it, however, a swap partition does not contain
+data when it is not "swapped on" (i.e. mounted), so you can remove it, and
+create a replacement swap partition later.
(parted) rm 2
@@ -681,8 +698,9 @@
SITUATION
-Suppose your disk layout looks like this:
+Your disk layout looks like this:
+ $ parted /dev/hda print
Disk geometry for /dev/hda: 0-8063.5 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
@@ -694,6 +712,7 @@
8 7326.5 7585.4 logical ext2
9 7585.4 7844.2 logical linux-swap
+ $ df
Filesystem Size Used Avail Use% Mounted on
/dev/hda8 251M 31M 207M 13% /
/dev/hda1 23M 2.4M 19M 11% /boot
@@ -701,16 +720,16 @@
/dev/hda6 3.4G 289M 2.9G 9% /home
/dev/hda7 251M 12M 226M 5% /var
-Suppose you wanted to increase the /var partition (/dev/hda7) to 1GB, using
-the space from /home (/dev/hda6).
+You want to increase the /var partition (/dev/hda7) to 1GB using the space
+from /home (/dev/hda6).
To resize a partition with Parted, you use the resize command:
(parted) resize PARTITION_NUMBER NEW_START NEW_END
NEW_START must be the same as the old start for ext2 partitions
-(unfortunately). So this process is going to be rather complicated. It IS
-possible, though :-)
+(unfortunately). So this process is going to be rather complicated; it IS,
+however, possible :-).
Note: if Parted supported moving the start of ext2 partitions (like it does
with FAT partitions), then it would be trivial:
@@ -725,7 +744,7 @@
# parted /dev/hda
(parted) resize 6 3545.6 6000
-(2) Make a new partition in it's place. This is where "/var" will be,
+(2) Make a new partition in its place. This is where "/var" will be,
eventually. This new partition will be numbered 10.
(parted) mkpartfs logical ext2 6000 7067.7
@@ -747,16 +766,16 @@
At this point: all logical partitions > 7 just changed number. So 8, 9 and 10
become 7, 8 and 9 respectively.
-This renumbering won't take place while any partitions are mounted on that
-disk (this will happen when you reboot). That's what that warning message
+This renumbering will not take place while any partitions are mounted on that
+disk (this will happen when you reboot). That is what that warning message
is talking about. So you should NEVER attempt to mount a file system touched
-by Parted (resized or created by Parted), before rebooting, if you get this
+by Parted (resized or created by Parted) before rebooting if you get this
message.
(5) Since the partition numbers have changed, /etc/fstab must be updated.
-This can be done before rebooting, because the root device wasn't touched
-by Parted. (If you want to use Parted to do something to the root device,
-you need to use the boot disk).
+This can be done before rebooting as the root device was not touched by
+Parted. (If you want to use Parted to do anything to the root device,
+you must use the boot disk).
If the old /etc/fstab looks like this:
@@ -795,56 +814,60 @@
------------------------------------------------------------------------------
3 BIOSES AND FIRMWARE
------------------------------------------------------------------------------
+
"BIOS" (Basic Input/Output System) and "firmware" mean the same thing. However,
on PC and PC98 based computers, the word BIOS is more common. On Apple
Macintosh and Sun computers, the word "firmware" is more common.
- The BIOS or firmware program is built into a ROM chip inside your
-computer, that does memory checks, etc. You can not (easily) change this
-program. Since BIOSes today are generally compatible with BIOSes in use 20
-years ago, these programs tend to have an antiquated design. Features have been
-added in counter-intuitive ways over the years, leading to overly complicated
-systems that cause a lot of confusion today.
+
+The BIOS or firmware program is built into a ROM chip inside your computer,
+that does memory checks, etc. You can not (easily) change this program.
+Since BIOSes today are generally compatible with BIOSes in use 20 years ago,
+these programs tend to have an antiquated design. Features have been added
+in counter-intuitive ways over the years leading to overly complicated systems
+that cause a lot of confusion today.
3.1 PC BIOSes
------------------------------------------------------------------------------
-There are a few popular PC BIOSes: AmiBIOS, Award, Phoenix, and others. They
-all work in a similar way. None of these BIOSes understand or know about
-partition tables. They affect partitioning indirectly.
- When your computer boots up, these BIOSes load the first bit of the boot
-loader program, stored on the MBR (Master Boot Record) on the hard disk. After
+
+There are a few popular PC BIOSes: AmiBIOS, Award, Phoenix, amoung others.
+They all work in a similar way. None of these BIOSes understand or know
+about partition tables. They affect partitioning indirectly.
+
+When your computer boots up, the BIOS loads the first block of the boot
+loader program stored on the MBR (Master Boot Record) on the hard disk. After
loading the first part of the boot loader, the BIOS executes it.
- The boot loader must then load the rest of itself. (There isn't
-enough room in the MBR for an entire boot loader!). The boot loader must ask
-the BIOS to do this. There are two ways it may do this: by using CHS
-(Cylinders Heads and Sectors) or LBA (Linear Block Addressing). Older BIOSes
-will only support CHS. New BIOSes usually support both LBA and CHS, although
-CHS support may be phased out in the future. On some BIOSes, you have to
-choose to enable LBA addressing.
+
+The boot loader must then load the rest of it itself (There is not enough
+room in the MBR for an entire boot loader!). The boot loader must ask the
+BIOS to do this by specifying where the rest of it lives on disk using either
+CHS (Cylinders Heads and Sectors) or LBA (Linear Block Addressing). Older
+BIOSes only support CHS. New BIOSes usually support both LBA and CHS,
+although CHS support may be phased out in the future. On some BIOSes,
+you have to choose to enable LBA addressing.
3.1.1 CHS mode, and BIOS geometry
-----------------------------------
The BIOS geometry of a hard disk is a triplet of 3 numbers: cylinders,
-heads and sectors. These numbers don't really mean much to anyone. However,
+heads and sectors. These numbers do not really mean much to anyone, however,
the BIOS, the boot-loader and the operating system must agree on what these
numbers are. This causes several problems:
* once you create a filesystem or disk label (i.e. partition table) on your
hard disk, you should not change BIOS geometry numbers in the BIOS setup
-program, unless you really know what you're doing. Of course, if you intend
+program unless you really know what you are doing. Of course, if you intend
to create a new disk label, changing the BIOS geometry numbers is safe.
* Linux usually detects the BIOS geometry automatically. However, sometimes
-it gets it wrong. In this case, you should tell it yourself, by passing
-a parameter to Linux. For example, if Linux thinks your hard drive /dev/hda
-has geometry 256/64/63, but the BIOS setup program says the geometry is
-512/32/63, then you would pass this parameter to Linux:
+it gets it wrong. In this case, you need to tell it yourself by passing
+a parameter to the kernel. For example, if Linux thinks your hard drive
+/dev/hda has the geometry 256/64/63 but the BIOS setup program says the
+geometry is 512/32/63, then you would pass this parameter to Linux:
hda=512,32,63
-Parameters are passed in different ways, depending what boot-loader you're
-using. You are probably using LILO. In this case, you add this line to
-/etc/lilo.conf: (You then need to run /sbin/lilo, for the change to take
-effect)
+Parameters are passed in different ways, depending what boot-loader you are
+using. If you are using LILO, you can add this line to /etc/lilo.conf:
+(You then need to run /sbin/lilo, for the change to take effect)
append="hda=512,32,63"
@@ -852,8 +875,8 @@
However, it cannot do this if there are no partitions on the disk. In this
case, you should check yourself. It is very important that you do this.
- * sometimes, Parted will complain that the partitions aren't aligned to
-cylinder boundaries. Parted can't deal with disks that have this problem (yet).
+ * sometimes, Parted will complain that the partitions are not aligned to
+cylinder boundaries. Parted cannot yet deal with disks that have this problem.
* partitions that are involved in the boot process must end before cylinder
1024, if CHS mode is being used. See the section on boot loaders to determine
@@ -861,30 +884,36 @@
3.1.2 LBA mode
----------------
-While, in principle, LBA mode should solve all of CHS's problems, it requires
+
+In principle, LBA mode should solve all of CHS's problems, however, it requires
other software to support LBA for the benefits to be realized. Unfortunately,
all of the above problems that CHS suffer, except the last one (boot partitions
being required to end near the start of the disk), still remain.
- We hope to eliminate most of these problems in the future...
+
+We hope to eliminate most of these problems in the future...
3.2 Macintosh OpenFirmware
------------------------------------------------------------------------------
+
There are two major version of the PowerMac's OpenFirmware - one used on
"old world", and one on "new world" PowerMac. They have significant
-differences. However, both understand partition tables.
- Both require that the user choose exactly one partition to be the boot
+differences, however, both understand partition tables.
+
+Both require that the user choose exactly one partition to be the boot
partition (the partition with the boot loader). However, they use different
mechanisms to do this.
-3.2.1 Old world OpenFirmware
+3.2.1 Old World OpenFirmware
------------------------------
+
The partition chosen to boot is set by various boot loaders, like Quik. So,
-you shouldn't need to do anything. We could add support for this in Parted, if
-someone screams louldy enough....
+you should not need to do anything. We could add support for this in Parted,
+if someone screams loud enough....
-3.2.2 New world OpenFirmware
+3.2.2 New World OpenFirmware
------------------------------
+
New world OpenFirmware requires the boot partition to be HFS and marked as
a boot partition. It uses a different mechanism to be marked as the boot
partition. This is controlled with Parted's "boot" flag. For example:
@@ -894,6 +923,7 @@
3.3 PC98 BIOS
------------------------------------------------------------------------------
+
The PC98 BIOS allows you to mark any number of partitions as bootable. You
can mark or unmark a partition as bootable with Parted's "boot" flag. For
example:
@@ -904,28 +934,30 @@
------------------------------------------------------------------------------
4 BOOT LOADERS
------------------------------------------------------------------------------
+
The boot loader is the program that allows you to select which operating you
-want to use, and loads that operating system. You may have more than one boot
-loader installed, especially if you have more than one type of operating
-system installed. It is common for boot loaders to be able to load other
-boot loaders.
-
-When resizing a partition, lots of data gets moved around. Many boot loaders
-don't understand the filesystem. They just remember where on the disk the
-required boot loader information lies. If this information is moved, they
-must be told where it has been moved. This is done by reinstalling the boot
+want to use and then loads that operating system. You may have more than one
+boot loader installed. This is especially common if you have more than one
+type of operating system installed. It is common for boot loaders to be able
+to load other boot loaders.
+
+When resizing a partition, lots of data are moved around. Many boot loaders
+do not understand the filesystem -- they just remember where on the disk the
+required boot loader information lies. Thus, if this information is moved,
+they must be told of the new location. This is done by reinstalling the boot
loader (i.e. re-running the boot-load installer program, which usually
-involves issuing a single command at the shell) Not all boot loaders require
+involves issuing a single command at the shell). Not all boot loaders require
this.
4.1 LILO (Linux Loader)
---------------------------
-LILO is a popular boot loader for x86. LILO's boot loader is usually installed
-with:
+
+LILO is a popular boot loader for Linux on the x86 architecture. LILO's boot
+loader is usually installed by running:
# /sbin/lilo
-If you are using a boot disk, then you should do this instead: (where /dev/hda1
+If you are using a boot disk then you should do this instead: (where /dev/hda1
should be replaced with your root device)
# mount /dev/hda1 /mnt
@@ -933,22 +965,24 @@
# umount /dev/hda1
(Not so) old version of LILO require that the partition with your /boot
-directory finish before the 1024 cylinder. So, if you have a large disk
+directory finish before the 1024 cylinder. Thus, if you have a large disk
(say, over 8 gig), you should have a /boot partition near the start of your
-disk. Newer versions of LILO don't have this problem (provided you have
+disk. Newer versions of LILO do not have this problem (provided you have
a new enough BIOS - probably post 1995 (?))
4.2 GNU GRUB (GRand Unified Bootloader)
-------------------------------------------
-GRUB is a relatively new boot loader, for x86. Depending on how GRUB is
+
+GRUB is a relatively new boot loader for x86. Depending on how GRUB is
installed, it may understand the filesystem, or simply remember where the boot
-files are stored. It understands the filesystem if it's using "Stage1.5". If
-it's not using Stage1.5, then you need to reinstall Stage2 (please see the GRUB
-documentation). Otherwise, you don't need to do anything.
+files are stored. It understands the filesystem if it is using "Stage1.5". If
+it is not using Stage1.5, then you need to reinstall Stage2 (please see the
+GRUB documentation). Otherwise, you do not need to do anything.
4.3 MS DOS, MS Windows 9x, MS Windows ME
--------------------------------------------
+
DOS and Windows require you to re-install the boot loader if you change the
FAT type (FAT16 or FAT32) of the boot partition. Parted will warn you before
attempting to do this. To re-install the boot loader, you can either create
@@ -990,35 +1024,38 @@
(parted) set 3 boot on
* the MS DOS and MS Windows 9x/ME can only boot from the first FAT partition.
-That is, the FAT partition with the smallest MINOR number, that isn't hidden.
+That is, the FAT partition with the smallest MINOR number, that is not hidden.
Note that boot loaders like GRUB and LILO (and some BIOSes) can change this
behaviour...
* if you are using CHS addressing (you probably are), then the boot
partition start must be less than cylinder 1024. You can tell MS DOS to use
-(or not to use) LBA addressing, by enabling or disabling the LBA flag on the
-boot partition. For example, to enable the LBA flag on partition 2, do:
+(or not to use) LBA addressing by enabling or disabling the LBA flag on the
+boot partition. For example, to enable the LBA flag on partition 2, you
+would run:
(parted) set 2 lba on
-Note: LBA addressing is not supported in MS-DOS 6.22 and lower, as well as all
-versions of PC-DOS.
+Note that LBA addressing is not supported in MS-DOS 6.22 and lower, as well
+as all versions of PC-DOS.
-Warning: some BIOSes won't enable LBA addressing, unless you enable it. If
-for some reason, Windows doesn't boot after changing this flag, this is
-probably the problem.
+Warning: some BIOSes will not enable LBA addressing, unless you specifically
+enable it. If for some reason, Windows does not boot after changing this flag,
+this is probably the problem.
* the "real" MS-DOS (i.e. up to version 6.22) and MS-DOS 7.0 (i.e. Windows
-95/95a) don't know about FAT32. It's therefore possible to boot them from the
-SECOND FAT (FAT16 only, of course) partition, when the FIRST FAT partition is
-FAT32. Both have to be primary partitions, so you'll have to set the one you
-want to boot from as active partition.
+95/95a) do not know about FAT32. It is therefore possible to boot them from
+the SECOND FAT (FAT16 only, of course) partition when the FIRST FAT partition
+is FAT32. Both have to be primary partitions, so you will have to set the one
+you want to boot from as active partition.
4.4 MS Windows NT, MS Windows 2000
--------------------------------------
+
Windows NT and 2000 require you to re-install the boot loader if you change the
FAT type (FAT16 or FAT32) of the system partition. Parted will warn you before
-attempting to do this. To re-install the boot loader, do:
+attempting to do this. To re-install the boot loader:
+
(1) Boot off the Windows 2000 CD
(2) It will ask if you want to proceed installing. Hit Enter
(3) It will then ask you if you want to install a new system, or
@@ -1030,7 +1067,8 @@
C:\>fixboot
The NT/2000 boot loader also needs:
- * it's own boot sector code in a PRIMARY FAT12, FAT16 or NTFS partition
+
+ * its own boot sector code in a PRIMARY FAT12, FAT16 or NTFS partition
(FAT32 possible with Windows 2000), which is called the "system partition".
This partition should be marked with the "boot" flag in Parted.
* the files NTLDR, BOOT.INI and NTDETECT.COM within the system partition.
@@ -1038,20 +1076,21 @@
partition or logical drive where Windows NT was installed to, called the "boot
partition". The boot partition and system partition may be located together in
one primary partition.
- * optionally, the file NTBOOTDD.SYS within the system partition, which is the
-renamed disk driver for your SCSI or IDE controller, when this has no own BIOS
-(or it's BIOS can't access large disks).
+ * optionally, the file NTBOOTDD.SYS, within the system partition, is the
+renamed disk driver for your SCSI or IDE controller when this has BIOS of
+its own or it cannot access large disks.
* with MS Windows NT the system partition should end before cylinder 1024,
and MUST start before cylinder 1024. If it ends after cylinder 1024 and the
-files necessary to boot are moved past this border MS Windows NT won't start
-anymore!
+files necessary to boot are moved past this border MS Windows NT will not
+start anymore!
* both the boot and system partition may be resized, without the need for
any other changes.
- * if the boot partition's number changes (i.e. it's MINOR number), then the
+ * if the boot partition's number changes (i.e. its MINOR number), then the
BOOT.INI has to be updated.
4.5 Quik
------------
+
Quik is a popular boot loader for old-world Macintosh PowerPCs. You need to
reinstall Quik if you resize an ext2 partition, with:
@@ -1059,10 +1098,11 @@
4.6 Yaboot
--------------
+
Yaboot is a popular boot loader for new-world Macintosh PowerPCs. (New-world
refers to coloured PowerPCs manufactured since 1999)
- Yaboot needs it's own boot strap partition, that must be at least 800k.
-So, if you are installing GNU/Linux from scratch, you would do something like:
+ Yaboot needs its own boot strap partition that must be at least 800k.
+Thus, if you are installing GNU/Linux from scratch, you would do something like:
(parted) mklabel mac
(parted) print
@@ -1085,40 +1125,43 @@
1 0.000 0.031 Apple
2 0.031 1.000 boot
- You don't need to reinstall yaboot after resizing a partition. Yaboot
-is installed with ybin.
+ You do not need to reinstall yaboot after resizing a partition. Yaboot
+is installed using ybin.
------------------------------------------------------------------------------
5 OPERATING SYSTEMS
------------------------------------------------------------------------------
-Parted only runs under GNU/Linux, at the moment. However, it can be used to
-resize partitions used by, or shared with other operating systems.
+
+Parted only runs under GNU/Hurd and GNU/Linux at the moment. However, it can
+be used to resize partitions used by, or shared with other operating systems.
When you want to resize a file-system, make sure it is not mounted. Parted
-can't resize mounted partitions (this may change in the future...)
+cannot resize mounted partitions (this may change in the future...)
If you want to resize your root or boot partition, use a boot disk (see
section 1.5), or use Andreas Dilger's online ext2 resizer, included in the
ext2resize package (see Section 6 for details).
If you modify the partition table on a disk with a partition mounted on it,
-you should reboot immediately. Linux won't know about the changes you made
-the partition table. (This will be fixed, with kernel 2.4, and when we add
-support for it)
-
+you should reboot immediately. Linux will not know about the changes you made
+the partition table (This will be fixed, with kernel 2.4, and when we add
+support for it).
5.1 GNU/Linux and FreeBSD
------------------------------------------------------------------------------
-Both systems are rather flexible about disk labels, supporting many different
+
+Both systems are rather flexible about disk labels supporting many different
disk label types.
- FreeBSD commonly uses a partition slice system, that isn't supported
-by Parted (yet).
+
+FreeBSD commonly uses a partition slice system, that is not supported by Parted
+(yet).
5.2 MS Windows and OS/2
------------------------------------------------------------------------------
-MS Windows and OS/2 only supports the msdos disk label. Therefore, if you
+
+MS Windows and OS/2 only support the msdos disk label. Therefore, if you
create a new disk label, you should use:
(parted) mklabel msdos
@@ -1126,6 +1169,7 @@
5.3 MacOS
------------------------------------------------------------------------------
+
MacOS (and Open Firmware) only understands the mac disk label. Therefore, if
you create a new disk label, you should use:
@@ -1133,7 +1177,7 @@
Note: for Mac partition maps, you should avoid leaving free space around,
because free space regions take up entries in the partition map (and Linux
-doesn't like having more than 15 entries). For example, if you do:
+does not like having more than 15 entries). For example, if you do:
(parted) print
Disk geometry for /dev/sda: 0.000-6149.882 megabytes
@@ -1154,7 +1198,7 @@
There is 1 megabyte of free space between partitions 3 and 4. You can avoid
this, by creating partitions 0.1M apart (in which case, Parted automatically
-"pushes" them together). So, in the above example, you should do this instead:
+"pushes" them together). So, in the above example, you could do this instead:
(parted) mkpartfs primary ext2 1000.1 2000
(parted) print
@@ -1180,6 +1224,7 @@
linux-swap * * * * *
ntfs *
reiserfs *
+ufs FIXME
NOTES:
(1) The start of the partition must stay fixed for ext2.
@@ -1194,23 +1239,27 @@
(4) The size of the new partition, after resizing or copying, is restricted
by the cluster size for fat (mainly affects FAT16). This is worse than you
-think, because you don't get to choose your cluster size (it's a bug in
+think, because you do not get to choose your cluster size (it is a bug in
Windows, but you want compatibility, right?).
- So, in practise, you can always shrink your partition (because Parted
-can shrink the cluster size), but you may not be able to grow the partition
-to the size you want. If you don't have any problems with using FAT32, you
-will always be able to grow the partition to the size you want.
- Summary: you can always shrink your partition. If you can't use
-FAT32 for some reason, you may not be able to grow your partition.
+
+So, in practise, you can always shrink your partition (Parted can shrink the
+cluster size), but you may not be able to grow the partition to the size you
+want. If you do not have any problems with using FAT32, you will always be
+able to grow the partition to the size you want.
+
+Summary: you can always shrink your partition. If you cannot use FAT32 for
+some reason, you may not be able to grow your partition.
6.1 Ext2
------------------------------------------------------------------------------
-Parted doesn't directly support for copying ext2 filesystems (yet).
-There are a few ways of achieving this, however:
+
+Parted does not yet directly support copying ext2 filesystems. There are,
+however, a few ways of achieving this:
+
* use Parted's mkfs command (or mkfs.ext2), and then run at the shell:
- FIXME!!! this doesn't work quite right - but it should be OK for
+ FIXME!!! this does not work quite right - but it should be OK for
most people...
# mount -t ext2 /dev/hda2 /mnt/dst
@@ -1228,27 +1277,32 @@
6.2 FAT16 and FAT32
------------------------------------------------------------------------------
+
Parted can not grow the cluster size of FAT filesystems (yet). This
places restrictions on resizing and copying partitions. This is often quite
-bizarre, because Parted can convert filesystems between FAT16 and FAT32,
+bizarre because Parted can convert filesystems between FAT16 and FAT32,
which have different restrictions on what the cluster size can be.
-For example, lets say have a 100Mb partition with a cluster size 4k. This
-partition can't be resized to 400Mb, because the cluster size would need to
-be changed to 16k. However, it can be resized to 600Mb if you use FAT32. The
-reverse is true for 600Mb FAT32 filesystems.
+For example, take a 100Mb partition with a cluster size 4k. This partition
+cannot be resized to 400Mb because the cluster size would need to be changed
+to 16k. However, it can be resized to 600Mb if you use FAT32. The reverse
+is true for 600Mb FAT32 filesystems.
+
6.2.1 MS DriveSpace partitions
--------------------------------
+
MS DriveSpace is a program that comes with MS Windows 95, that can be used
-to compress FAT filesystems. I believe this works the same way as DoubleSpace,
-so everything said here applies should apply to DoubleSpace as well.
+to compress FAT filesystems. I believe that this works the same way as
+DoubleSpace, so everything said here applies should apply to DoubleSpace as
+well.
It is possible to use Parted to resize and copy these partitions, but you
have to do a few extra things...
6.2.1.1 Growing a DriveSpace partition
--------------------------------------
+
(1) Use Parted's resize command to grow the partition to the desired size.
(2) Use MS DriveSpace to shift the free space from the host drive to the
@@ -1256,16 +1310,18 @@
6.2.1.2 Shrinking a DriveSpace partition
----------------------------------------
+
(1) Use MS DriveSpace to shift the free space from the compressed drive to
the host drive. The amount of free space shifted corresponds to the desired
amount by which to shrink the partition.
(2) Use Parted's resize command to shrink the partition to the desired
-size. NOTE: Parted doesn't give good feedback on what the numbers, to
+size. NOTE: Parted does not give good feedback on what the numbers, to
know how much to shrink the partition by. This is on the TODO list.
6.2.1.3 Copying a DriveSpace partition
--------------------------------------
+
If you want to copy a DriveSpace partition to a partition that is bigger,
then you can follow the instructions for growing a DriveSpace partition,
except you copy rather than resize the desired partition, and make sure
@@ -1289,8 +1345,9 @@
6.3 Reiserfs
------------------------------------------------------------------------------
-Parted does not support reiserfs. However, reiserfs does come with it's own
-resize tool, resize_reiserfs. Just to let you know ;-)
+
+Parted does not support reiserfs. However, reiserfs does come with its own
+resize tool, resize_reiserfs.
------------------------------------------------------------------------------
@@ -1299,18 +1356,19 @@
LVM (Logical Volume Manager) is an alternative system to partitioning. It
allows logical volumes (i.e. "virtual partitions") to be spread over many
-physical volumes (i.e. hard disks and/or partitions). LVM is supported on Linux
-version 2.4, and later.
+physical volumes (i.e. hard disks and/or partitions). LVM is supported on
+Linux version 2.4, and later.
RAID (Redundant Array of Inexpensive Disks) is a system for using many disks
and/or partitions together, as a "virtual partition". There are a few different
modes of utilising software RAID, that are essentially:
+
* using multiple (small) disks for a single file system, to improve
performance and to make the entire space available available on a single file
system.
* using multiple disks to store redundant copies of information, to improve
reliability and performance.
-Software RAID is supported on Linux version 2.0, and later.
+Software RAID is supported on the Hurd and Linux version 2.0, and later.
Hardware RAID is supported normally by Parted - so you need not read this
section if you are using hardware RAID (as opposed to software RAID).
@@ -1319,9 +1377,9 @@
all be used independently:
* LVM and software RAID are often composed of partitions, rather than raw
hard disks.
- * !!! FIXME (Note: RAID used on LVM isn't yet supported by Linux yet (?))
+ * !!! FIXME (Note: RAID used on LVM is not yet supported by Linux yet (?))
-GNU Parted does not support LVM and software RAID in full, but it is still
+GNU Parted does not support LVM and software RAID in full, however, it is still
useful when used in combination with their respective tools. Parted is useful
for these tasks:
* creating a software RAID or LVM partition
@@ -1333,23 +1391,24 @@
-------------------------------------------------------------------------------
To create a RAID or LVM partition, you must:
-(1) Create a partition with the mkpart command.
-(2) Set the LVM or RAID flag on the partition.
+
+ (1) Create a partition with the mkpart command.
+ (2) Set the LVM or RAID flag on the partition.
For example:
(parted) mkpart primary ext2 0 4000
(parted) set 1 lvm on
-Note: the LVM or RAID partition will not be ready for use yet. You still need
-to run mkraid(8) for RAID, or use the LVM tools to initialise the physical
+Note: the LVM or RAID partition will not be ready for use yet, you still need
+to run mkraid(8) for RAID or use the LVM tools to initialise the physical
volume, and create logical groups, etc.
7.2 Manipulating a file system on a Software RAID or LVM logical volume
-------------------------------------------------------------------------------
-Parted can manipulate RAID and LVM logical volumes, even though it does not
+Parted can manipulate RAID and LVM logical volumes even though it does not
understand RAID and LVM. It utilises Linux's support for RAID and LVM.
Therefore, you can only use these methods if your Linux kernel supports RAID
and/or LVM.
@@ -1361,11 +1420,12 @@
# parted /dev/md0
For the rest of this chapter, "virtual device" will refer to the device Parted
-is editting (in the immediately example above: /dev/md0).
+is editing (in the immediately example above: /dev/md0).
7.2.1 Creating a file system
------------------------------
+
(1) Create a loopback disk label. This is a fake disk label, that tells Parted
to treat the virtual device as a single file system. With this fake disk label,
there is either zero or one partition.
@@ -1390,6 +1450,7 @@
7.2.2 Resizing a file system
------------------------------
+
You usually resize the file system at the same times as you resize your virtual
device. If you are growing the file system and virtual device, you should grow
the device first (with the RAID or LVM tools), and then grow the file system.
@@ -1403,6 +1464,7 @@
7.2.3 Copying a file system from a virtual device to a partition
------------------------------------------------------------------
+
Just use the cp command. For example:
(parted) select /dev/hda
@@ -1410,6 +1472,7 @@
7.2.4 Copying a file system to a virtual device
-------------------------------------------------
+
(1) Create the loopback disk label on the virtual device. For example:
(parted) select /dev/md0
@@ -1430,35 +1493,35 @@
8 DISK IMAGING
------------------------------------------------------------------------------
-Disk imaging is a method for avoiding the tedious Windows install process.
+Disk imaging is a method for avoiding the tedious Windows installation process.
For example, if you want to install Windows and Office on 1000 machines,
-it'll probably take you about 5 times 1000 hours. Things aren't so bad
-with GNU/Linux, because there are programs like Red Hat's kickstart, which
-allow you to automate the install of other programs, or practically anything
-you need to do. Therefore, disk imaging is really only used for Windows
-machines. Obviously, we urge you to not use Windows (or any non-free
-software) at all, but we realise that most organisations would find it
-impossible switch from Windows to GNU/Linux (or other free software)
-without a transition period, where both systems are available.
+it will probably take about 5 times 1000 hours. Things are not so bad
+with GNU/Linux due to programs such as Red Hat's kickstart, which allows you
+to automate the install of other programs, or practically anything you need
+to do. Therefore, disk imaging is really only used for Windows machines.
+Obviously, we urge you to not use Windows (or any non-free software) at all,
+however, we realise that most organisations would find it impossible switch
+from Windows to GNU/Linux (or other free software) without a transition
+period, where both systems are available.
With disk imaging, you can burn a CD with a disk image of a partition
containing Windows and Office, and copy the partition directly onto the hard
-disks of all the computers, by sticking in a boot disk and the CD, and
-letting it fly. But the partition on the Windows disk is probably going to be
-bigger, so the partition will also have to be resized. I've had several
-people say that they've managed to automate this process with Linux boot
-floppies and Parted. It is possible to use the CD ROM only, by using the
+disks of all the computers, by inserting a boot disk, a CD, and then
+letting it fly. As the partition on the Windows disk is probably going to be
+bigger then the CD, the partition will have to be resized. I have had several
+people say that they have managed to automate this process with Linux boot
+floppies and Parted. It is possible to use the CD ROM only by using the
floppy as the boot image on the CD. Read the CD writing HOWTO for more
information. There are a few weird things you have to do to get this whole
-thing to work (which will be fixed in the next stable series). Anyway, this
+process to work (this will be fixed in the next stable series). This
is the general process:
-(1) Install Windows on a machine, with the setup you want. You can have the
-partition as big as you want, so long as you don't use more than 640 Mb, and
-you leave enough room for a complete Linux install, and another 1300 Mb
+(1) Install Windows on a machine with the setup you want. You can have the
+partition as big as you want so long as you do not use more than 640 Mb and
+you leave enough room for a complete GNU/Linux install and another 1300 Mb
for two copies of the CD image.
-(2) Install Linux on the machine.
+(2) Install GNU/Linux on the machine.
(3) Make a directory for the CD image (eg: /root/cdimage/)
@@ -1481,24 +1544,24 @@
localhost:~/parted-1.0.0# ./configure --disable-nls
--without-readline --disable-shared; make
-(8) Create a Linux boot disk (see the Bootdisk HOWTO).
+(8) Create a GNU/Linux boot disk (see the Bootdisk HOWTO).
(9) Put the cut-down version of Parted on the boot disk (or a supplementary
root disk).
(10) Write a shell script to do the following:
- mount /dev/cdrom /mnt/cdrom
- parted --script /dev/hda mklabel msdos mkpartfs primary fat 0 SOME-SIZE
- parted --script /dev/hda cp /mnt/cdrom/diskimage 1 1
- parted --script /dev/hda set 1 boot on
- /sbin/halt
+ $ mount /dev/cdrom /mnt/cdrom
+ $ parted --script /dev/hda mklabel msdos mkpartfs primary fat 0 SOME-SIZE
+ $ parted --script /dev/hda cp /mnt/cdrom/diskimage 1 1
+ $ parted --script /dev/hda set 1 boot on
+ $ /sbin/halt
(11) Start installing! Stick the floppy + CD into each computer, and let it
roll...
-Obviously, I can and will make this process a lot easier. We're considering
-making a mini-distribution to do this. I wouldn't have time to maintain such
+Obviously, I can and will make this process a lot easier. We are considering
+making a mini-distribution to do this. I would not have time to maintain such
a thing - any volunteers?
@@ -1506,8 +1569,8 @@
9 FURTHER INFORMATION AND RELATED SOFTWARE
------------------------------------------------------------------------------
-If you want to find out more information, feel free to send questions
-to [EMAIL PROTECTED] (!) indicates the information/software is probably included
+If you want to find out more information, feel free to send questions to
[EMAIL PROTECTED] (!) indicates the information/software is probably included
in your distribution.
These files in the Parted distribution contain further information:
@@ -1527,8 +1590,8 @@
* TODO - planned features that are not yet implemented
These documents are not distributed with Parted, but you may find them
-useful. Most of these will probably be in your distribution. Eg: on Red Hat
-Linux, look on the CD in /doc/HOWTO and /doc/FAQ.
+useful. Most of these will probably be in your distribution E.g. on Debian
+GNU/Linux, look on the CD in /doc/HOWTO and /doc/FAQ.
* Filesystems HOWTO http://penguin.cz/~mhi/fs/
* Hard Disk Upgrade mini-HOWTO (!): http://sunsite.unc.edu/LDP/HOWTO
* Large Disk HOWTO http://www.win.tue.nl/~aeb/linux/Large-Disk.html
@@ -1548,14 +1611,15 @@
Other related programs are listed here. Some of these also have useful
documentation:
+
* Disk Drake. www.linux-mandrake.com/diskdrake. This is similar in
functionality to Parted. The FAT code in Disk Drake is based on our
-Parted code. Here's how Disk Drake compares to Parted: (which we both
-agree to :-) Disk Drake is:
+Parted code. Here is how Disk Drake compares to Parted (which we both
+agree to :-)) Disk Drake is:
- easier to use, protects you from making mistakes
- more complete solution (handles /etc/fstab, lilo, etc.)
- - less support for FAT (can't convert FAT16<->FAT32, can't copy
+ - less support for FAT (cannot convert FAT16<->FAT32, cannot copy
partitions)
- less support for ext2 (at the moment)
- less attention to compatibility between (older) DOS/Windows systems
@@ -1564,8 +1628,8 @@
* dosfsck
* e2fsck, resize2fs e2fsprogs (!)
http://web.mit.edu/tytso/www/linux/e2fsprogs.html
- * ext2resize - uses the same code as Parted, but includes some other
-goodies as well, such as an online ext2 resizer, that doesn't require
+ * ext2resize - uses the same code as Parted but includes some other
+goodies as well such as an online ext2 resizer that does not require
unmounting. http://ext2resize.sourceforge.net
* fdisk (!)
* FIPS (!) (First Interactive Partition Splitter)
PGP signature