bug-parted
[Top][All Lists]
Advanced

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

Errors while probing devices in GNU/Hurd.


From: Harley D. Eades III
Subject: Errors while probing devices in GNU/Hurd.
Date: 19 Dec 2004 23:46:06 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Hello,
      In GNU/Hurd when probing for devices a large sum of errors would scroll 
across the screen.

Errors: ./parted: cannot load libstore_/dev/sd0.so.0.3: 
libstore_/dev/sd0.so.0.3: cannot open shared object file: No such file or 
directory
./parted: cannot load libstore_/dev/sd0.so.0.3: libstore_/dev/sd0.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd1.so.0.3: libstore_/dev/sd1.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd1.so.0.3: libstore_/dev/sd1.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd2.so.0.3: libstore_/dev/sd2.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd2.so.0.3: libstore_/dev/sd2.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd3.so.0.3: libstore_/dev/sd3.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd3.so.0.3: libstore_/dev/sd3.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd4.so.0.3: libstore_/dev/sd4.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd4.so.0.3: libstore_/dev/sd4.so.0.3: 
cannot open shared object file: No such file or directory
./parted: cannot load libstore_/dev/sd5.so.0.3: libstore_/dev/sd5.so.0.3: 
cannot open shared 
..SNIP...
Error: No device found
Retry/Cancel?

I did some cosmetic changes as well. :)

What does everyone think?

Happy Hacking.
-Harley

This patch cures this problem.

2004-12-19  Harley D. Eades III  <address@hidden>
* libparted/gnu.c (gnu_new): Added three new variables ro_err, rw_err and 
ispath.
  The ispath variables is set to 1 if path is indeed a path and not a store type
  name.  This prevents having to use strchr more then once.  Added a check for
  determining if the inputted path is a path and not a store-type name.  If
  (const char *)path is a path then use store_open (). If (const char *)path is 
a 
  store-type name use store_typed_open ().

--- libparted/gnu.c     2004-09-13 19:49:43.000000000 -0500
+++ ../patched/stable/libparted/gnu.c   2004-12-14 20:42:03.000000000 -0600
@@ -224,7 +224,8 @@
 {
        PedDevice*      dev;
        GNUSpecific*    arch_specific;
-       error_t err;
+       error_t ro_err, rw_err;
+       int ispath = 0;
 
        PED_ASSERT (path != NULL, return NULL);
 
@@ -236,42 +237,57 @@
        arch_specific->consume = 1;
 
  retry_open:
-       err = store_typed_open (dev->path, 0, NULL, &arch_specific->store);
-       if (err) {
-               error_t rw_err = err;
-
-               err = store_typed_open (dev->path, STORE_READONLY, NULL,
-                                       &arch_specific->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) {
-                               return NULL;
-                       } else
-                               goto retry_open;
+       
+       /* Try read-write. */
+       if (strchr (dev->path, '/') != NULL) {
+         ispath = 1; /* We set this to prevent having to use strchr more then 
once. */
+         rw_err = store_open (dev->path, 0, NULL, &arch_specific->store);
+       } else {
+         rw_err = store_typed_open (dev->path, 0, NULL, &arch_specific->store);
+       }
+       
+       /* Try readonly. */
+       if (rw_err) {
+         if (ispath) {
+           ro_err = store_open (dev->path, STORE_READONLY, NULL,
+                                &arch_specific->store);
+         } else {
+           ro_err = store_typed_open (dev->path, STORE_READONLY, NULL,
+                                      &arch_specific->store);
+         }
+           
+           /* Error bail out. */
+           if (ro_err) {
+               if (ped_exception_throw (
+                                        PED_EXCEPTION_ERROR,
+                                        PED_EXCEPTION_RETRY_CANCEL,
+                                        _("Error opening %s: %s"),
+                                        dev->path, strerror (ro_err))
+                   != PED_EXCEPTION_RETRY) {
+                 return NULL;
                } 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, strerror (rw_err), dev->path);
-                       dev->read_only = 1;
+                 goto retry_open;
                }
+           } 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, strerror (rw_err), dev->path);
+             dev->read_only = 1;
+           }
        } else {
-               dev->read_only = 0;
+         dev->read_only = 0;
        }
-
+       
        _flush_cache (dev);
-
+       
        if (!init_file (dev)) {
-               gnu_destroy(dev);
-               return NULL;
+         gnu_destroy(dev);
+         return NULL;
        }
-
+       
        return dev;
 }
 






reply via email to

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