bug-parted
[Top][All Lists]
Advanced

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

[patch] Hurd


From: Neal H Walfield
Subject: [patch] Hurd
Date: Sun, 5 Aug 2001 02:08:26 +0200
User-agent: Mutt/1.3.18i

The attached patch (against 1.5.3) makes it possible to compile GNU
Parted on the Hurd.  However, in order to actually use GNU Parted, you
will also need to do:

        # CFLAGS=-D_FILE_OFFSET_BITS=64 ../configure

There should be a way to do this automagically; I just do not know what
that is.

Thanks.

diff --exclude configure --exclude aclocal.m4 --exclude Makefile.in -uprN 
parted-1.5.3.orig/configure.in parted-1.5.3/configure.in
--- parted-1.5.3.orig/configure.in      Fri Jul 27 01:46:00 2001
+++ parted-1.5.3/configure.in   Sun Aug  5 00:03:25 2001
@@ -202,15 +202,6 @@ dnl GNU/Hurd:
 if test x$OS = xgnu; then
        CFLAGS="$CFLAGS -D_GNU_SOURCE=1"
 
-dnl libstore
-       AC_CHECK_LIB(store, store_open, OS_LIBS="$OS_LIBS -lstore",
-               AC_MSG_ERROR(
-GNU Parted requires libstore when running on GNU/Hurd
-systems.  It is a standard part of a GNU/Hurd system.
-               )
-               exit
-       )
-
 dnl libshouldbeinlibc
        AC_CHECK_LIB(shouldbeinlibc, vm_deallocate,
                OS_LIBS="$OS_LIBS -lshouldbeinlibc",
@@ -221,6 +212,16 @@ GNU/Hurd systems.  It is a standard part
                exit
        )
 fi
+
+dnl libstore
+       AC_CHECK_LIB(store, store_open, OS_LIBS="$OS_LIBS -lstore",
+               AC_MSG_ERROR(
+GNU Parted requires libstore when running on GNU/Hurd
+systems.  It is a standard part of a GNU/Hurd system.
+               )
+               exit,
+               -lshouldbeinlibc
+       )
 
 AC_SUBST(OS_LIBS)
 
diff --exclude configure --exclude aclocal.m4 --exclude Makefile.in -uprN 
parted-1.5.3.orig/libparted/device_gnu.c parted-1.5.3/libparted/device_gnu.c
--- parted-1.5.3.orig/libparted/device_gnu.c    Fri Jun 22 03:05:46 2001
+++ parted-1.5.3/libparted/device_gnu.c Sun Aug  5 01:40:32 2001
@@ -53,8 +53,7 @@ _device_get_sector_size (PedDevice* dev)
        GNUSpecific*    arch_specific = GNU_SPECIFIC (dev);
        size_t          store_block_size = arch_specific->store->block_size;
 
-       PED_ASSERT (store_block_size % PED_SECTOR_SIZE == 0, return 0);
-       return store_block_size;
+       return PED_SECTOR_SIZE;
 }
 
 static PedSector
@@ -64,7 +63,7 @@ _device_get_length (PedDevice* dev)
        size_t          store_blocks = arch_specific->store->blocks;
        size_t          store_block_size = arch_specific->store->block_size;
 
-       return store_blocks / (store_block_size / PED_SECTOR_SIZE);
+       return ((long long) store_blocks * store_block_size) / PED_SECTOR_SIZE;
 }
 
 static int
@@ -334,6 +333,7 @@ _arch_device_read (const PedDevice* dev,
        /* In bytes.  This can be larger than COUNT when store pages are
           larger than PED_SECTOR_SIZE.  */
        size_t                  store_read_length;
+       char                    local_buffer[PED_SECTOR_SIZE];
        void *                  store_read_buffer;
        size_t                  have_read;
        size_t                  read_offset;
@@ -350,10 +350,12 @@ _arch_device_read (const PedDevice* dev,
                store_read_length = device_read_length;
        }
 
-       read_offset = start - store_start_block * 
arch_specific->store->block_size;
+       read_offset = start
+                     - store_start_block * arch_specific->store->block_size;
 
        if (store_read_length % arch_specific->store->block_size != 0)
-               store_read_length = store_read_length + 
arch_specific->store->block_size
+               store_read_length = store_read_length
+                                   + arch_specific->store->block_size
                                    - store_read_length % 
arch_specific->store->block_size;
 
 retry:
@@ -362,6 +364,9 @@ retry:
                size_t  did_read;
                size_t  offset;
 
+               store_read_buffer = local_buffer;
+               did_read = sizeof (local_buffer);
+
                err = store_read (arch_specific->store, store_start_block,
                                  store_read_length - have_read,
                                  &store_read_buffer, &did_read);
@@ -395,8 +400,9 @@ retry:
                                ? device_read_length + read_offset - have_read
                                : did_read);
 
-               vm_deallocate (mach_task_self (), (long) store_read_buffer,
-                              did_read);
+               if (store_read_buffer != local_buffer)
+                       vm_deallocate (mach_task_self (),
+                                      (long) store_read_buffer, did_read);
 
                have_read += did_read;
                store_start_block += did_read
@@ -417,6 +423,7 @@ _arch_device_write (PedDevice* dev, cons
        error_t                 err;
        PedExceptionOption      ex_status;
        void *                  temp;
+       char                    local_buffer[PED_SECTOR_SIZE];
        size_t                  did_read;
        size_t                  did_write;
 
@@ -453,6 +460,8 @@ _arch_device_write (PedDevice* dev, cons
 doggy_first_block_read:
                /* We do not bother looping as we are only reading a
                   single block.  */
+               temp = local_buffer;
+               did_read = sizeof (local_buffer);
                err = store_read (arch_specific->store,
                                  PED_TO_STORE (arch_specific->store, start),
                                  arch_specific->store->block_size, &temp,
@@ -514,9 +523,11 @@ doggy_first_block_write:
                                case PED_EXCEPTION_UNHANDLED:
                                        ped_exception_catch ();
                                case PED_EXCEPTION_CANCEL:
-                                       vm_deallocate (mach_task_self (),
-                                                      (long) temp,
-                                                      did_read);
+                                       if (temp != local_buffer)
+                                               vm_deallocate (
+                                                       mach_task_self (),
+                                                       (long) temp,
+                                                       did_read);
                                        return 0;
                        }
                }
@@ -525,7 +536,9 @@ doggy_first_block_write:
                count -= flushing / PED_SECTOR_SIZE;
                buffer += write_offset;
 
-               vm_deallocate (mach_task_self (), (long) temp, did_read);
+               if (temp != local_buffer)
+                       vm_deallocate (mach_task_self (), (long) temp,
+                                      did_read);
 
                if (count == 0)
                        return 1;
@@ -575,6 +588,8 @@ doggy_first_block_write:
 doggy_last_block_read:
        /* We do not bother looping as we are only reading a
           single block.  */
+       temp = local_buffer;
+       did_read = sizeof (local_buffer);
        err = store_read (arch_specific->store,
                          PED_TO_STORE (arch_specific->store, start),
                          arch_specific->store->block_size, &temp,
@@ -630,9 +645,10 @@ doggy_last_block_write:
                        case PED_EXCEPTION_UNHANDLED:
                                ped_exception_catch ();
                        case PED_EXCEPTION_CANCEL:
-                               vm_deallocate (mach_task_self (),
-                                              (long) temp,
-                                              did_read);
+                               if (temp != local_buffer)
+                                       vm_deallocate (mach_task_self (),
+                                                      (long) temp,
+                                                      did_read);
                                return 0;
                }
        }

Attachment: pgpTB1IsI1aUM.pgp
Description: PGP signature


reply via email to

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