bug-parted
[Top][All Lists]
Advanced

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

[PATCH] Hurd port


From: Neal H Walfield
Subject: [PATCH] Hurd port
Date: Sun, 17 Jun 2001 22:44:03 -0500
User-agent: Mutt/1.3.18i

This corrects (against 1.5.2-pre1) a bunch of problems with the Hurd
port.  I have used this code and tested it on a file making partitions
and filesystems and it _seems_ to work correctly.  I even used to code
to make a partition and a filesystem on my hard drive; I held my breath,
but it worked!  I do, however, warn you that I have not verified all of
the code -- I think that Andrew changed some of the semantics between
this and the last version.

Having said that, I had to use this hack:

Index: libparted/Makefile.am
===================================================================
RCS file: /home/neal/cvs/parted/libparted/Makefile.am,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile.am
--- libparted/Makefile.am       2001/06/17 14:12:56     1.1.1.1
+++ libparted/Makefile.am       2001/06/18 03:27:49
@@ -18,8 +18,6 @@
                        exception.c             \
                        filesys.c               \
                        geom.c                  \
-                       llseek.c                \
-                       llseek.h                \
                        libparted.c             \
                        natmath.c               \
                        disk.c                  \
@@ -29,10 +27,14 @@
                        disk_mac.c              \
                        disk_pc98.c             \
                        disk_sun.c
+                       # llseek.c              \
+                       # llseek.h              \ 
 
 EXTRA_libparted_la_SOURCES = device_linux.c device_gnu.c
 
 libparted_la_LIBADD   =        @UUID_LIBS@                     \
+                       -lstore                         \
+                       -lshouldbeinlibc                \
                        fs_ext2/libext2.la              \
                        fs_fat/libfat.la                \
                        fs_hfs/libhfs.la                \


to get it to compile.  This clearly needs to be autoconfized.

Here is a small problem with the linux stuff:

Index: libparted/device_linux.c
===================================================================
RCS file: /home/neal/cvs/parted/libparted/device_linux.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 device_linux.c
--- libparted/device_linux.c    2001/06/17 14:12:56     1.1.1.1
+++ libparted/device_linux.c    2001/06/18 03:27:49
@@ -568,9 +568,9 @@
        return dev;
 
 error_free_arch_specific:
-       free (dev->arch_specific);
+       ped_free (dev->arch_specific);
 error_free_path:
-       free (dev->path);
+       ped_free (dev->path);
 error_free_dev:
        ped_free (dev);
 error:


This is because _GNU_SOURCE already defines __USE_GNU.  Maybe this can
be autoconfized.

Index: parted/strlist.c
===================================================================
RCS file: /home/neal/cvs/parted/parted/strlist.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 strlist.c
--- parted/strlist.c    2001/06/17 14:12:56     1.1.1.1
+++ parted/strlist.c    2001/06/18 03:27:49
@@ -31,6 +31,7 @@
 
 #ifdef ENABLE_NLS
 
+#undef __USE_GNU
 #define __USE_GNU
 
 #include <wchar.h>

And here are the guts of the patch:

Index: libparted/device_gnu.c
===================================================================
RCS file: /home/neal/cvs/parted/libparted/device_gnu.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 device_gnu.c
--- libparted/device_gnu.c      2001/06/17 14:12:56     1.1.1.1
+++ libparted/device_gnu.c      2001/06/18 03:27:49
@@ -19,6 +19,8 @@
 
 #define _GNU_SOURCE 1
 
+#include <parted/parted.h>
+
 #include <string.h>
 #include <errno.h>
 #include <hurd.h>
@@ -28,6 +30,13 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <libintl.h>
+#if ENABLE_NLS
+#  define _(String) dgettext (PACKAGE, String)
+#else
+#  define _(String) (String)
+#endif /* ENABLE_NLS */
+
 #define GNU_SPECIFIC(dev) ((GNUSpecific*) dev->arch_specific)
 
 typedef struct _GNUSpecific    GNUSpecific;
@@ -59,8 +68,6 @@
 static int
 _device_probe_geometry (PedDevice* dev)
 {
-       PED_ASSERT (dev->open_count > 0, return 0);
-
        dev->length = _device_get_length (dev);
        if (!dev->length)
                return 0;
@@ -85,7 +92,7 @@
        PedExceptionOption      ex_status;
 
 retry_open:
-       if (!_arch_device_open (dev)) {
+       if (!ped_device_open (dev)) {
                ex_status = ped_exception_throw (
                                PED_EXCEPTION_WARNING,
                                PED_EXCEPTION_RETRY_CANCEL,
@@ -105,7 +112,7 @@
        }
 
 retry_probe:
-       if (!device_probe_geometry (dev)) {
+       if (!_device_probe_geometry (dev)) {
                ex_status = ped_exception_throw (
                                PED_EXCEPTION_WARNING,
                                PED_EXCEPTION_RETRY_CANCEL,
@@ -148,6 +155,12 @@
        dev->path = strdup (path);
        if (!dev->path)
                goto error_free_dev;
+
+       dev->arch_specific
+               = (GNUSpecific*) ped_malloc (sizeof (GNUSpecific));
+       if (!dev->arch_specific)
+               goto error_free_path;
+
        dev->type = PED_DEVICE_FILE;    /* FIXME? */
        dev->open_count = 0;
        dev->external_mode = 0;
@@ -161,6 +174,8 @@
 
        return dev;
 
+error_free_arch_specific:
+       ped_free (dev->arch_specific);
 error_free_path:
        ped_free (dev->path);
 error_free_dev:
@@ -169,6 +184,13 @@
        return NULL;
 }
 
+void
+_arch_device_destroy (PedDevice* dev)
+{
+       ped_free (dev->path);
+       ped_free (dev);
+}
+
 static int
 _kernel_reread_part_table (PedDevice* dev)
 {
@@ -181,8 +203,6 @@
 {
        GNUSpecific*    arch_specific = GNU_SPECIFIC (dev);
 
-       PED_ASSERT (dev->open_count > 0, return);
-
        if (dev->read_only)
                return;
 
@@ -373,7 +393,8 @@
                                ? device_read_length + read_offset - have_read
                                : did_read);
 
-               vm_deallocate (mach_task_self (), store_read_buffer, did_read);
+               vm_deallocate (mach_task_self (), (long) store_read_buffer,
+                              did_read);
 
                have_read += did_read;
                store_start_block += did_read
@@ -491,8 +512,9 @@
                                case PED_EXCEPTION_UNHANDLED:
                                        ped_exception_catch ();
                                case PED_EXCEPTION_CANCEL:
-                                       vm_deallocate (mach_task_self (), temp,
-                                                     did_read);
+                                       vm_deallocate (mach_task_self (),
+                                                      (long) temp,
+                                                      did_read);
                                        return 0;
                        }
                }
@@ -501,7 +523,7 @@
                count -= flushing / PED_SECTOR_SIZE;
                buffer += write_offset;
 
-               vm_deallocate (mach_task_self (), temp, did_read);
+               vm_deallocate (mach_task_self (), (long) temp, did_read);
 
                if (count == 0)
                        return 1;
@@ -606,7 +628,8 @@
                        case PED_EXCEPTION_UNHANDLED:
                                ped_exception_catch ();
                        case PED_EXCEPTION_CANCEL:
-                               vm_deallocate (mach_task_self (), temp,
+                               vm_deallocate (mach_task_self (),
+                                              (long) temp,
                                               did_read);
                                return 0;
                }
@@ -647,7 +670,7 @@
                return 1;
 
        while (1) {
-               err = file_sync (po->store->source, 1, 0);
+               err = file_sync (arch_specific->store->source, 1, 0);
                if (! err || err == EOPNOTSUPP || err == EPERM
                    || (last_failure && strcmp (last_failure, dev->path) == 0))
                  break;
@@ -661,7 +684,7 @@
                switch (ex_status) {
                        case PED_EXCEPTION_IGNORE:
                                if (last_failure)
-                                       free (last_failure);
+                                       ped_free (last_failure);
                                last_failure = strdup (dev->path);
                                return 1;
 
@@ -681,21 +704,21 @@
 static 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");
+       _ped_device_probe ("/dev/sd0");
+       _ped_device_probe ("/dev/sd1");
+       _ped_device_probe ("/dev/sd2");
+       _ped_device_probe ("/dev/sd3");
+       _ped_device_probe ("/dev/sd4");
+       _ped_device_probe ("/dev/sd5");
+
+       _ped_device_probe ("/dev/hd0");
+       _ped_device_probe ("/dev/hd1");
+       _ped_device_probe ("/dev/hd2");
+       _ped_device_probe ("/dev/hd3");
+       _ped_device_probe ("/dev/hd4");
+       _ped_device_probe ("/dev/hd5");
+       _ped_device_probe ("/dev/hd6");
+       _ped_device_probe ("/dev/hd7");
 
        return 1;
 }

Attachment: pgpwXfgl77_Yq.pgp
Description: PGP signature


reply via email to

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