+Support '/dev/ataraid/d0p1' device naming.
authorshort <>
Sun, 21 Dec 2003 21:28:31 +0000 (21:28 +0000)
committershort <>
Sun, 21 Dec 2003 21:28:31 +0000 (21:28 +0000)
+Display human readable 'parent partition' open error message.

src/libcaptive/storage/relastblock.c

index 903d838..f7aa7fa 100644 (file)
@@ -146,9 +146,13 @@ GIOChannel *iochannel_subrange_new;
 
        /* /dev/ide/host0/bus0/target0/lun0/part1 -> /dev/ide/host0/bus0/target0/lun0/disc */
        slashpart_prefix="/part";
-       if (!strcmp(linknum-strlen(slashpart_prefix),slashpart_prefix))
+       if (linknum>linkbuf+strlen(slashpart_prefix) && !strcmp(linknum-strlen(slashpart_prefix),slashpart_prefix))
                strcpy(linknum-strlen(slashpart_prefix),"/disc");
 
+       /* /dev/ataraid/d0p1 -> /dev/ataraid/d0 */
+       if (linknum>=linkbuf+2 && linknum[-1]=='p' && isdigit(linknum[-2]))
+               *--linknum='\0';
+
        iochannel_flags=g_io_channel_get_flags(iochannel);
        switch (iochannel_flags & (G_IO_FLAG_IS_READABLE|G_IO_FLAG_IS_WRITEABLE)) {
                case G_IO_FLAG_IS_READABLE:
@@ -160,11 +164,11 @@ GIOChannel *iochannel_subrange_new;
                default: g_assert_not_reached();
                }
 
-       iochannel_unix_new=g_io_channel_new_file(
+       if (!(iochannel_unix_new=g_io_channel_new_file(
                        linkbuf,        /* filename */
                        iochannel_unix_new_mode,        /* mode */
-                       NULL) /* error */
-       g_assert(iochannel_unix_new!=NULL);
+                       NULL))) /* error */
+               g_error(_("Parent partition \"%s\" not readable by mode \"%s\""),linkbuf,iochannel_unix_new_mode);
 
        /* 'iochannel_unix_new' sanity checks: */
        iochannel_unix_new_fd=captive_iounixchannel_get_fd(iochannel_unix_new);